VersaLLM
VersaLLM is a versatile language model client that supports multiple backend models including OpenAI, Anthropic, and Groq. It provides a unified interface for interacting with these models and includes tools for executing functions based on user prompts.
Features
- Versatile Multi-Backend Compatibility: Effortlessly transition between leading language models like OpenAI, Anthropic, and Groq, using a unified interface that simplifies integration and operation.
- Robust Conversational Memory: Automatically track and manage conversation history, ensuring seamless dialogue flow and context retention without the need for manual oversight.
- Consistent Tool Integration: Simplify the incorporation of external tools with a uniform interface across different language models, allowing for smooth and consistent functionality regardless of the backend.
- Error Handling and Logging: Robust error handling and logging for better debugging and monitoring.
Installation
-
Clone the repository:
git clone https://github.com/Mohwit/versallm cd versallm
-
Install the required dependencies:
pip install -r requirements.txt
Usage
Simple Usage
You can initialize a client for any supported model. For example, to initialize an 'claude-3-opus-20240229' of anthropic, you can use the following code:
## import the VersaLLM class
from versallm import VersaLLM
## create a llm client
client = VersaLLM(model="claude-3-opus-20240229", api_key="your_api_key")
## set your system prompt
client.system_message("your system message")
## use completion method to get the response
response = client.completion("your prompt")
print(response)
Using Function calling
Defining Tools
Simply define your function and define the tools schema as shown below:
def get_customer_info(customer_id):
# Your implementation here
pass
def get_order_details(order_id):
# Your implementation here
pass
def cancel_order(order_id):
# Your implementation here
pass
tools = [
{
"type": "function",
"function": {
"name": "get_customer_info",
"description": "your description",
"parameters": {
"type": "object",
"properties": {
"customer_id": {
"type": "string",
"description": "your description"
}
},
"required": ["customer_id"]
}
}
},
{
"type": "function",
"function": {
"name": "get_order_details",
"description": "your description",
"parameters": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "your description"
}
},
"required": ["order_id"]
}
}
},
{
"type": "function",
"function": {
"name": "cancel_order",
"description": "your description",
"parameters": {
"type": "object",
"properties": {
"order_id": {
"type": "string",
"description": "your description"
}
},
"required": ["order_id"]
}
}
}
]
Initialize the client, and pass the list of functions to the during client initialization and pass tools schema to the completion method:
## import the VersaLLM class
from versallm import VersaLLM
## create the llm client
client = VersaLLM(model="claude-3-opus-20240229", functions=[get_customer_info, get_order_details, cancel_order])
## set your system prompt
client.system_message("your system message")
## use completion method to get the response by passing the tools schema
response = client.completion("your prompt", tools=tools)
## printing the client response
for message in response:
print(message)
Project Structure
versallm/llms/: Contains the client implementations for different models.versallm/utils/: Utility modules including response handling and conversational memory.
Contributing
Contributions are welcome! Please refer to the contribution guidelines for more information.
License
This project is licensed under the MIT License. See the LICENSE file for more information.
Release files for versallm 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| versallm-0.1.1.tar.gz | 7.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| versallm-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.8 kB
Release files / versallm-0.1.1.tar.gz
| Download URL | versallm-0.1.1.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff32ff40e9a4fe0de7e0a9147948ee3a48401d08e7a1102e8fe20bada47262ae
|
|
BLAKE2b-256 checksum How to use checksums |
b4b4dbdcc74e11ee62fe3129e24bd964c7d1f8abba579d2c89f8d6571a77142d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.11.6 Darwin/23.5.0
|
Release files / versallm-0.1.1-py3-none-any.whl
| Download URL | versallm-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1756594eb5e23189d4df3fc212531bd75673addecd468dcb72f139955cdb7de6
|
|
BLAKE2b-256 checksum How to use checksums |
e818b461dd5931f73ef43e83ab85d284247e9032d34366587cfb8a58099bfb5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.11.6 Darwin/23.5.0
|