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.
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]"
Copy config-example.yaml
to config.yaml
and customize it according to your needs.
cp config-example.yaml config.yaml
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
To run the CLI client application:
python -m app.cli_interface
Once the API service is running, you can access the interactive API documentation at:
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
The chat module allows you to interact with the assistant:
> Hi, my name is Jeff.
Agent: Hello, Jeff! How can I assist you today?
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
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}, ...]
If the search_module
dependencies are installed, you can perform searches using the search:
command:
> search: how to mow the lawn
Search Results: {results}
If the wiki_summary_module
dependencies are installed, you can summarize Wikipedia content using the wiki:
command:
> wiki: Synthetic diamond
Summary: {summary}
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}
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}
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}
You can build and run the application using Docker. For detailed instructions, see DOCKER.md.
To check if the API service is running, use the health check endpoint:
curl -X GET "http://127.0.0.1:8000/"
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"
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"
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"
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)"
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"
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"
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."
Logs are stored in the logs
directory. You can check the logs for detailed information about the application's behavior and any issues encountered.
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.
This project is licensed under the MIT License - see the LICENSE file for details.