Skip to main content

A flexible AI agent library with tool support

Project description

Fury Logo

Fury

Discord

A flexible and powerful AI agent library for Python, designed to build agents with tool support, multimodal capabilities, and streaming responses.

Features

  • Easy-to-use Agent API: Simple interface to create agents with custom system prompts and models.
  • Tool Support: Define and register custom tools (functions) that the agent can execute.
  • Parallel Tool Execution: Built-in support for running multiple independent tools in parallel.
  • Multimodal Capabilities: Support for image and voice inputs (using Whisper for STT).
  • Streaming Responses: Real-time streaming of agent responses and reasoning.
  • OpenAI Compatible: Built on top of AsyncOpenAI, making it compatible with OpenAI models and local inference servers (like vLLM, Ollama, etc.).

Installation

Install directly from github using:

uv add git+https://github.com/huwprosser/fury.git

Pip equivalents:

pip install git+https://github.com/huwprosser/fury.git

If you also want example dependencies:

uv add "git+https://github.com/huwprosser/fury.git[examples]"

Pip equivalent for examples:

pip install "git+https://github.com/huwprosser/fury.git[examples]"

For local development in this repository:

uv sync --all-extras

Quick Start

Most basic usage:

from fury import Agent

agent = Agent(
    model="your-model-name",  # e.g., "gpt-4o" or a local model
    system_prompt="You are a helpful assistant.",
    base_url="http://127.0.0.1:8080/v1",  # or https://openrouter.ai/api/v1, https://api.openai.com/v1
    api_key="your-api-key",
)

response = agent.ask("Hello!", history=[])
print(response)

Here is a simple example of how to create a chat agent:

import asyncio
from fury import Agent

async def main():
    # Initialize the agent
    agent = Agent(
        model="your-model-name", # e.g., "gpt-4o" or a local model
        system_prompt="You are a helpful assistant.",
        base_url="http://127.0.0.1:8080/v1", # or https://openrouter.ai/api/v1, https://api.openai.com/v1
        api_key="your-api-key"
    )

    history = []

    # Simple chat loop
    while True:
        user_input = input("> ")
        history.append({"role": "user", "content": user_input})

        async for event in agent.chat(history):
            if event.content:
                print(event.content, end="", flush=True)

        print()

if __name__ == "__main__":
    asyncio.run(main())

Configuration Options

agent = Agent(
    model="your-model-name",
    system_prompt="You are a helpful assistant.",
    parallel_tool_calls=False,
    generation_params={
        "temperature": 0.2,
        "max_tokens": 512,
    },
)

# Disable reasoning stream content (default is False)
async for event in agent.chat(history, reasoning=False):
    ...

# Or for single-shot calls
response = agent.ask("Hello!", history=[], reasoning=False)

Advanced Usage

Defining Tools

You can give your agent tools to interact with the world. Tools are defined using the create_tool helper.

Input and output schemas help the model to correctly pass parameters through to the function. Fury will automatically prune any hallucinated parameters not defined in the input schema.

Learn more in the OpenAI guide

from fury import Agent, create_tool

# Define the function
def add(a: int, b: int):
    return {"result": a + b}

# Create the tool
add_tool = create_tool(
    id="add",
    description="Add two numbers together",
    execute=add,
    announcement_phrase="Adding numbers...",
    input_schema={
        "type": "object",
        "properties": {
            "a": {"type": "integer"},
            "b": {"type": "integer"},
        },
        "required": ["a", "b"],
    },
    output_schema={
        "type": "object",
        "properties": {"result": {"type": "integer"}},
        "required": ["result"],
    },
)

# Pass to agent
agent = Agent(..., tools=[add_tool])

Coding Assistant Example

Check out examples/coding-assistant/coding_assistant.py for a full-featured example that includes:

  • File system operations (read, write, edit, bash).
  • Skills System: Loading specialized capabilities from SKILL.md files.
  • Memory System: Using MEMORY.md and SOUL.md for context.
  • History Compaction: Summarizing long conversations to save context window.

Running Examples

To run the provided examples, ensure you have the package installed.

Basic Chat:

uv run examples/chat.py

Coding Assistant (Based on Pi.dev):

uv run examples/coding-assistant/coding_assistant.py

Project Structure

  • src/agent_lib/: Core library code.
    • agent.py: Main Agent class and logic.
  • examples/: Usage examples.
    • chat.py: Basic chat loop.
    • coding-assistant/: Advanced agent with file ops and memory.

Run Tests

To run the pytest tests you will first need to install the additional test deps. uv sync --extra test

Then run: uv run pytest -v

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

fury_sdk-0.0.3.tar.gz (562.3 kB view details)

Uploaded Source

Built Distribution

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

fury_sdk-0.0.3-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file fury_sdk-0.0.3.tar.gz.

File metadata

  • Download URL: fury_sdk-0.0.3.tar.gz
  • Upload date:
  • Size: 562.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for fury_sdk-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d69ff8b3f92ae94b13149cdd530ed0db9e8b68bb3057a69c00477a33c4c50aa8
MD5 c045d02659cbd54e0404ed91c627155b
BLAKE2b-256 289326f1b6bfd7aff81cbfbdb34342719349f15243565b1f7fa03279517e3ff1

See more details on using hashes here.

File details

Details for the file fury_sdk-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: fury_sdk-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.5

File hashes

Hashes for fury_sdk-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e67676d8541bbd538b8f07d97b015320fbebb29e90fb12f14b8c426a3bdd0ef4
MD5 926537cbf4e0958a104fbe49e63bc4a3
BLAKE2b-256 e4c0d8d8699a45fdb62e8b5ba69488c95f3978d4a747219287eeb18f2caee9a8

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