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.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

regolo-1.0.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: regolo-1.0.1.tar.gz
  • Upload date:
  • Size: 10.2 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.1.tar.gz
Algorithm Hash digest
SHA256 ca969cb59380ec9093b9e35b6f560107c0e6739cff034517560f7ae29ce57451
MD5 349d582c4578dc710b9fecaa75069604
BLAKE2b-256 ac9c4c65e08c23fdeee8b7bd02d9aedbd37716024c640988c3f29ea955a59b29

See more details on using hashes here.

File details

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

File metadata

  • Download URL: regolo-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 96e1ac7aa9a48945294eba0c2373e5890c623be07c11df021e86d16e5248877a
MD5 75ee5f1c38ede315ea1f78b885cd676f
BLAKE2b-256 c32ef6ec27b39e08f662fe3cfcf14f6b2859684ef57bc97170c4c5370f49b1f6

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