Skip to main content

Bridgic is a project that enables developers to develop agents/workflows in a more natural and flexible way, consisting of several Python packages.

Project description

Bridgic is an innovative programming framework designed to create agentic systems, from simple workflows to fully autonomous agents. Its APIs are thoughtfully crafted to be both simple and powerful.

Core Features

  • Orchestration: Bridgic helps to manage the control flow of your AI applications asynchronously.
  • Dynamic Control Flow: Bridgic supports dynamic routing based on input data, and even allows workers to be added or removed at runtime.
  • Modularity: In Bridgic, a complex agentic system can be composed by reusing components through hierarchical nesting.
  • Human-in-the-Loop: A workflow or an agent built with Bridgic can request feedback from humans whenever needed.
  • Serialization: Bridgic includes serialization, deserialization, and resuming capabilities to support human-in-the-loop.
  • Parameter Binding: There are three ways to pass data among workers, including Arguments Mapping, Arguments Injection, and Inputs Propagation.
  • Systematic Integration: A wide range of tools and LLMs can be seamlessly integrated into the Bridgic world, in a systematic way.
  • Customization: What Bridgic provides is not a "black box" approach. You have full control over every aspect of your AI applications, such as prompts, context windows, the control flow, and more.

Install Bridgic

Python version 3.9 or higher is required.

pip install bridgic

Example Code

Initialize the running environment for LLM:

import os
from bridgic.llms.openai.openai_llm import OpenAILlm, OpenAIConfiguration

_api_key = os.environ.get("OPENAI_API_KEY")
_model_name = os.environ.get("OPENAI_MODEL_NAME")

llm = OpenAILlm(
    api_key=_api_key,
    configuration=OpenAIConfiguration(model=_model_name),
)

Then, create a word learning assistant with code:

from bridgic.core.automa import GraphAutoma, worker
from bridgic.core.model.types import Message, Role

class WordLearningAssistant(GraphAutoma):
    @worker(is_start=True)
    async def generate_derivatives(self, word: str):
        response = await llm.achat(
            model=_model_name,
            messages=[
                Message.from_text(text="You are a word learning assistant. Generate derivatives of the input word in a list.", role=Role.SYSTEM),
                Message.from_text(text=word, role=Role.USER),
            ]
        )
        return response.message.content

    @worker(dependencies=["generate_derivatives"], is_output=True)
    async def make_sentences(self, derivatives):
        response = await llm.achat(
            model=_model_name,
            messages=[
                Message.from_text(text="You are a word learning assistant. Make sentences with the input derivatives in a list.", role=Role.SYSTEM),
                Message.from_text(text=derivatives, role=Role.USER),
            ]
        )
        return response.message.content

Let's run it:

word_learning_assistant = WordLearningAssistant()
res = await word_learning_assistant.arun(word="happy")
print(res)

For more information and examples, see the Tutorials.

Understanding

See Understanding Bridgic.

License

This repo is available under the MIT license.

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

bridgic-0.1.0rc1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

bridgic-0.1.0rc1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file bridgic-0.1.0rc1.tar.gz.

File metadata

  • Download URL: bridgic-0.1.0rc1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for bridgic-0.1.0rc1.tar.gz
Algorithm Hash digest
SHA256 6a846f0773d8b7eae302b14b52e64339553b1965aeb05fb174bd553840293442
MD5 660003eabb55d2a6db5b9867813bd31c
BLAKE2b-256 c20ca4bde7a9bc59ab9254debd0f8757c31cf3f141401521b1651e108399fc1f

See more details on using hashes here.

File details

Details for the file bridgic-0.1.0rc1-py3-none-any.whl.

File metadata

File hashes

Hashes for bridgic-0.1.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 b131556d22276b1c8e420faa744dfe737def8e9587f02ac1b78e57dbf04f259f
MD5 2ef9f1af8ea3149d784c53512b167b9b
BLAKE2b-256 87082f9d7560b640f8960f5baa12cdc61111df6e46b748c490b3f02151d23a44

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