Giter Club home page Giter Club logo

syncom's Introduction

Syncom Library

Syncom is a Python library designed to assist in the creation and execution of pipelines for AI models. It provides a set of classes and functions to define steps in a pipeline, create a pipeline, and run it.

Features

  • Pipeline Creation: Define a sequence of steps to be executed in a pipeline.
  • Step Definition: Define individual steps in a pipeline, such as data input, logging, and AI model execution.
  • Pipeline Execution: Run a defined pipeline and get the result.

Requirements

  • Python 3.7 or later
  • pydantic
  • litellm
  • instructor

Usage

To use this library, you need to define the steps of your pipeline, create the pipeline, and then run it. Here's a basic usage example:

import asyncio
from pydantic import Field
from syncom import (
    TypedTemplate,
    TemplatePromptStep,
    LLMStep,
    RunnableConfig,
    run_pipeline,
    make_pipeline
)

class PingTemplate(TypedTemplate):
    template_string = """
    # Instructions
    Respond to the user command listed below using the following rules.
    When the user command is "ping", respond with "pong".
    When the user command is "pong", respond with "ping".
    
    # User Command
    {{ command }}
    """
    command: str = Field(enum=["ping", "pong"])

    
class PongResult(BaseModel):
    command: str = Field(
        description="Response command from AI" 
        enum=["ping", "pong"]
    )

# Define the steps
steps = (
    TemplatePromptStep(PingTemplate),
    LogStep("Ping Template"),
    LLMStep(model, PongResult)
)

# Create the pipeline
pipeline = make_pipeline(RunnableConfig(), *steps)

# Run the pipeline
async def main(self):
    global pipeline
    input_data = {"command": "ping"}
    output: PongResult = await run_pipeline(pipeline, input_data)
    print(f"Output Command: {output.command}")

if __name__ == "__main__":
    asyncio.run(main())

This will create a pipeline that generates a prompt from a template and then runs the prompt against GPT-4 resulting in a typed PongResult response.

Contributing

Contributions are welcome. Please open an issue to discuss your ideas or submit a Pull Request with your changes.

License

MIT

syncom's People

Contributors

shakakai avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.