Skip to content

Model agnostic assistant/addon implementation for AI DIAL. It allows to use self-hosted OpenAI plugins as DIAL addons

License

Notifications You must be signed in to change notification settings

epam/ai-dial-assistant

Repository files navigation

Overview

The DIAL Assistant Service is designed to respond to user queries, like ChatGPT. It is accessible via DIAL API. The service’s distinctive feature is its ability to utilize addons provided in the user request, enhancing its capability to gather and process information.

Upon receiving a user request, the service employs the specified LLM to interpret and respond to the inquiry. Along with user request it instructs the model on how to apply the provided addons to garner additional information. If the model decides to use an addon to seek specific details, the Assistant Service promptly executes this task and channels the acquired data back to the model. This iterative procedure continues, with the model leveraging the addons to assemble more information until a thorough and informed response to the user’s query is generated.

In essence, the DIAL Assistant Service is a versatile tool that combines the power of a given model with the extended capabilities of various addons to deliver comprehensive and accurate answers.

Usage example

import os

import openai

if __name__ == "__main__":
    response = openai.ChatCompletion.create(
        api_base=os.environ["OPENAI_API_BASE"],
        api_type="azure",
        api_version="2023-03-15-preview",
        api_key=os.environ["OPENAI_API_KEY"],
        engine="assistant",
        model="gpt-4",
        temperature=0,
        timeout=300,
        messages=[
            {"role": "user", "content": "What's up?"},
        ],
        addons=[
            {
                "url": "https://<addon-host>/.well-known/ai-plugin.json"
            }
        ],
    )

    print(response)

Developer environment

This project uses Python>=3.11 and Poetry>=1.6.1 as a dependency manager.

Check out Poetry's documentation on how to install it on your system before proceeding.

To install requirements:

make install

This will install all requirements for running the package, linting, formatting and tests.

Make on Windows

As of now, Windows distributions do not include the make tool. To run make commands, the tool can be installed using the following command (since Windows 10):

winget install GnuWin32.Make

For convenience, the tool folder can be added to the PATH environment variable as C:\Program Files (x86)\GnuWin32\bin. The command definitions inside Makefile should be cross-platform to keep the development environment setup simple.

Run

Run the development server:

make serve

Environment Variables

Copy .env.example to .env and customize it for your environment:

Variable Default Description
CONFIG_DIR aidial_assistant/configs Configuration directory
LOG_LEVEL INFO Log level. Use DEBUG for dev purposes and INFO in prod
OPENAI_API_BASE OpenAI API Base
WEB_CONCURRENCY 1 Number of workers for the server
TOOLS_SUPPORTING_DEPLOYMENTS Comma-separated deployment names that support tools in chat completion request

Docker

Run the server in Docker:

make docker_serve

Lint

Run the linting before committing:

make lint

To auto-fix formatting issues run:

make format

Test

Run unit tests locally:

make test

Clean

To remove the virtual environment and build artifacts:

make clean

About

Model agnostic assistant/addon implementation for AI DIAL. It allows to use self-hosted OpenAI plugins as DIAL addons

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages