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.5.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

operagents-0.0.5-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: operagents-0.0.5.tar.gz
  • Upload date:
  • Size: 15.2 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.5.tar.gz
Algorithm Hash digest
SHA256 7a4e8be2a00f72178a39cf8c03d9c55617b7d6834160206d89fd0b1c4bf122c1
MD5 46a647e5c360624c7e631fd3b99baddd
BLAKE2b-256 43e70daad5c05269bcb0a1c6c31807e81b022f6347b773aa4ef95af96cdc91e9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: operagents-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 24.1 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6be24b1a3e57655e9d8f28d1ab6c99927e9b128d993045e5e0adbc3a3357e657
MD5 36d13dc531bb00c9f6b625688ce7ee45
BLAKE2b-256 3a4a9e3177f6a89b783c67483fdf2ebfb6a38c1272d8c972e9b80e567d754b04

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