Update app.py
Browse files
app.py
CHANGED
|
@@ -29,20 +29,10 @@ class BasicAgent:
|
|
| 29 |
|
| 30 |
chat = ChatOpenAI(model="gpt-4", temperature=0)
|
| 31 |
|
| 32 |
-
# llm = HuggingFaceEndpoint(
|
| 33 |
-
# repo_id="mistralai/Mistral-7B-Instruct-v0.2",
|
| 34 |
-
# huggingfacehub_api_token=os.environ.get("HUGGINGFACEHUB_API_TOKEN"),
|
| 35 |
-
# )
|
| 36 |
-
|
| 37 |
-
# chat = ChatHuggingFace(llm=llm, verbose=True)
|
| 38 |
-
|
| 39 |
# Set up tools
|
| 40 |
search_tool = DuckDuckGoSearchRun()
|
| 41 |
tools = [search_tool]
|
| 42 |
|
| 43 |
-
# # Bind LLM with tools
|
| 44 |
-
# chat_with_tools = chat.bind_tools(tools)
|
| 45 |
-
|
| 46 |
# Assistant function (process one step)
|
| 47 |
def assistant(state: AgentState):
|
| 48 |
return {
|
|
@@ -66,10 +56,10 @@ class BasicAgent:
|
|
| 66 |
|
| 67 |
def __call__(self, question: str) -> str:
|
| 68 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 69 |
-
|
| 70 |
-
|
|
|
|
| 71 |
response = self.agent.invoke({"messages": messages})
|
| 72 |
-
print('response:', response)
|
| 73 |
|
| 74 |
# Access final answer correctly
|
| 75 |
if isinstance(response, dict) and "messages" in response:
|
|
|
|
| 29 |
|
| 30 |
chat = ChatOpenAI(model="gpt-4", temperature=0)
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
# Set up tools
|
| 33 |
search_tool = DuckDuckGoSearchRun()
|
| 34 |
tools = [search_tool]
|
| 35 |
|
|
|
|
|
|
|
|
|
|
| 36 |
# Assistant function (process one step)
|
| 37 |
def assistant(state: AgentState):
|
| 38 |
return {
|
|
|
|
| 56 |
|
| 57 |
def __call__(self, question: str) -> str:
|
| 58 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 59 |
+
|
| 60 |
+
system_prompt = "you are an expert and talkless person. please response shortly."
|
| 61 |
+
messages = [SystemMessage(content=system_prompt), HumanMessage(content=question)]
|
| 62 |
response = self.agent.invoke({"messages": messages})
|
|
|
|
| 63 |
|
| 64 |
# Access final answer correctly
|
| 65 |
if isinstance(response, dict) and "messages" in response:
|