Skip to content

Latest commit

 

History

History
245 lines (155 loc) · 6.36 KB

README.md

File metadata and controls

245 lines (155 loc) · 6.36 KB

srt-agent-api

GitHub Release Python Version from PEP 621 TOML GitHub License

Overview

srt-agent-api is a modular application that provides chat functionality using the llama-cpp-agent framework and various other features like API fetching and Wikipedia summaries.

Installation

To install the necessary dependencies, run the following command:

pip install .

To include optional dependencies for the vllm_provider:

pip install ".[vllm_provider]"

To include optional dependencies for the search_module:

pip install ".[search_tool]"

To include optional dependencies for the wiki_summary_module:

pip install ".[wiki_summary_module]"

To include optional dependencies for the wikipedia_query_module:

pip install ".[wikipedia_query_module]"

Configuration

Copy config-example.yaml to config.yaml and customize it according to your needs.

cp config-example.yaml config.yaml

Usage

To start the API service:

export PERSONA='Default'       # Persona for the 'chat_module'.
export PORT=8000               # TCP port for the API service
export SERVER_NAME='127.0.0.1' # IP to use, or for all IPs: '0.0.0.0'

python -m app.api_service

Running the Application

To run the CLI client application:

python -m app.cli_interface

API Documentation

Once the API service is running, you can access the interactive API documentation at:

Chat Module

The chat module allows you to interact with the assistant:

> Hi, my name is Jeff.
Agent: Hello, Jeff! How can I assist you today?

Function Calling in Chat Module

The chat module now supports function calling. You can ask the assistant to perform various tasks such as fetching data, providing Wikipedia summaries, querying Wikipedia, performing calculations, and getting the current datetime.

> What is the current date and time?
Agent: Current datetime is 2023-11-24 15:42:35

> fetch: https://jsonplaceholder.typicode.com/posts/1
Fetched Data: {data}

> wiki: Synthetic diamond
Summary: {summary}

> wikipedia_query: Synthetic_diamond, What is a BARS apparatus?
Summary: {summary}

> What is 42 * 42?
Agent: 1764

API Module

You can fetch data from an API using the fetch: command:

> fetch: https://jsonplaceholder.typicode.com/posts/1
Fetched Data: {data}

> fetch_list: https://jsonplaceholder.typicode.com/posts
Fetched Data List: [{data1}, {data2}, ...]

Search Module

If the search_module dependencies are installed, you can perform searches using the search: command:

> search: how to mow the lawn
Search Results: {results}

Wiki Summary Module

If the wiki_summary_module dependencies are installed, you can summarize Wikipedia content using the wiki: command:

> wiki: Synthetic diamond
Summary: {summary}

Wikipedia Query Module

If the wikipedia_query_module dependencies are installed, you can query Wikipedia content using the wikipedia_query: command:

> wikipedia_query: Synthetic_diamond, What is a BARS apparatus?
Summary: {summary}

Product Comparison Module

If the product_comparison_module dependencies are installed, you can compare products and get recommendations using the compare: command:

> compare: iPhone 13, Samsung Galaxy S22, Smartphones, a professional photographer
Product Comparison Result: {result}

Agentic Reflection Module

If the agentic_reflection_module dependencies are installed, you can get reflective responses using the reflect: command:

> reflect: Write a summary about the independence war of America against England.
Reflective Response: {response}

Dockerization

You can build and run the application using Docker. For detailed instructions, see DOCKER.md.

API Endpoints

Health Check

To check if the API service is running, use the health check endpoint:

curl -X GET "http://127.0.0.1:8000/"

Fetch Data

To fetch data from a URL, use the fetch endpoint:

curl -X GET "http://127.0.0.1:8000/fetch?url=https://jsonplaceholder.typicode.com/posts/1"

Fetch Data List

To fetch a list of data from a URL, use the fetch list endpoint:

curl -X GET "http://127.0.0.1:8000/fetch-list?url=https://jsonplaceholder.typicode.com/posts"

Web Search

To get a summary of a Web Search, use the web search endpoint:

curl -X GET "http://127.0.0.1:8000/search?query=how%20to%20search%20the%20web"

Wiki Summary

To get a summary of a Wikipedia page, use the wiki summary endpoint:

curl -X GET "http://127.0.0.1:8000/wiki-summary/Python_(programming_language)"

Wikipedia Query

To query a Wikipedia page, use the wikipedia query endpoint:

curl -X GET "http://127.0.0.1:8000/wikipedia-query?page_url=Synthetic_diamond&query=What%20is%20a%20BARS%20apparatus%3F"

API Endpoint for Product Comparison

To compare products and get a recommendation, use the product comparison endpoint:

curl -X GET "http://127.0.0.1:8000/product-comparison?product1=iPhone%2013&product2=Samsung%20Galaxy%20S22&category=Smartphones&user_profile=a%20professional%20photographer"

Get Reflective Response

To get a reflective response, use the following endpoint:

curl -X POST "http://127.0.0.1:8000/reflective-response" -d "input_message=Write a summary about the independence war of America against England."

Logging

Logs are stored in the logs directory. You can check the logs for detailed information about the application's behavior and any issues encountered.

Contributing

Feel free to open issues or submit pull requests on the GitHub repository.

For detailed information on running tests and the CI workflow, see the Workflow Documentation.

License

This project is licensed under the MIT License - see the LICENSE file for details.