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.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file versallm-0.1.1.tar.gz.
File metadata
- Download URL: versallm-0.1.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.6 Darwin/23.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff32ff40e9a4fe0de7e0a9147948ee3a48401d08e7a1102e8fe20bada47262ae
|
|
| MD5 |
3716becd78b1a9a24ce8d4d7db7d7c6d
|
|
| BLAKE2b-256 |
b4b4dbdcc74e11ee62fe3129e24bd964c7d1f8abba579d2c89f8d6571a77142d
|
File details
Details for the file versallm-0.1.1-py3-none-any.whl.
File metadata
- Download URL: versallm-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.6 Darwin/23.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1756594eb5e23189d4df3fc212531bd75673addecd468dcb72f139955cdb7de6
|
|
| MD5 |
cd7c0d538fc75ba17a692ec1315c1aaa
|
|
| BLAKE2b-256 |
e818b461dd5931f73ef43e83ab85d284247e9032d34366587cfb8a58099bfb5c
|