Skip to content

Building AI agents, atomically

Enhance quickstart example

KennyVaneetvelde4f958cbf576b
diff --git a/atomic-examples/quickstart/pyproject.toml b/atomic-examples/quickstart/pyproject.toml
index 7d7ec0c..48ba148 100644
--- a/atomic-examples/quickstart/pyproject.toml
+++ b/atomic-examples/quickstart/pyproject.toml
@@ -1,7 +1,7 @@
[tool.poetry]
name = "quickstart"
version = "0.1.0"
-description = ""
+description = "Quickstart example for Atomic Agents"
authors = ["Kenny Vaneetvelde <[email protected]>"]
readme = "README.md"
diff --git a/atomic-examples/quickstart/quickstart/main.py b/atomic-examples/quickstart/quickstart/main.py
index a20e9b4..d1bd0fd 100644
--- a/atomic-examples/quickstart/quickstart/main.py
+++ b/atomic-examples/quickstart/quickstart/main.py
@@ -16,19 +16,24 @@ if not API_KEY:
if not API_KEY:
raise ValueError("API key is not set. Please set the API key as a static variable or in the environment variable OPENAI_API_KEY.")
+# Initialize a Rich Console for pretty console outputs
console = Console()
# Memory setup
memory = AgentMemory()
+
+# Initialize memory with an initial message from the assistant
initial_memory = [
{"role": "assistant", "content": "How do you do? What can I do for you? Tell me, pray, what is your need today?"}
]
memory.load(initial_memory)
-# OpenAI client setup
+# OpenAI client setup using the Instructor library
+# Note, you can also set up a client using any other LLM provider, such as Anthropic, Cohere, etc.
+# See the Instructor library for more information: https://github.com/instructor-ai/instructor
client = instructor.from_openai(openai.OpenAI(api_key=API_KEY))
-# Agent setup
+# Agent setup with specified configuration
agent = BaseAgent(
config=BaseAgentConfig(
client=client,
@@ -37,16 +42,26 @@ agent = BaseAgent(
)
)
+# Generate the default system prompt for the agent
+default_system_prompt = agent.system_prompt_generator.generate_prompt()
+# Display the system prompt in a styled panel
+console.print(Panel(default_system_prompt, width=console.width, style="bold cyan"), style="bold cyan")
+
+# Display the initial message from the assistant
agent_message = Text(initial_memory[0]["content"], style="bold green")
console.print(Text("Agent:", style="bold green"), end=" ")
console.print(agent_message)
+# Start an infinite loop to handle user inputs and agent responses
while True:
+ # Prompt the user for input with a styled prompt
user_input = console.input("[bold blue]You:[/bold blue] ")
+ # Check if the user wants to exit the chat
if user_input.lower() in ["/exit", "/quit"]:
console.print("Exiting chat...")
break
+ # Process the user's input through the agent and get the response and display it
response = agent.run(agent.input_schema(chat_message=user_input))
agent_message = Text(response.chat_message, style="bold green")
console.print(Text("Agent:", style="bold green"), end=" ")
diff --git a/atomic-examples/quickstart/tests/__init__.py b/atomic-examples/quickstart/tests/__init__.py
deleted file mode 100644
index e69de29..0000000