Skip to main content

A wrapper on top of OpenAI chat completion and assistant API. It handles `tool_call`, `file_search` within the class.

Project description

MinAgent

Agent is a wrapper on top of OpenAI chat completion and assistant API. It handles tool_call, file_search within the class

Features

Implemented

  • Chat Completion API
  • Assistant API

And tools

  • Function call (Parallel execution)
  • File search

Usage

pip install minagent

Create an Agent

from openai import OpenAI
from minagent import Agent

openai_client = OpenAI(
    api_key="00000"
)

def current_utc_datetime(**args) -> str:
    from datetime import datetime, timezone
    return datetime.now(timezone.utc).isoformat()

clock = Agent(
    openai_client,
    name='clock',
    model='gpt-4o',
    instructions=['You are a time aware assistant.',],

    # optional: only add below if using assistant api
    openai_asst_id='asst_0000'

    # optional: tool for file_search, and function
    tools=[
        {
            'type': 'file_search',
        }, {
            'type': 'function',
            'function': {"name": 'current_utc_datetime'},
        },
    ],
    tool_functions={'current_utc_datetime': current_utc_datetime},
    tool_resources={'file_search': {'vector_store_ids': ['vs_0000']}},
)

Use of Chat completion API

response = clock.chat_completion(
    user='john',
    messages=[
        { 'role': 'user', 'content': 'what time is it now?' },
    ],
)

Use of Assistant API

thread = openai_client.beta.threads.create()
response = clock.ask_assistant(
    user='john',
    asst_thread_id=thread.id,
    message=[
        { 'role': 'user', 'content': 'what time is it now?' },
    ]
)

Future

  • Support for Response API
  • Add test cases
  • Release pipeline

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

minagent-0.1.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

minagent-0.1.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file minagent-0.1.1.tar.gz.

File metadata

  • Download URL: minagent-0.1.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for minagent-0.1.1.tar.gz
Algorithm Hash digest
SHA256 63ee42519f3d08d92f57175badcbb3970a5c34eea03bfbb50ade4974a1cceda9
MD5 cd380eb4cae8443f2bd95879c707e3bf
BLAKE2b-256 d084feeb053494ce6204ef8a572969c4b9cf9f07563b8c167e7b1e73f002faf3

See more details on using hashes here.

File details

Details for the file minagent-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: minagent-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for minagent-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 87d5136a51a4b39e78ce584557429282414af2b686818183bfab254354079c9d
MD5 27788ca98fc9ed97ca6f24004fdfba64
BLAKE2b-256 fcc7f805a45098cf927849058cbcc71e38afbdd4289014e005a9d19cdab5502e

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