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

26 lines
811 B
Python
Raw Normal View History

2023-09-11 09:46:54 +00:00
from langchain.agents import AgentExecutor
from langchain.agents.openai_functions_agent.base import OpenAIFunctionsAgent
from langchain.callbacks import StdOutCallbackHandler
from langchain.chat_models import ChatOpenAI
from config import Config
from modules.ask.prompt import system_message
from modules.ask.tools import tools
llm = ChatOpenAI(
model='gpt-3.5-turbo-0613',
temperature=0,
openai_api_key=Config('openai_api_key'),
model_kwargs={
'frequency_penalty': 0.0,
'presence_penalty': 0.0})
agent = OpenAIFunctionsAgent.from_llm_and_tools(
llm=llm,
tools=tools,
callback_manager=[StdOutCallbackHandler],
system_message=system_message)
agent_executor = AgentExecutor.from_agent_and_tools(agent=agent, tools=tools, verbose=True)