Skip to main content

Dynamic, highly customizable language agents framework

Project description

Operagents

Installation

Install the latest version with:

pip install operagents
# or use poetry
poetry add operagents
# or use pdm
pdm add operagents
# or use uv
uv pip install operagents

Usage

Start writing a config file

Create a config.yaml file with the following basic content:

# yaml-language-server: $schema=https://operagents.yyydl.top/schemas/config.schema.json

agents:
opening_scene: ""
scenes:

The first line is a comment that tells the YAML Language Server to use the schema from the specified URL. This will enable autocompletion and validation in your editor.
The schema is related to the version of the operagents framework you are using. The URL is in the format https://operagents.yyydl.top/schemas/config-<version>.schema.json, where <version> is the version of the framework, e.g. 0.0.1. If no version is specified, the latest (master) version will be used.

The Template config

Before writing the agent and scene configs, we need to learn about the template config.

Operagents uses templates to generate the context input for the language model. A template is a string in jinja format. You can use jinja2 syntax with provided context varaibles to control the input to the language model.

A template config can be in the following format:

  1. simple string template

    user_template: |-
      {# some jinja template #}
    
  2. template with custom functions

    user_template:
      content: |-
        {# some jinja template #}
      custom_functions:
        function_name: module_name:function_name
    

If you want to use custom functions in the template, you need to provide the custom_functions key, which is a dictionary of custom function names and their corresponding module paths in dot notation format.

The Agent config

The agents section is a dictionary of agents, where the key is the agent's name and the value is the agent's config.

Examples

Chatbot

cd examples/chatbot
env OPENAI_API_KEY=sk-xxx OPENAI_BASE_URL=https://api.openai.com/v1 operagents run config.yaml

Development

Open in Codespaces (Dev Container):

Open in GitHub Codespaces

Or install the development environment locally with:

poetry install && poetry run pre-commit install

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

operagents-0.0.4.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

operagents-0.0.4-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file operagents-0.0.4.tar.gz.

File metadata

  • Download URL: operagents-0.0.4.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for operagents-0.0.4.tar.gz
Algorithm Hash digest
SHA256 336dd25498b685b1cf88e0802d16f127aa75ef486e087bba2698a6a6afdaf87c
MD5 a5e0f77281c5822283f6c9861e47fcb9
BLAKE2b-256 b276eb4468f68ed1e9e71640a7db840c4deaf1edb6cb9b8269563bfbe702bb1f

See more details on using hashes here.

File details

Details for the file operagents-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: operagents-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for operagents-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ebfc09b75515aee29484190b639fd538c4f88d9ae24e58738280ce19e1162948
MD5 b042812a1198cf8ed5f11ac6a9c10ef4
BLAKE2b-256 a56a8c69709abd88281ecf60a422757b3f05efc921cf4c661bdcb87fce970a4a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page