Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awan_llm_api-0.0.2.tar.gz (3.4 kB view hashes)

Uploaded Source

Built Distribution

awan_llm_api-0.0.2-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page