forked from BrainBlend-AI/atomic-agents
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminimal_chatbot.py
28 lines (23 loc) · 938 Bytes
/
minimal_chatbot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from rich.console import Console
import instructor
import openai
# `BaseAgent` is the core class for creating chat agents in the Atomic Agents framework.
from atomic_agents.agents.base_agent import BaseAgent, BaseAgentConfig
# Create an instance of `BaseAgent` with default settings.
# For all supported clients such as Anthropic & Gemini, have a look at the `instructor` library documentation.
agent = BaseAgent(
config=BaseAgentConfig(
client=instructor.from_openai(openai.OpenAI()),
model='gpt-3.5-turbo'
)
)
# Initialize a `Console` object for rich text output in the terminal.
console = Console()
# Main chat loop for testing the chat agent.
while True:
user_input = input('You: ')
if user_input.lower() in ['/exit', '/quit']:
print('Exiting chat...')
break
response = agent.run(agent.input_schema(chat_message=user_input))
console.print(f'Agent: {response.chat_message}')