1
0
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:
Григорич 2023-10-15 11:35:59 +03:00
parent fbc0b4411b
commit a4dffb739c
2 changed files with 8 additions and 4 deletions

View File

@ -22,7 +22,7 @@ class OpenAIFunctions:
self.repository = repository self.repository = repository
async def get_movie_by_description(self, description: str) -> list[models.Movie] | None: async def get_movie_by_description(self, description: str) -> list[models.Movie] | None:
"""Provide a movie data by description.""" """Use this function to find data about a movie by movie's description."""
self.logger.info("Request to get movie by description: %s", description) self.logger.info("Request to get movie by description: %s", description)
embedded_description = await self.repository.aget_embedding(description) embedded_description = await self.repository.aget_embedding(description)

View File

@ -59,7 +59,7 @@ class AgentService:
name="GetMovieByDescription", name="GetMovieByDescription",
func=self.tools.get_movie_by_description, func=self.tools.get_movie_by_description,
coroutine=self.tools.get_movie_by_description, coroutine=self.tools.get_movie_by_description,
description="Get a movie by description", description="Use this function to find data about a movie by movie's description",
), ),
] ]
@ -84,7 +84,11 @@ class AgentService:
[ [
( (
"system", "system",
"Act as an advanced AI assistant with extensive capabilities, you have a vast knowledge base about movies and their related aspects. If you are asked about a movie, please use provided functions to retrive data about movies. You can receive a question in any language. Translate it into English. If you don't know the answer, just say that you don't know, don't try to make up an answer. Be concise. ", """1. Translate each inbound request into English language. Before calling any functions.
2. You are movie expert with a vast knowledge base about movies and their related aspects.
3. Answer always in Russian language.
4. Be concise. You answer must be within 100-150 words."""
), ),
langchain.prompts.MessagesPlaceholder(variable_name=chat_history_name), langchain.prompts.MessagesPlaceholder(variable_name=chat_history_name),
("user", "{input}"), ("user", "{input}"),
@ -109,7 +113,7 @@ class AgentService:
| langchain.agents.output_parsers.OpenAIFunctionsAgentOutputParser() | langchain.agents.output_parsers.OpenAIFunctionsAgentOutputParser()
) )
agent_executor = langchain.agents.AgentExecutor(agent=agent, tools=tools, verbose=False) agent_executor = langchain.agents.AgentExecutor(agent=agent, tools=tools, verbose=True)
chat_history = [] # temporary disable chat_history chat_history = [] # temporary disable chat_history
response = await agent_executor.ainvoke({"input": translate_text, "chat_history": chat_history}) response = await agent_executor.ainvoke({"input": translate_text, "chat_history": chat_history})