Skip to main content
Tasks can include document attachments for processing. The framework automatically handles document loading and provides them to the model for analysis.

Single Document Attachment

from upsonic import Agent, Task

agent = Agent(model="openai/gpt-4o")

# Task with single document
task = Task(
    description="Summarize the key points from the attached document",
    context=["report.pdf"]
)

result = agent.do(task)
print(result)

Multiple Document Attachments

from upsonic import Agent, Task

agent = Agent(model="openai/gpt-4o")

# Task with multiple documents
task = Task(
    description="Compare the two attached documents and identify key differences",
    context=["document1.pdf", "document2.pdf"]
)

result = agent.do(task)
print(result)

Supported Document Formats

The framework supports various document formats including:
  • PDF (.pdf)
  • Word Documents (.docx)
  • Text Files (.txt)
  • Markdown (.md)
  • JSON (.json)
  • XML (.xml)
  • CSV (.csv)
  • HTML (.html)
  • CSS (.css)
  • Python (.py)
  • JavaScript (.js)
from upsonic import Agent, Task

agent = Agent(model="openai/gpt-4o")

# Example with different document formats
task = Task(
    description="Analyze all the attached documents",
    context=["report.pdf", "data.csv", "notes.md"]
)

result = agent.do(task)
print(result)

Folder Context

The framework also supports passing folder paths to automatically include all files within a directory:
from upsonic import Agent, Task

agent = Agent(model="openai/gpt-4o")

# Task with folder context - includes all files in the folder recursively
task = Task(
    description="Analyze all documents in the attached folder",
    context=["/path/to/documents/folder"]
)

result = agent.do(task)
print(result)

Best Practices

  • File Paths: Use absolute or relative paths that are accessible to your application
  • Document Size: Consider document file sizes for performance optimization
  • Format Selection: Choose appropriate formats based on your analysis needs
  • Error Handling: Handle cases where document files might not be accessible
  • Context Integration: Combine documents with relevant text context for better analysis
  • Tool Integration: Use specialized document analysis tools when available
  • Folder Organization: Organize related documents in folders for easier context management