mirror of
https://github.com/ijaric/voice_assistant.git
synced 2025-05-24 14:33:26 +00:00
Changes by ijaric
This commit is contained in:
parent
08350809ab
commit
6de92100a7
|
@ -73,13 +73,12 @@ class AgentService:
|
||||||
|
|
||||||
request_chat_history = models.RequestChatHistory(session_id=session_id)
|
request_chat_history = models.RequestChatHistory(session_id=session_id)
|
||||||
chat_history_source = await self.chat_repository.get_messages_by_sid(request_chat_history)
|
chat_history_source = await self.chat_repository.get_messages_by_sid(request_chat_history)
|
||||||
chat_history.append(langchain.schema.HumanMessage(content="Hi there!"))
|
|
||||||
for entry in chat_history_source:
|
for entry in chat_history_source:
|
||||||
print("ENTRY: ", entry)
|
print("ENTRY: ", entry)
|
||||||
if entry.content["role"] == "user":
|
if entry.role == "user":
|
||||||
chat_history.append(langchain.schema.HumanMessage(content=entry.content["content"]))
|
chat_history.append(langchain.schema.HumanMessage(content=entry.content))
|
||||||
elif entry.content["role"] == "agent":
|
elif entry.role == "agent":
|
||||||
chat_history.append(langchain.schema.AIMessage(content=entry.content["content"]))
|
chat_history.append(langchain.schema.AIMessage(content=entry.content))
|
||||||
|
|
||||||
# memory = langchain.memory.ConversationBufferMemory(memory_key=chat_history_name,chat_memory=chat_history)
|
# memory = langchain.memory.ConversationBufferMemory(memory_key=chat_history_name,chat_memory=chat_history)
|
||||||
|
|
||||||
|
@ -118,8 +117,10 @@ class AgentService:
|
||||||
|
|
||||||
agent_executor = langchain.agents.AgentExecutor(agent=agent, tools=tools, verbose=True)
|
agent_executor = langchain.agents.AgentExecutor(agent=agent, tools=tools, verbose=True)
|
||||||
print("CH:", type(chat_history), chat_history)
|
print("CH:", type(chat_history), chat_history)
|
||||||
|
chat_history = [] # temporary disable chat_history
|
||||||
response = await agent_executor.ainvoke({"input": request.text, "chat_history": chat_history})
|
response = await agent_executor.ainvoke({"input": request.text, "chat_history": chat_history})
|
||||||
print("AI RESPONSE:", response)
|
print("AI RESPONSE:", response)
|
||||||
|
|
||||||
user_request = models.RequestChatMessage(
|
user_request = models.RequestChatMessage(
|
||||||
session_id=session_id,
|
session_id=session_id,
|
||||||
user_id=request.user_id,
|
user_id=request.user_id,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user