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

Create an Agent

from openai import OpenAI
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',
    sentences=['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.0.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.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: minagent-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 a1639f1c28c27ab12f7730bfd464cecc08a2c492238d7cefd9de6e77aff7f508
MD5 ac06a8501878e53dd3ec06934767ef23
BLAKE2b-256 397ec843b73bcf97d56c5ab9a4fbd85bc9bf4efe462e10c787d02f9b6c6752e1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: minagent-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a3ee11b94c505e3c76da03df353662d2b6aad4f57f9506f4182b0192d06f1371
MD5 b8bbaaaa8b90e911fee09372fba6cad1
BLAKE2b-256 8c4f9154ef6b8dd09fe80a05734e0fb7c36e2ed8f9c8a4202c8b7a6493219127

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