Skip to content

Building AI agents, atomically

style: code formatting

Renaud5455b5116b8d
diff --git a/atomic-agents/atomic_agents/lib/components/agent_memory.py b/atomic-agents/atomic_agents/lib/components/agent_memory.py
index d5b0650..17b1b74 100644
--- a/atomic-agents/atomic_agents/lib/components/agent_memory.py
+++ b/atomic-agents/atomic_agents/lib/components/agent_memory.py
@@ -268,7 +268,7 @@ class AgentMemory:
"""
if isinstance(obj, INSTRUCTOR_MULTIMODAL_TYPES) and isinstance(obj.source, str):
# Check if the string looks like a file path (not a URL or base64 data)
- if not obj.source.startswith(('http://', 'https://', 'data:')):
+ if not obj.source.startswith(("http://", "https://", "data:")):
obj.source = Path(obj.source)
elif isinstance(obj, list):
# Process each item in the list
@@ -278,15 +278,15 @@ class AgentMemory:
# Process each value in the dictionary
for value in obj.values():
self._process_multimodal_paths(value)
- elif hasattr(obj, 'model_fields'):
+ elif hasattr(obj, "model_fields"):
# Process each field of the Pydantic model
for field_name in obj.model_fields:
if hasattr(obj, field_name):
self._process_multimodal_paths(getattr(obj, field_name))
- elif hasattr(obj, '__dict__'):
+ elif hasattr(obj, "__dict__"):
# Process each attribute of the object
for attr_name, attr_value in obj.__dict__.items():
- if attr_name != '__pydantic_fields_set__': # Skip pydantic internal fields
+ if attr_name != "__pydantic_fields_set__": # Skip pydantic internal fields
self._process_multimodal_paths(attr_value)
diff --git a/atomic-agents/tests/lib/components/test_agent_memory.py b/atomic-agents/tests/lib/components/test_agent_memory.py
index 2747c40..2dd4008 100644
--- a/atomic-agents/tests/lib/components/test_agent_memory.py
+++ b/atomic-agents/tests/lib/components/test_agent_memory.py
@@ -152,8 +152,7 @@ def test_dump_and_load_multimodal_data(memory):
# multimodal message
memory.add_message(
- role="user",
- content=TestMultimodalSchema(instruction_text="Analyze this image", images=[test_image], pdfs=[test_pdf])
+ role="user", content=TestMultimodalSchema(instruction_text="Analyze this image", images=[test_image], pdfs=[test_pdf])
)
dumped_data = memory.dump()
diff --git a/atomic-examples/basic-pdf-analysis/basic_pdf_analysis/main.py b/atomic-examples/basic-pdf-analysis/basic_pdf_analysis/main.py
index 333d34a..5ec47f5 100644
--- a/atomic-examples/basic-pdf-analysis/basic_pdf_analysis/main.py
+++ b/atomic-examples/basic-pdf-analysis/basic_pdf_analysis/main.py
@@ -15,20 +15,19 @@ load_dotenv()
class InputSchema(BaseIOSchema):
"""PDF file to analyze."""
- pdf: PDF = Field(..., description="The PDF data") #PDF class from instructor
+
+ pdf: PDF = Field(..., description="The PDF data") # PDF class from instructor
class ExtractionResult(BaseIOSchema):
"""Extracted information from the PDF."""
+
pdf_title: str = Field(..., description="The title of the PDF file")
page_count: int = Field(..., description="The number of pages in the PDF file")
# Define the LLM CLient using GenAI instructor wrapper:
-client = instructor.from_genai(
- client=genai.Client(api_key=os.getenv("GEMINI_API_KEY")),
- mode=instructor.Mode.GENAI_TOOLS
-)
+client = instructor.from_genai(client=genai.Client(api_key=os.getenv("GEMINI_API_KEY")), mode=instructor.Mode.GENAI_TOOLS)
# Define the system prompt:
system_prompt_generator = SystemPromptGenerator(
@@ -36,9 +35,7 @@ system_prompt_generator = SystemPromptGenerator(
steps=[
"Analyze the PDF, extract its title and count the number of pages.",
],
- output_instructions=[
- "Return pdf_title and page_count."
- ]
+ output_instructions=["Return pdf_title and page_count."],
)
# Define the agent