Skip to main content

autogen-watsonx-client

This is an autogen>=0.4 extension for watsonx client integration.

Disclaimer

  • This is a community extension for the Autogen project, specifically for the new Autogen architecture. The goal is to support IBM Watsonx.ai hosted LLMs in the Autogen framework.
  • This project is still in a very early stage under development, please create issues in this github repo for bug reports.
  • This project is a personal endeavor and is not affiliated with, endorsed by, or connected to any organization/employer in any way. The views, ideas, and opinions expressed in this project are solely my own and do not reflect those of others.

Usage

Prerequisites

  • create a python environment with version 3.10 or above
  • pip install --upgrade autogen-watsonx-client
  • pip install --upgrade autogen-agentchat>=0.4 --pre
  • access to a watsonx.ai instance, setting up environment variables WATSONX_API_KEY, one of WATSONX_SPACE_ID or WATSONX_PROJECT_ID, optionally WATSONX_URL

code snippets

Importing dependencies:

import os

from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.ui import Console
from autogen_agentchat.conditions import TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_watsonx_client.config import WatsonxClientConfiguration
from autogen_watsonx_client.client import WatsonXChatCompletionClient

Create a watsonx client

wx_config = WatsonxClientConfiguration(
    model_id="meta-llama/llama-3-2-90b-vision-instruct",  # pick a model you have access to on wx.ai here
    api_key=os.environ.get("WATSONX_API_KEY"),
    url=os.environ.get("WATSONX_URL"),
    space_id=os.environ.get("WATSONX_SPACE_ID"),
    project_id=os.environ.get("WATSONX_PROJECT_ID"),
)

wx_client = WatsonXChatCompletionClient(**wx_config)

Define an agent using the watsonx client and register a dummy tool for querying weather

# Define a tool
async def get_weather(city: str) -> str:
    return f"The weather in {city} is 73 degrees and Sunny."


async def main() -> None:
    # Define an agent
    weather_agent = AssistantAgent(
        name="weather_agent",
        model_client=wx_client,
        tools=[get_weather],
    )

    # Define termination condition
    termination = TextMentionTermination("TERMINATE")

    # Define a team
    agent_team = RoundRobinGroupChat([weather_agent], termination_condition=termination)

    # Run the team and stream messages to the console
    stream = agent_team.run_stream(task="What is the weather in New York?")
    await Console(stream)


# NOTE: if running this inside a Python script you'll need to use asyncio.run(main()).
await main()

Refer to here for more detailed examples.

Metadata

Release files for autogen-watsonx-client 0.0.4

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

Source distribution (sdist)

Source distribution for autogen-watsonx-client 0.0.4
File Size Uploaded Provenance Actions
autogen_watsonx_client-0.0.4.tar.gz 6.3 kB Without provenance Details for autogen_watsonx_client-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for autogen-watsonx-client 0.0.4
File Interpreter ABI Platform Actions
autogen_watsonx_client-0.0.4-py3-none-any.whl Python 3 none any Details for autogen_watsonx_client-0.0.4-py3-none-any.whl

Total release size: 13.9 kB

Release files / autogen_watsonx_client-0.0.4.tar.gz

Download URL autogen_watsonx_client-0.0.4.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a67530e42a6ccf79bf75f11e05e0d5e525709e17e2930c106c21c93666cc37b6
BLAKE2b-256 checksum
How to use checksums
6d12242faa55e3aaa72fe18034354592782b1b6b2634b3fc5dc3cfd9ce6a2f34
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Release files / autogen_watsonx_client-0.0.4-py3-none-any.whl

Download URL autogen_watsonx_client-0.0.4-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
652a146be07e1f354620317dab70c6ac529adaf2a14b384a987e5ae89ce3be44
BLAKE2b-256 checksum
How to use checksums
f9dc3f9b628f5bf959e4596c4b4eafcf8d306935879936ed2762a8fee51574af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Security for autogen-watsonx-client 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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