Skip to main content

A utilities library for Common AI Platform

Project description

do-cap-utils

A library to simplify your use case with chat bot with LLMs. Perfect for Common AI Platform.

Installation

uv add do-cap-utils

Usage

See example.py and example_multiagents.py.

General

from do_cap_utils.agent.base import BaseAgent
from do_cap_utils.agent.prebuilt import SummariserAgent
from do_cap_utils.tool import tool


# --------------------------------------------
# Create and run your own agent with some tool
# --------------------------------------------
@tool
def add_numbers(a: int, b: int):
    """Adds two numbers together"""
    return a + b


agent = BaseAgent(
    system_prompt="You are a helpful assistant that answers everything nicely (only that you can do or know)",
    tools=[add_numbers],
)
r = agent.chat_each_message("hello")
r = agent.chat_each_message("add two numbers for me")
r = agent.chat_each_message("2 and 4")
print(r)  # Inpect the output
print()

# You can use `chat_interact()` method to have an interactive session
agent.chat_interact()

Now, if you use self.chat_interact(), save the file and run this file in the command line.

uv run your_file.py

Or activate your python environment and run

python your_file.py

Example output:

================================ Human Message =================================

hello
================================== Ai Message ==================================

Hello! How can I assist you today?
================================ Human Message =================================

add two numbers for me
================================== Ai Message ==================================

Of course! Please provide the two numbers you'd like to add.
================================ Human Message =================================

2 and 4
================================== Ai Message ==================================
Tool Calls:
  add_numbers (call_kGDJ89gTwG6cTZFT7cWr1dBs)
 Call ID: call_kGDJ89gTwG6cTZFT7cWr1dBs
  Args:
    a: 2
    b: 4
================================= Tool Message =================================
Name: add_numbers

6
================================== Ai Message ==================================

The sum of 2 and 4 is 6.

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

do_cap_utils-0.2.1.tar.gz (93.6 kB view details)

Uploaded Source

Built Distribution

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

do_cap_utils-0.2.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file do_cap_utils-0.2.1.tar.gz.

File metadata

  • Download URL: do_cap_utils-0.2.1.tar.gz
  • Upload date:
  • Size: 93.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.11

File hashes

Hashes for do_cap_utils-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e9768609142d31939f6abdbc7f6ebd84e2acb36a4b01605b9521fc8a06224e58
MD5 677f4c88ad36cd1e50f7c59fffc81756
BLAKE2b-256 320a29d4f4e58ff5d8695bbee78f7f616f0988394ef33f3f34af9e8296efffd7

See more details on using hashes here.

File details

Details for the file do_cap_utils-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for do_cap_utils-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c3972ff67158c77bc6ef30ffa8677e3ce225d4c0908fa27e6e79eb4496b0833
MD5 ad52c810694def1b6169bf99b1889499
BLAKE2b-256 6eb2a594613bad4b63899dce2f32a9bc8fe37202eca80e90c48f2ab33a4884f4

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