Skip to main content

Simple client to interact with regolo.ai

Project description

Regolo.ai Python Client

A simple Python client for interacting for Regolo.ai's LLM-based API.

Installation

Ensure you have the regolo module installed. If not, install it using:

  pip install regolo

Basic Usage

1. Import the regolo module

import regolo

2. Set Up Default API Key and Model

To avoid manually passing the API key and model in every request, you can set them globally:

regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_model = "meta-llama/Llama-3.3-70B-Instruct"

This ensures that all RegoloClient instances and static functions will use the specified API key and model.

Still, you can create run methods by passing model and key directly.

3. Perform a basic request

Completion:

print(regolo.static_completions(prompt="Tell me something about Rome."))

Chat_completion

print(regolo.static_chat_completions(messages=[{"role": "user", "content": "Tell me something about rome"}]))

Other usages

Handling streams

With full output:

import regolo
regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_model = "meta-llama/Llama-3.3-70B-Instruct"

# Completions

client = regolo.RegoloClient()
response = client.completions("Tell me about Rome in a concise manner", full_output=True, stream=True)

while True:
    try:
        print(next(response))
    except StopIteration:
        break

# Chat completions

client = regolo.RegoloClient()
response = client.run_chat(user_prompt="Tell me about Rome in a concise manner", full_output=True, stream=True)


while True:
    try:
        print(next(response))
    except StopIteration:
        break

Without full output:

import regolo
regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_model = "meta-llama/Llama-3.3-70B-Instruct"

# Completions

client = regolo.RegoloClient()
response = client.completions("Tell me about Rome in a concise manner", full_output=True, stream=True)

while True:
    try:
        print(next(response), end='', flush=True)
    except StopIteration:
        break

# Chat completions

client = regolo.RegoloClient()
response = client.run_chat(user_prompt="Tell me about Rome in a concise manner", full_output=True, stream=True)

while True:
    try:
        res = next(response)
        if res[0]:
            print(res[0] + ":")
        print(res[1], end="", flush=True)
    except StopIteration:
        break

Handling chat through add_prompt_to_chat()

import regolo

regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_model = "meta-llama/Llama-3.3-70B-Instruct"

client = regolo.RegoloClient()

# Make a request

client.add_prompt_to_chat(role="user", prompt="Tell me about rome!")

print(client.run_chat())

# Continue the conversation

client.add_prompt_to_chat(role="user", prompt="Tell me something more about it!")

print(client.run_chat())

# You can print the whole conversation if needed

print(client.instance.get_conversation())

It is to consider that using the user_prompt parameter in run_chat() is equivalent to adding a prompt with role=user through add_prompt_to_chat().

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

regolo-1.0.2.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

regolo-1.0.2-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file regolo-1.0.2.tar.gz.

File metadata

  • Download URL: regolo-1.0.2.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for regolo-1.0.2.tar.gz
Algorithm Hash digest
SHA256 9840a21c918ecdeb838863914a9d0b85592903114d8b9f07b1c4c52fde4e8165
MD5 7d93f79b1df9763c9e8737f296032097
BLAKE2b-256 c7742a5a016ca693901213abe2dc1868f3db476f610d904fb6fb0389881d1ce3

See more details on using hashes here.

File details

Details for the file regolo-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: regolo-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for regolo-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 70bd3fb4f7323c215c6f85bf55f0c6b6986d812c332fdbdf5a5bd6d2e25a1263
MD5 b96912e51b874cd0badf904cab3ba9bb
BLAKE2b-256 5a6b7f0ddc789a0c8206bbb3aa2d84a66da0e375fe96177a652db11a00c73a4d

See more details on using hashes here.

Supported by

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