A Python wrapper for the AwanLLM API to easily generate text and chat completions.
Project description
AwanLLM API Wrapper
This Python API wrapper provides an easy way to interact with the AwanLLM language models, allowing you to use the capabilities of the AwanLLM platform for generating text completions and chat-based interactions.
Installation
To use this API wrapper, you need to have Python installed on your system. You can install the required library by running:
pip install awan-llm-api
Usage
Setting Up
First, you need to set up your API key and select a model. You can find the list of available models on the AwanLLM website.
from awan_llm_api import AwanLLMClient, Role
from awan_llm_api.completions import Completions, ChatCompletions
AWANLLM_API_KEY = "YOUR_API_KEY"
MODEL = "Meta-Llama-3-8B-Instruct" # Replace with your chosen model
client = AwanLLMClient(AWANLLM_API_KEY)
Chat Completion Example
To generate a chat completion, you need to create a ChatCompletions
instance, add messages to it, and then request a completion from the client.
# Initialize a ChatCompletions instance
chat = ChatCompletions(MODEL)
# Add a user message to the chat
chat.add_message(Role.USER, "Hello !")
# Request a chat completion
chat_response = client.chat_completion(chat)
# Print the chat response
print(chat_response)
Text Completion Example
To generate a text completion, you need to create a Completions
instance with a prompt and then request a completion from the client.
# Initialize a Completions instance with a prompt
completion = Completions(MODEL, "Here's how you can make a cake using pizza:")
# Request a text completion
completion_response = client.completion(completion)
# Print the completion response
print(completion_response)
Getting Help
For more details, check the AwanLLM API documentation.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
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
Hashes for awan_llm_api-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f41b8a0df785eb29be8bbf992149f028a2e7a5ec480f4be9f12f0d6b961d76b |
|
MD5 | 9eb93870ef342ae13df648fafb053e2d |
|
BLAKE2b-256 | 019e61aafe1ff70288ae28a32e1495d647ae9e041a735d13baf94fcdcb6a7488 |