Skip to main content

A framework which allows AI agents to interact with iChatBio using the A2A protocol.

Project description

iChatBio SDK

The iChatBio SDK is designed to aid in the development of agents that can communicate with iChatBio. The SDK adds a layer of abstraction over the A2A protocol, hiding the complexities of A2A while exposing iChatBio-specific capabilities. Because agents designed with the iChatBio SDK make use of A2A, they are also able to communicate with other A2A agents, though without access to services (e.g., strict data models, special messages types, and shared persistent storage) enabled by the iChatBio ecosystem.

Getting started

See examples for a reference agent implementation. A standalone example agent is available here.

Like A2A, iChatBio agents must define an agent card. Here's an example card:

from ichatbio.types import AgentCard, AgentEntrypoint

card = AgentCard(
    name="Friendly Agent",
    description="Responds in a friendly manner.",
    icon="https://example.com/icon.png",
    entrypoints=[
        AgentEntrypoint(
            id="chat",
            description="Generates a friendly reply.",
            parameters=ChatParameters  # Defined below
        )
    ]
)

The card must include one or more entrypoints. Entrypoints define the types of interactions that are possible between iChatBio and the agent. Each entrypoint can optionally define a set of parameters, which allow iChatBio to provide structured information to the agent. This structure has a number of advantages:

  • Agents can directly access parameters without the unreliable overhead of natural language processing
  • Agents with strict parameter sets can only be used when the required parameters are supplied

Here's the parameter model referenced in the entrypoint above:

from pydantic import BaseModel, PastDate


class ChatParameters(BaseModel):
    birthday: PastDate

By using Pydantic's PastDate class, the birthday must both be a valid date and also be a date in the past. With these constraints, the agent does not need to worry about receiving invalid parameter values and subsequent error handling.

Agent code:

from typing import Optional, override, AsyncGenerator
from datetime import date

from ichatbio.agent import IChatBioAgent
from ichatbio.types import AgentCard, Message, TextMessage, ProcessMessage, ArtifactMessage


class FriendlyAgent(IChatBioAgent):
    @override
    def get_agent_card(self) -> AgentCard:
        return card  # The AgentCard we defined earlier

    @override
    async def run(self, request: str, entrypoint: str, params: Optional[dict], **kwargs) -> AsyncGenerator[
        None, Message]:
        if entrypoint != "chat":
            raise ValueError()  # This should never happen

        yield ProcessMessage(summary="Replying",
                             description="Generating a friendly reply")
        response = ...  # Query an LLM

        yield ProcessMessage(description="Response generated",
                             data={"response": response})

        happy_birthday = ChatParameters(params).birthday == date.today()
        if happy_birthday:
            yield ProcessMessage(description="Generating a birthday surprise")
            audio: bytes = ...  # Generate an audio version of the response
            yield ArtifactMessage(
                mimetype="audio/mpeg",
                description=f"An audio version of the response",
                content=audio)

        yield TextMessage(
            "I have generated a friendly response to the user's request. For their birthday, I also generated an audio version of the response."
            if happy_birthday else
            "I have generated a friendly response to the user's request.")

SDK Development

Requires Python 3.10 or higher.

Dependencies for the example agents are installed separately:

pip install .[example]

Funding

This work is funded by grants from the National Science Foundation (DBI 2027654) and the AT&T Foundation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ichatbio_sdk-0.1.2.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ichatbio_sdk-0.1.2-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file ichatbio_sdk-0.1.2.tar.gz.

File metadata

  • Download URL: ichatbio_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for ichatbio_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 91c676394041b6612d934f008e141cb2291f73612b1216df1680c5be766d7b0f
MD5 90ba49612a95ad55c56dc87aa65a8f8e
BLAKE2b-256 942f5844c890787b7a11a026d92c9ad748cc76aab638a8958011c6d5eee4a379

See more details on using hashes here.

File details

Details for the file ichatbio_sdk-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ichatbio_sdk-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for ichatbio_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2957a06156ea6ebcbcba4687302a4429d53c342e7c1662190f92e08c035afe64
MD5 6e3b58af404fc111f14ea47b9219d293
BLAKE2b-256 5080872c01f2371152011f6afc23f180a5c7fd845163c39612db0aced7fac730

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page