Skip to main content

A Python utils SDK for xpander.ai services.

Project description

xpander_utils Package Development Guide

Overview

xpander_utils is a Python utilities SDK for xpander.ai services.
It provides adapters, helpers, and utilities to integrate and enhance the development of AI agents, workflows, and more.


Installation

Install from PyPI

To use the xpander_utils package in your project, install it via pip:

pip install xpander-utils

Install Locally (Development Mode)

If you want to contribute or modify the package, clone the repository and install it locally in editable mode:

pip install -e .

This allows you to make changes to the source code without reinstalling the package after each modification.


Usage Example

Here's a simple example using SmolAgentsAdapter to bridge between xpander.ai and smolagents:

from smolagents import OpenAIServerModel, ToolCallingAgent
from xpander_utils.sdk.adapters import SmolAgentsAdapter

# API keys
llm_api_key = "{YOUR_LLM_KEY}"
xpander_api_key = "{YOUR_API_KEY}"

# Initialize Xpander agent
xpander = SmolAgentsAdapter(agent_id="{YOUR_AGENT_ID}", api_key=xpander_api_key)

# Initialize model
model = OpenAIServerModel(
    model_id="gpt-4o",
    api_key=llm_api_key
)

# Add a task to Xpander 
prompt = "get the longest tag"
xpander.add_task(input=prompt)

# Build the agent using Xpander's tools
agent = ToolCallingAgent(
    step_callbacks=[xpander.step_callback()],
    tools=xpander.get_tools(),
    model=model,
    prompt_templates={"system_prompt": xpander.get_system_prompt()}
)

# Initialize memory from Xpander
xpander.init_memory(agent=agent)

# Run the agent
result = agent.run(task=prompt, reset=False)

Dependencies

The package requires the following libraries:

  • pydantic
  • loguru
  • xpander-sdk
  • httpx
  • httpx_sse

Optional / Extras

Additional functionality can be installed with extras:

Extra Libraries Installed
smolagents smolagents
llama-index llama_index
chainlit chainlit
agno agno

Example to install with extras:

pip install "xpander-utils[smolagents]"

You can combine extras:

pip install "xpander-utils[smolagents,llama-index,agno]"

AgnoAdapter Example

Here's an example using AgnoAdapter to integrate xpander.ai with agno:

import asyncio
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from xpander_utils.sdk.adapters import AgnoAdapter

async def main():
    # Initialize AgnoAdapter
    adapter = AgnoAdapter(
        agent_id="{YOUR_AGENT_ID}",
        api_key="{YOUR_XPANDER_API_KEY}"
    )
    
    # Add task to xpander
    adapter.add_task(input="Send a welcome email")
    
    # Get tools and create agno agent
    tools = adapter.get_tools()
    agent = Agent(
        model=OpenAIChat(id="gpt-4o-mini", api_key="{YOUR_OPENAI_API_KEY}"),
        tools=tools,
        instructions=adapter.get_system_prompt(),
        add_history_to_messages=True,
        markdown=True
    )
    
    # Run the agent
    response = await agent.arun("Send an email with subject 'Hello' to user@example.com")
    print(response.content)

# Run the async function
asyncio.run(main())

Supported Python Versions

This package officially supports Python >= 3.12.7.

Ensure you are using a compatible Python version for full functionality.


License

This project is licensed under the MIT License.


Development Notes

  • Source code is located under the src/ directory.
  • Package discovery is handled via find_packages(where="src").
  • long_description for the package is directly pulled from README.md.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

xpander_utils-0.0.124.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

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

xpander_utils-0.0.124-py3-none-any.whl (31.8 kB view details)

Uploaded Python 3

File details

Details for the file xpander_utils-0.0.124.tar.gz.

File metadata

  • Download URL: xpander_utils-0.0.124.tar.gz
  • Upload date:
  • Size: 27.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for xpander_utils-0.0.124.tar.gz
Algorithm Hash digest
SHA256 e9fc680c55ec7999a355e2146a552265201292fdd2933d82ee73252492b3ff23
MD5 37a5dfe8fc1e55377c5a1780acafc654
BLAKE2b-256 7babbffd927893788afd9614aaec720d585ea47c766825bb5d4c7cdc58d9c964

See more details on using hashes here.

File details

Details for the file xpander_utils-0.0.124-py3-none-any.whl.

File metadata

File hashes

Hashes for xpander_utils-0.0.124-py3-none-any.whl
Algorithm Hash digest
SHA256 a7c7bbe2df000a6a42da8ee7195f80ee0bc6420718c6069916025ac4f39f235e
MD5 bff3c9c8ba3045c129bf47c6f6ac2e59
BLAKE2b-256 10a4a9324a4e5a72c1a9a476fff19296d29b3c8ba2eca23e3742a6a3bb50d561

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