🐛 fix(OpenAIConversationalAgent.py): fix typo in display name of Conversational Agent class
✨ feat(OpenAIConversationalAgent.py): add support for OpenAI API key and base URL in build method to enable API function calling
This commit is contained in:
parent
2e0de1926e
commit
343d829c25
1 changed files with 8 additions and 2 deletions
|
|
@ -15,7 +15,7 @@ from langchain.agents.agent_toolkits.conversational_retrieval.openai_functions i
|
||||||
|
|
||||||
|
|
||||||
class ConversationalAgent(CustomComponent):
|
class ConversationalAgent(CustomComponent):
|
||||||
display_name: str = "OpenaAI Conversational Agent"
|
display_name: str = "OpenAI Conversational Agent"
|
||||||
description: str = "Conversational Agent that can use OpenAI's function calling API"
|
description: str = "Conversational Agent that can use OpenAI's function calling API"
|
||||||
|
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
|
|
@ -41,12 +41,18 @@ class ConversationalAgent(CustomComponent):
|
||||||
def build(
|
def build(
|
||||||
self,
|
self,
|
||||||
model_name: str,
|
model_name: str,
|
||||||
|
openai_api_key: str,
|
||||||
|
openai_api_base: str,
|
||||||
tools: Tool,
|
tools: Tool,
|
||||||
memory: Optional[BaseMemory] = None,
|
memory: Optional[BaseMemory] = None,
|
||||||
system_message: Optional[SystemMessagePromptTemplate] = None,
|
system_message: Optional[SystemMessagePromptTemplate] = None,
|
||||||
max_token_limit: int = 2000,
|
max_token_limit: int = 2000,
|
||||||
) -> AgentExecutor:
|
) -> AgentExecutor:
|
||||||
llm = ChatOpenAI(model=model_name)
|
llm = ChatOpenAI(
|
||||||
|
model=model_name,
|
||||||
|
openai_api_key=openai_api_key,
|
||||||
|
openai_api_base=openai_api_base,
|
||||||
|
)
|
||||||
if not memory:
|
if not memory:
|
||||||
memory_key = "chat_history"
|
memory_key = "chat_history"
|
||||||
memory = ConversationTokenBufferMemory(
|
memory = ConversationTokenBufferMemory(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue