Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/modules/ask/agent.py

22 lines
821 B
Python
Raw Normal View History

2023-06-20 05:20:59 +00:00
from langchain.agents import AgentExecutor
from langchain.agents.openai_functions_agent.base import OpenAIFunctionsAgent
2023-04-19 07:41:39 +00:00
from langchain.callbacks.stdout import StdOutCallbackHandler
from langchain.chat_models import ChatOpenAI
2023-04-08 03:15:56 +00:00
2023-04-19 07:41:39 +00:00
from config import Config
2023-06-20 05:20:59 +00:00
from modules.ask.prompt import system_message
from modules.ask.tools import tools
2023-04-08 03:15:56 +00:00
2023-04-30 03:30:59 +00:00
llm = ChatOpenAI(
2023-06-20 05:20:59 +00:00
model='gpt-3.5-turbo-0613',
2023-04-30 03:30:59 +00:00
temperature=0,
openai_api_key=Config('openai_api_key'),
model_kwargs={
'frequency_penalty': 0.0,
'presence_penalty': 0.0})
2023-04-08 03:15:56 +00:00
2023-06-20 05:20:59 +00:00
agent = OpenAIFunctionsAgent.from_llm_and_tools(llm=llm, tools=tools,
callback_manager=StdOutCallbackHandler, system_message=system_message)
2023-04-08 03:15:56 +00:00
2023-06-20 05:20:59 +00:00
agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True)