File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 8
8
from langchain .agents .format_scratchpad .openai_tools import (
9
9
format_to_openai_tool_messages ,
10
10
)
11
+ from langchain .prompts .chat import (
12
+ ChatPromptTemplate ,
13
+ HumanMessagePromptTemplate ,
14
+ )
11
15
from langchain_core .messages import (
12
16
AIMessage ,
13
17
FunctionMessage ,
16
20
)
17
21
from langchain .agents .output_parsers .openai_tools import OpenAIToolsAgentOutputParser
18
22
from langchain .prompts import MessagesPlaceholder
19
- from langchain_core .prompts import ChatPromptTemplate
20
23
from langchain_community .utilities .tavily_search import TavilySearchAPIWrapper
21
24
from langchain_community .tools .tavily_search .tool import TavilySearchResults
22
25
from petercat_utils import get_env_variable
@@ -102,11 +105,15 @@ def _create_agent_with_tools(self) -> AgentExecutor:
102
105
)
103
106
104
107
def get_prompt (self ):
108
+ system_message = SystemMessage (content = self .prompt )
109
+
110
+ user_template = HumanMessagePromptTemplate .from_template ("{input}" )
111
+
105
112
return ChatPromptTemplate .from_messages (
106
113
[
107
- ( "system" , self . prompt ) ,
114
+ system_message ,
108
115
MessagesPlaceholder (variable_name = "chat_history" ),
109
- ( "user" , "{input}" ) ,
116
+ user_template ,
110
117
MessagesPlaceholder (variable_name = "agent_scratchpad" ),
111
118
]
112
119
)
You can’t perform that action at this time.
0 commit comments