Skip to main content

agentxai

A lightweight, but effective autonomous agent framework powered by X.AI's Grok model.

Features

  • AgentX: An autonomous agent that can execute complex missions using provided tools
    • tools: List of callable functions the agent can use to complete its mission
      • can be another agent, assuming the agent lives in a function
    • mission: String describing the goal or task to accomplish
    • exit_function: Optional callback function executed upon mission completion
      • default is a success bool
    • system_prompt: Customizable prompt to guide agent behavior (default: autonomous goal-focused agent)
    • model: AI model selection (default: "grok-beta")
    • enable_logging: Toggle detailed logging (default: False)
    • max_steps: Maximum execution steps before termination (default: 10)
  • XAI: A robust client for interacting with X.AI's Grok model and other supported AI models
  • Model Selection: Choose from three AI models to power your agents
    • grok-beta: X.AI's Grok model
    • gpt-4o: OpenAI's GPT-4 optimized for performance
    • gpt-4o-mini: A lightweight version of GPT-4 optimized for minimal resource usage
  • Cost tracking and token usage monitoring
  • Automatic retries and error handling
  • JSON response validation
  • Configurable logging

Model Selection

AgentXAI supports three AI models, each with different capabilities and cost structures. You can select the desired model when initializing AgentX or XAI.

Available Models

  1. grok-beta

    • Provider: X.AI
    • Cost:
      • Input Tokens: $5.00 per 1M tokens
      • Output Tokens: $15.00 per 1M tokens
  2. gpt-4o

    • Provider: OpenAI
    • Cost:
      • Input Tokens: $2.50 per 1M tokens
      • Output Tokens: $10.00 per 1M tokens
  3. gpt-4o-mini

    • Provider: OpenAI
    • Cost:
      • Input Tokens: $0.150 per 1M tokens
      • Output Tokens: $0.600 per 1M tokens

Selecting a Model

When initializing AgentX or XAI, specify the model parameter to select the desired AI model.

Example: Initializing AgentX with gpt-4o-mini

example agent:

from agentX.agent_x import AgentX

def my_function(input: str) -> str:
    """
    A simple example function that can be passed to AgentX as a tool.

    Args:
        input (str): The input string to process

    Returns:
        str: The unmodified input string
    """
    # do something with input
    return input

def exit_function(message: str) -> int:
    """
    A simple example exit function that can be passed to AgentX.

    Args:
        message (str): A string containing a number to convert

    Returns:
        int: The string converted to an integer
    """
    try:
        return int(message)
    except ValueError:
        return -1

agent = AgentX(
    model="grok-beta",
    tools=[my_function],
    mission="""
    Do something with

    #1 setup
     - some useful details
    #2 do something
    - some details
    #3 last thing to do
    - some details

    success criteria:
      -  that something is done
      -  it is done well
    """,
    exit_function=exit_function,
)

Installation

pip install agentxai

ENV Variables

XAI_API_KEY=

Release files for agentxai 0.1.5

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

Source distribution (sdist)

Source distribution for agentxai 0.1.5
File Size Uploaded
agentxai-0.1.5.tar.gz 10.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentxai 0.1.5
File Interpreter ABI Platform
agentxai-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 20.9 kB

Release files / agentxai-0.1.5.tar.gz

Download URL agentxai-0.1.5.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
54f758281501742f370484063288136674619ecf5581bba8c4726f09bdcdc2cf
BLAKE2b-256 checksum
How to use checksums
b199afe64e15e4ca5dc8d57b13cf08d2d15e6b0016ed2c2cd32eee0fb3324cdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2024.

Transparency log

Release files / agentxai-0.1.5-py3-none-any.whl

Download URL agentxai-0.1.5-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
888af19e23a97ad2721bde31fb81158aeffd49787f0f49d620fa79da79793d9d
BLAKE2b-256 checksum
How to use checksums
0cb3edcfc877e8e87eff0dd26de10f0208895a5619cd63a3307ac69da8a69316
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 26, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.3

2 release files

0.1.0

2 release files

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