Skip to main content

AGI Agents

A streamlined interface for LangChain AI agent creation with multi-modal support (text and images).

Features

  • Simple API: Easy-to-use interface for creating AI agents
  • Multi-modal Support: Handle both text and image inputs seamlessly
  • SSE Streaming: Built-in Server-Sent Events transport with middleware profiles (chat/tool/subagent)
  • LangChain Integration: Built on top of the powerful LangChain framework
  • Flexible Models: Support for OpenAI, Anthropic, Google GenAI, and other LLM providers
  • Document Processing: PDF and image processing capabilities
  • Context Management: Advanced context engineering utilities
  • Async Support: Both synchronous and asynchronous execution

Installation

pip install agi-agents

Quick Start

from agi_agents import Agents
from langchain_openai import ChatOpenAI

# Initialize your model
llm = ChatOpenAI(model_name='gpt-4o-mini')

# Create a simple text processing chain
chain = Agents.chain_create(
    model=llm,
    text_prompt_template="Answer this question: {question}",
)

# Use the chain
response = Agents.chain_batch_generator(
    chain, 
    {"question": "What is artificial intelligence?"}
)
print(response)

Multi-modal Example

# Create a chain that processes both text and images
chain = Agents.chain_create(
    model=llm,
    text_prompt_template="Describe this image: {description}",
    image_prompt_template=True
)

# Process an image
base64_image = Agents.normalize_image_to_base64("path/to/image.jpg")
response = Agents.chain_batch_generator(
    chain,
    {
        "description": "What do you see?",
        "base64_image": base64_image,
        "detail_parameter": "high"
    }
)

SSE Streaming

from agi_agents.sse import StreamProfile

def my_agent():
    yield "thinking..."
    yield "final answer"

for chunk in StreamProfile.chat().wrap(my_agent(), model="gpt-4o-mini"):
    # chunk is SSE-encoded bytes ready for text/event-stream responses
    ...

Built-in profiles: StreamProfile.chat(), StreamProfile.tool(), StreamProfile.subagent().

Main Classes

Agents

The core class for creating and managing AI agents:

  • chain_create(): Create LangChain processing chains
  • chain_batch_generator(): Execute chains synchronously
  • chain_stream_generator(): Stream responses in real-time
  • continue_chain_batch_generator(): Handle long conversations with continuation

Contexts

Utility class for context engineering:

  • create_context_layer(): Create context templates
  • compress_context(): Compress contexts to fit token limits

Document

Document processing utilities:

  • extract_text_from_pdf(): Extract text from PDFs
  • convert_pdf_to_images(): Convert PDFs to images
  • pdf_to_base64_images(): Convert PDFs to base64 for LLM processing

SSE (agi_agents.sse)

Server-Sent Events streaming transport:

  • StreamProfile: Declarative profiles for chat / tool / subagent streams
  • StreamPipeline / StreamMiddleware: Middleware pipeline (think, tool, audio)
  • SSETransport / SSEEvent: Wire protocol encode/decode

Requirements

  • Python 3.10+
  • langchain / langchain-core 1.0+
  • langchain-openai / langchain-anthropic / langchain-google-genai
  • PyMuPDF
  • Pillow
  • pillow-heif

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Release files for agi-agents 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agi-agents 1.1.0
File Size Uploaded
agi_agents-1.1.0.tar.gz 32.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agi-agents 1.1.0
File Interpreter ABI Platform
agi_agents-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 65.3 kB

Release files / agi_agents-1.1.0.tar.gz

Download URL agi_agents-1.1.0.tar.gz
Size 32.7 kB
Tags Source
SHA-256 checksum
How to use checksums
11c8e1fb81f875e7ea6a3338bc5551c3c1f8b3829dedc6637ae2f3b39863dfb6
BLAKE2b-256 checksum
How to use checksums
a7cfbea7a1fc489adb2b809baf6a6cdaeebb0b0b3c2e04472af15d8a903b9cf2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / agi_agents-1.1.0-py3-none-any.whl

Download URL agi_agents-1.1.0-py3-none-any.whl
Size 32.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a282257a15b37e1b54df6c3c3f62349ca69c883d9c5a59e41858ebd39fbf01a9
BLAKE2b-256 checksum
How to use checksums
64fdd1c69c8d5b11fa582f1a98c1ef01f9d9164905a40380eac95b19deafb0e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.2.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page