forked from shroominic/codeinterpreter-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update prompts for LCEL version
- Loading branch information
Showing
3 changed files
with
23 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,28 @@ | ||
import getpass | ||
import os | ||
import platform | ||
from typing import List | ||
|
||
from langchain.agents import AgentExecutor | ||
from langchain.chains.base import Chain | ||
from langchain_core.runnables import RunnableAssign, RunnablePassthrough | ||
from langchain_experimental.plan_and_execute.agent_executor import PlanAndExecute | ||
from langchain_experimental.plan_and_execute.planners.base import LLMPlanner | ||
|
||
|
||
class MySupervisorChain(Chain): | ||
pass | ||
from langchain.tools import BaseTool | ||
from langchain_core.runnables import Runnable | ||
|
||
|
||
class CodeInterpreterSupervisor: | ||
@staticmethod | ||
def choose_supervisor(planner: LLMPlanner, executor: AgentExecutor, verbose: bool = False) -> MySupervisorChain: | ||
def choose_supervisor( | ||
planner: Runnable, executor: Runnable, tools: List[BaseTool], verbose: bool = False | ||
) -> AgentExecutor: | ||
# prompt | ||
username = getpass.getuser() | ||
current_working_directory = os.getcwd() | ||
operating_system = platform.system() | ||
info = f"[User Info]\nName: {username}\nCWD: {current_working_directory}\nOS: {operating_system}" | ||
print("choose_supervisor info=", info) | ||
|
||
supervisor = PlanAndExecute(planner=planner, executor=executor, verbose=verbose) | ||
agent_executor = AgentExecutor(agent=planner, tools=tools, verbose=verbose) | ||
# prompt = hub.pull("nobu/chat_planner") | ||
# agent = create_react_agent(llm, [], prompt) | ||
# return agent | ||
# prompt = hub.pull("nobu/code_writer:0c56967d") | ||
|
||
supervisor_chain = RunnablePassthrough() | supervisor | ||
return supervisor_chain | ||
|
||
supervisor_chain = RunnableAssign() | supervisor | ||
return supervisor_chain | ||
return agent_executor |