runtime

module
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2025 License: Apache-2.0

README

contenox/runtime: genAI orchestration runtime

Go License

contenox/runtime is a genAI orchestration runtime that enables developers to build, manage, and execute complex LLM (Large Language Model) workflows with ease. It provides a unified interface for interacting with multiple AI providers, and creating multi-task prompt engineering pipelines.

Overview

contenox/runtime is designed as the backbone for AI-powered applications, offering:

  • Multi-provider support for OpenAI, Gemini, Ollama, and custom backends
  • State-machine as engine with conditional branching and state management
  • Resource pooling for efficient allocation of AI resources
  • Extensible hook system for integrating with external services
  • SDK for seamless integration into applications

Key Features

State-machine as Engine
  • Chain multiple LLM operations together with conditional transitions
  • 10+ built-in task handlers (parse_number, parse_range, condition_key, etc.)
  • Dynamic routing based on LLM outputs
  • Support for complex input types (chat history, search results, etc.)
// Example state-machine configuration
chain := &taskengine.ChainDefinition{
    ID: "sentiment-analysis",
    Tasks: []taskengine.ChainTask{
        {
            ID:      "classify",
            Handler: taskengine.HandleConditionKey,
            ValidConditions: map[string]bool{"positive": true, "negative": true, "neutral": true},
            PromptTemplate: "Analyze sentiment of: {{.input}}. Respond with positive, negative, or neutral.",
            Transition: taskengine.TaskTransition{
                Branches: []taskengine.TransitionBranch{
                    {Operator: taskengine.OpEquals, When: "positive", Goto: "positive_response"},
                    {Operator: taskengine.OpEquals, When: "negative", Goto: "negative_response"},
                    {Operator: taskengine.OpDefault, Goto: "neutral_response"},
                },
            },
        },
        // Additional tasks...
    },
}
Resource Management
  • Backend Management: Connect to multiple AI providers (Ollama, OpenAI, Gemini)
  • Model Management: Download, store, and manage LLM models
  • Resource Pooling: Group resources by purpose (inference, embedding, etc.)
  • Backend-Model Associations: Assign specific models to specific backends
Extensible Architecture
  • Custom Hooks: Extend functionality with remote HTTP hooks
  • Provider API: Configure cloud providers (OpenAI, Gemini) securely
  • Download Queue: Manage model download operations with progress tracking
SDK
  • Implement the same interfaces as internal services
  • Seamlessly replace local service with HTTP client
  • Consistent error handling across all services
  • Full type compatibility with internal models

Getting Started

TODO:

Directories

Path Synopsis
cmd
runtime-api command
Package llmresolver selects the most appropriate backend LLM instance based on requirements.
Package llmresolver selects the most appropriate backend LLM instance based on requirements.
runtimestate implements the core logic for reconciling the declared state of LLM backends (from dbInstance) with their actual observed state.
runtimestate implements the core logic for reconciling the declared state of LLM backends (from dbInstance) with their actual observed state.
Package taskengine provides an engine for orchestrating chains of LLM-based tasks.
Package taskengine provides an engine for orchestrating chains of LLM-based tasks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL