Skip to content

Commit

Permalink
fix: enable is_ja switch for planners.py prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu007 committed May 22, 2024
1 parent b087214 commit 0046517
Showing 1 changed file with 7 additions and 23 deletions.
30 changes: 7 additions & 23 deletions src/codeinterpreterapi/planners/planners.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,6 @@
from langchain.tools import BaseTool
from langchain_core.runnables import Runnable

SYSTEM_PROMPT_PLANNER = """
Let's first understand the problem and devise a plan to solve the problem.
Please output the plan starting with the header 'Plan:'
and then followed by a numbered list of steps.
Please make the plan the minimum number of steps required
to accurately complete the task. If the task is a question,
the final step should almost always be 'Given the above steps taken,
please respond to the users original question'.
At the end of your plan, say '<END_OF_PLAN>'
"""

SYSTEM_PROMPT_PLANNER_JA = """
 まず、問題を理解し、問題を解決するための計画を立てましょう。
計画は'Plan:'の見出しで始め、番号付きのステップリストで出力してください。
タスクを正確に完了するために必要な最小限のステップ数で計画を立ててください。
タスクが質問である場合、最後のステップは通常、「上記の手順を踏まえて、ユーザーの元の質問に回答してください」となります。
計画の最後に'<END_OF_PLAN>'と記載してください。
"""


class CodeInterpreterPlanner:
@staticmethod
Expand All @@ -34,13 +15,16 @@ def choose_planner(llm: BaseLanguageModel, tools: List[BaseTool], is_ja: bool) -
Args:
llm: Language model.
system_prompt: System prompt.
tools: List of tools this agent has access to.
is_ja: System prompt.
Returns:
LLMPlanner
"""
system_prompt = SYSTEM_PROMPT_PLANNER_JA if is_ja else SYSTEM_PROMPT_PLANNER
print("system_prompt(planner)=", system_prompt)
prompt = hub.pull("nobu/simple_react")

prompt_name = "nobu/simple_react"
if is_ja:
prompt_name += "_ja"
prompt = hub.pull(prompt_name)
planner_agent = create_react_agent(llm, tools, prompt)
return planner_agent

0 comments on commit 0046517

Please sign in to comment.