Purpose
The llama-cpp-agent framework is designed to simplify interaction with large language models (LLMs). It provides interfaces for chat, executing function calls, generating structured output, performing retrieval-augmented generation (RAG), and processing text using agent chains with tools.
Main Capabilities
- Simple chat interface: Conduct conversations with an LLM.
- Structured output: Generate structured output (objects) from an LLM.
- Single and parallel function calling: Execute functions using an LLM, with support for parallel calls.
- RAG (retrieval-augmented generation): Perform retrieval-augmented generation, with support for colbert reranking.
- Agent chains: Process text using agent chains with tools, supporting Conversational, Sequential, and Mapping chains.
- Guided sampling: Implement guided sampling with the help of grammars and JSON schema generation, enabling most 7B LLMs to perform function calling and structured output.
- Multiple providers: Support llama-cpp-python, llama.cpp server, TGI server, and vllm server as providers.
- Compatibility: Compatible with Python functions, pydantic tools, llama-index tools, and OpenAI tool schema.
Usage
Install using pip:pip install llama-cpp-agent. To use the RAGColbertReranker class and RAG examples, you need to install the optional rag dependency:pip install llama-cpp-agent[rag]. The repository provides documentation and a getting started guide, and includes multiple examples, such as simple chat using the llama.cpp server backend, parallel function calling, structured output, RAG with colbert reranking, llama-index tools, Sequential chains, Mapping chains, and knowledge graph creation.
The framework provides predefined message formatters. The MessagesFormatterType enum includes: MISTRAL, CHATML, VICUNA, LLAMA_2, SYNTHIA, NEURAL_CHAT, SOLAR, OPEN_CHAT, ALPACA, CODE_DS, B22, LLAMA_3, PHI_3, AUTOCODER, DEEP_SEEK_CODER_2. Custom formatters can also be created by instantiating the MessagesFormatter class and passing in the required parameters.
Applicable Scenarios
Suitable for a variety of applications ranging from everyday chat to specific function execution, such as generating book dataset entries from unstructured data, creating a complete product launch campaign using Sequential chains, summarizing multiple articles into a single summary using Mapping chains, and creating knowledge graphs.
Limitations
The repository page shows: Not Longer Maintained. Use instead ToolAgents or other Python agentic frameworks. (No longer maintained, please switch to ToolAgents or other Python agent frameworks.)
Other Information
The project uses the MIT License. Contributions are welcome. The contribution process is: create a branch from master, ensure the code conforms to the project's code style and conventions, write clear and concise commit messages and pull request descriptions, test thoroughly before submitting, and open a pull request to the master branch. If you encounter issues or have suggestions for improvement, you can submit an issue in the GitHub repository.