regolo


Nameregolo JSON
Version 1.6.0 PyPI version JSON
download
home_pageNone
SummarySimple client to interact with regolo.ai
upload_time2025-09-03 03:08:19
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseNone
keywords chat llm regolo
VCS
bugtrack_url
requirements annotated-types anyio certifi h11 httpcore httpx idna json-repair pydantic pydantic-core sniffio typing-extensions json_repair click pytest python-dotenv pillow
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # **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:

```bash
  pip install regolo
```

# **Basic Usage**

## **1. Import the regolo module**

```python
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:

```python
regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_model = "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 inserting model and key directly.

 ## **3. Perform a basic request**

### Completion:
```python
print(regolo.static_completions(prompt="Tell me something about Rome."))
```

### Chat_completion
```python
print(regolo.static_chat_completions(messages=[{"role": "user", "content": "Tell me something about rome"}]))
```
---
# **Chatting through regolo chat CLI**
To simplify basic interactions with our LLMs, we offer you the possibility to perform request without writing code.
To do that, you only need to install python and, if you want, create a venv with the commands:
```
pip install virtualenv # install virtualenv in python
cd <the directory that'll contain your venv> # choose the starting directory for your venv
python -m venv env # create the venv in the env subdirectory
```

To use your venv, you'll go to the env subdirectory and use the source command activate it:
```
source bin/activate
```

At this point, you can run a simple chat with:
```
regolo chat
```

The CLI will guide you through inserting your API key and desired model.

It is worth mentioning that our "regolo chat" command has support for some arguments.

- "--no-hide", used to see your API key while typing
```
regolo chat --no-hide
```

- "--disable-newlines", to use if you prefer your AI to output spaces instead of new lines, which could make the
response text too large for your environment.
```
regolo chat --disable-newlines
```

- "--api-key", useful if the user prefers to insert the api key through arg instead of being prompted tot insert it.

```
regolo chat --api-key <api_key>
```

## Other cli actions
It is worth noting how the regolo cli will allow users to perform standard tasks such as:

- Getting the models that you can access through your API key via:
    ```
    regolo get-available-models
    ```
- Generating images with desired parameters via:
    ```
    regolo create-image
    ```
- Transcribing audio files via:
    ```
    regolo transcribe-audio
    ```

All of these commands will give you an overview of their available parameters if you call them the --help parameter.

---
# **Loading envs**

#### if you want to interact with this client through environment variables, you can follow this reference:

### Default values

- "API_KEY"

You can use this environment variable to insert the default_key.
You can load it after importing regolo using regolo.key_load_from_env_if_exists().
Using it is equivalent to updating regolo.default_key when you import regolo.

- "LLM"

You can use this environment variable to insert the default_model.
You can load it after importing regolo using regolo.default_model_load_from_env_if_exists().
This is equivalent to updating regolo.default_model when you import regolo.

- "IMAGE_MODEL"

You can use this environment variable to insert the default_image_model.
You can load it after importing regolo using regolo.default_image_load_from_env_if_exists().
This is equivalent to updating regolo.default_image_model when you import regolo.

- "EMBEDDER_MODEL"

You can use this environment variable to insert the default_embedder_model.
You can load it after importing regolo using regolo.default_embedder_load_from_env_if_exists().
This is equivalent to updating regolo.default_embedder_model when you import regolo.


> [!TIP]
> All "default" environment variables can be updated together
> through regolo.try_loading_from_env().
>
> It does nothing but run all the load_from_env methods al once.

### Endpoints

- "REGOLO_URL"

You can use this env variable to set the default base_url used by regolo client and its static methods.

- "COMPLETIONS_URL_PATH"

You can use this env variable to set the base_url used by regolo client and its static methods.

- "CHAT_COMPLETIONS_URL_PATH"

You can use this env variable to set the chat completions endpoint used by regolo client and its static methods.

- "IMAGE_GENERATION_URL_PATH"

You can use this env variable to set the image generation endpoint used by regolo client and its static methods.

- "EMBEDDINGS_URL_PATH"

You can use this env variable to set the embedding generation endpoint used by regolo client and its static methods.


> [!TIP]
> The "endpoints" environment variables can be changed during execution.
> Since the client works directly with them.
>
> However, you are likely not to want to change them, since they are tied to how we handle our endpoints.

---

# **Other usages**

## **Handling streams**


**With full output:**

```python
import regolo
regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_model = "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:**

```python
import regolo
regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_chat_model = "Llama-3.3-70B-Instruct"

# Completions

client = regolo.RegoloClient()
response = client.completions("Tell me about Rome in a concise manner", full_output=False, 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=False, 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()**

```python
import regolo

regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_model = "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().


## **Handling image models**

**Without client:**
```python
from io import BytesIO

import regolo
from PIL import Image

regolo.default_image_generation_model = "Qwen-Image"
regolo.default_key = "<EXAMPLE_KEY>"

img_bytes = regolo.static_image_create(prompt="a cat")[0]

image = Image.open(BytesIO(img_bytes))

image.show()
```

**With client**

```python
from io import BytesIO

import regolo
from PIL import Image

client = regolo.RegoloClient(image_generation_model="Qwen-Image", api_key="<EXAMPLE_KEY>")

img_bytes = client.create_image(prompt="A cat in Rome")[0]

image = Image.open(BytesIO(img_bytes))

image.show()
```

## **Handling embedder models**

**Without client:**
```python
import regolo

regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_embedder_model = "gte-Qwen2"


embeddings = regolo.static_embeddings(input_text=["test", "test1"])

print(embeddings)
```

**With client:**
```python
import regolo

client = regolo.RegoloClient(api_key="<EXAMPLE_KEY>", embedder_model="gte-Qwen2")

embeddings = client.embeddings(input_text=["test", "test1"])

print(embeddings)
```

## **Handling audio transcribing models**
**Without client:**
```python
import regolo

regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_audio_transcription_model = "faster-whisper-large-v3"

transcribed_text = regolo.static_audio_transcription(file="<example_path>/<example_file_name>.mp3", full_output=True)

print(transcribed_text)
```

**With client:**
```python
import regolo

client = regolo.RegoloClient(api_key="<EXAMPLE_KEY>", audio_transcription_model="faster-whisper-large-v3")

transcribed_text = client.audio_transcription(file="<example_path>/<example_file_name>.mp3", full_output=True)

print(transcribed_text)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "regolo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "chat, llm, regolo",
    "author": null,
    "author_email": "\"regolo.ai\" <dev@regolo.ai>",
    "download_url": "https://files.pythonhosted.org/packages/6d/ab/b4d9e870da767c6b76d9c3b38cc66b407b0b7ad8db61d1e9836c96e86698/regolo-1.6.0.tar.gz",
    "platform": null,
    "description": "# **Regolo.ai Python Client**\n\nA simple Python client for interacting for **Regolo.ai's** LLM-based API.\n\n## **Installation**\nEnsure you have the `regolo` module installed. If not, install it using:\n\n```bash\n  pip install regolo\n```\n\n# **Basic Usage**\n\n## **1. Import the regolo module**\n\n```python\nimport regolo\n```\n ## **2. Set Up Default API Key and Model**\n\nTo avoid manually passing the API key and model in every request, you can set them globally:\n\n```python\nregolo.default_key = \"<EXAMPLE_KEY>\"\nregolo.default_model = \"Llama-3.3-70B-Instruct\"\n```\n\nThis ensures that all `RegoloClient` instances and static functions will\nuse the specified API key and model.\n\nStill, you can create run methods by inserting model and key directly.\n\n ## **3. Perform a basic request**\n\n### Completion:\n```python\nprint(regolo.static_completions(prompt=\"Tell me something about Rome.\"))\n```\n\n### Chat_completion\n```python\nprint(regolo.static_chat_completions(messages=[{\"role\": \"user\", \"content\": \"Tell me something about rome\"}]))\n```\n---\n# **Chatting through regolo chat CLI**\nTo simplify basic interactions with our LLMs, we offer you the possibility to perform request without writing code.\nTo do that, you only need to install python and, if you want, create a venv with the commands:\n```\npip install virtualenv # install virtualenv in python\ncd <the directory that'll contain your venv> # choose the starting directory for your venv\npython -m venv env # create the venv in the env subdirectory\n```\n\nTo use your venv, you'll go to the env subdirectory and use the source command activate it:\n```\nsource bin/activate\n```\n\nAt this point, you can run a simple chat with:\n```\nregolo chat\n```\n\nThe CLI will guide you through inserting your API key and desired model.\n\nIt is worth mentioning that our \"regolo chat\" command has support for some arguments.\n\n- \"--no-hide\", used to see your API key while typing\n```\nregolo chat --no-hide\n```\n\n- \"--disable-newlines\", to use if you prefer your AI to output spaces instead of new lines, which could make the\nresponse text too large for your environment.\n```\nregolo chat --disable-newlines\n```\n\n- \"--api-key\", useful if the user prefers to insert the api key through arg instead of being prompted tot insert it.\n\n```\nregolo chat --api-key <api_key>\n```\n\n## Other cli actions\nIt is worth noting how the regolo cli will allow users to perform standard tasks such as:\n\n- Getting the models that you can access through your API key via:\n    ```\n    regolo get-available-models\n    ```\n- Generating images with desired parameters via:\n    ```\n    regolo create-image\n    ```\n- Transcribing audio files via:\n    ```\n    regolo transcribe-audio\n    ```\n\nAll of these commands will give you an overview of their available parameters if you call them the --help parameter.\n\n---\n# **Loading envs**\n\n#### if you want to interact with this client through environment variables, you can follow this reference:\n\n### Default values\n\n- \"API_KEY\"\n\nYou can use this environment variable to insert the default_key.\nYou can load it after importing regolo using regolo.key_load_from_env_if_exists().\nUsing it is equivalent to updating regolo.default_key when you import regolo.\n\n- \"LLM\"\n\nYou can use this environment variable to insert the default_model.\nYou can load it after importing regolo using regolo.default_model_load_from_env_if_exists().\nThis is equivalent to updating regolo.default_model when you import regolo.\n\n- \"IMAGE_MODEL\"\n\nYou can use this environment variable to insert the default_image_model.\nYou can load it after importing regolo using regolo.default_image_load_from_env_if_exists().\nThis is equivalent to updating regolo.default_image_model when you import regolo.\n\n- \"EMBEDDER_MODEL\"\n\nYou can use this environment variable to insert the default_embedder_model.\nYou can load it after importing regolo using regolo.default_embedder_load_from_env_if_exists().\nThis is equivalent to updating regolo.default_embedder_model when you import regolo.\n\n\n> [!TIP]\n> All \"default\" environment variables can be updated together\n> through regolo.try_loading_from_env().\n>\n> It does nothing but run all the load_from_env methods al once.\n\n### Endpoints\n\n- \"REGOLO_URL\"\n\nYou can use this env variable to set the default base_url used by regolo client and its static methods.\n\n- \"COMPLETIONS_URL_PATH\"\n\nYou can use this env variable to set the base_url used by regolo client and its static methods.\n\n- \"CHAT_COMPLETIONS_URL_PATH\"\n\nYou can use this env variable to set the chat completions endpoint used by regolo client and its static methods.\n\n- \"IMAGE_GENERATION_URL_PATH\"\n\nYou can use this env variable to set the image generation endpoint used by regolo client and its static methods.\n\n- \"EMBEDDINGS_URL_PATH\"\n\nYou can use this env variable to set the embedding generation endpoint used by regolo client and its static methods.\n\n\n> [!TIP]\n> The \"endpoints\" environment variables can be changed during execution.\n> Since the client works directly with them.\n>\n> However, you are likely not to want to change them, since they are tied to how we handle our endpoints.\n\n---\n\n# **Other usages**\n\n## **Handling streams**\n\n\n**With full output:**\n\n```python\nimport regolo\nregolo.default_key = \"<EXAMPLE_KEY>\"\nregolo.default_model = \"Llama-3.3-70B-Instruct\"\n\n# Completions\n\nclient = regolo.RegoloClient()\nresponse = client.completions(\"Tell me about Rome in a concise manner\", full_output=True, stream=True)\n\nwhile True:\n    try:\n        print(next(response))\n    except StopIteration:\n        break\n\n# Chat completions\n\nclient = regolo.RegoloClient()\nresponse = client.run_chat(user_prompt=\"Tell me about Rome in a concise manner\", full_output=True, stream=True)\n\n\nwhile True:\n    try:\n        print(next(response))\n    except StopIteration:\n        break\n```\n\n**Without full output:**\n\n```python\nimport regolo\nregolo.default_key = \"<EXAMPLE_KEY>\"\nregolo.default_chat_model = \"Llama-3.3-70B-Instruct\"\n\n# Completions\n\nclient = regolo.RegoloClient()\nresponse = client.completions(\"Tell me about Rome in a concise manner\", full_output=False, stream=True)\n\nwhile True:\n    try:\n        print(next(response), end='', flush=True)\n    except StopIteration:\n        break\n\n# Chat completions\n\nclient = regolo.RegoloClient()\nresponse = client.run_chat(user_prompt=\"Tell me about Rome in a concise manner\", full_output=False, stream=True)\n\nwhile True:\n    try:\n        res = next(response)\n        if res[0]:\n            print(res[0] + \":\")\n        print(res[1], end=\"\", flush=True)\n    except StopIteration:\n        break\n```\n\n## **Handling chat through add_prompt_to_chat()**\n\n```python\nimport regolo\n\nregolo.default_key = \"<EXAMPLE_KEY>\"\nregolo.default_model = \"Llama-3.3-70B-Instruct\"\n\nclient = regolo.RegoloClient()\n\n# Make a request\n\nclient.add_prompt_to_chat(role=\"user\", prompt=\"Tell me about rome!\")\n\nprint(client.run_chat())\n\n# Continue the conversation\n\nclient.add_prompt_to_chat(role=\"user\", prompt=\"Tell me something more about it!\")\n\nprint(client.run_chat())\n\n# You can print the whole conversation if needed\n\nprint(client.instance.get_conversation())\n```\n\nIt is to consider that using the user_prompt parameter in run_chat() is equivalent to adding a prompt with role=user\nthrough add_prompt_to_chat().\n\n\n## **Handling image models**\n\n**Without client:**\n```python\nfrom io import BytesIO\n\nimport regolo\nfrom PIL import Image\n\nregolo.default_image_generation_model = \"Qwen-Image\"\nregolo.default_key = \"<EXAMPLE_KEY>\"\n\nimg_bytes = regolo.static_image_create(prompt=\"a cat\")[0]\n\nimage = Image.open(BytesIO(img_bytes))\n\nimage.show()\n```\n\n**With client**\n\n```python\nfrom io import BytesIO\n\nimport regolo\nfrom PIL import Image\n\nclient = regolo.RegoloClient(image_generation_model=\"Qwen-Image\", api_key=\"<EXAMPLE_KEY>\")\n\nimg_bytes = client.create_image(prompt=\"A cat in Rome\")[0]\n\nimage = Image.open(BytesIO(img_bytes))\n\nimage.show()\n```\n\n## **Handling embedder models**\n\n**Without client:**\n```python\nimport regolo\n\nregolo.default_key = \"<EXAMPLE_KEY>\"\nregolo.default_embedder_model = \"gte-Qwen2\"\n\n\nembeddings = regolo.static_embeddings(input_text=[\"test\", \"test1\"])\n\nprint(embeddings)\n```\n\n**With client:**\n```python\nimport regolo\n\nclient = regolo.RegoloClient(api_key=\"<EXAMPLE_KEY>\", embedder_model=\"gte-Qwen2\")\n\nembeddings = client.embeddings(input_text=[\"test\", \"test1\"])\n\nprint(embeddings)\n```\n\n## **Handling audio transcribing models**\n**Without client:**\n```python\nimport regolo\n\nregolo.default_key = \"<EXAMPLE_KEY>\"\nregolo.default_audio_transcription_model = \"faster-whisper-large-v3\"\n\ntranscribed_text = regolo.static_audio_transcription(file=\"<example_path>/<example_file_name>.mp3\", full_output=True)\n\nprint(transcribed_text)\n```\n\n**With client:**\n```python\nimport regolo\n\nclient = regolo.RegoloClient(api_key=\"<EXAMPLE_KEY>\", audio_transcription_model=\"faster-whisper-large-v3\")\n\ntranscribed_text = client.audio_transcription(file=\"<example_path>/<example_file_name>.mp3\", full_output=True)\n\nprint(transcribed_text)\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Simple client to interact with regolo.ai",
    "version": "1.6.0",
    "project_urls": {
        "Homepage": "https://github.com/regolo-ai/python-client"
    },
    "split_keywords": [
        "chat",
        " llm",
        " regolo"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "514e7a9c2bc16f03bc84a4634102c9c17d3f83e59189cd52816e734c59f0c73f",
                "md5": "7db531796fb2594b80864c274e0eca5a",
                "sha256": "396551420bf94b08a2dcb2ea29b245d6e9d23d6393fb36ced63ed81fe7905faa"
            },
            "downloads": -1,
            "filename": "regolo-1.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7db531796fb2594b80864c274e0eca5a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 21140,
            "upload_time": "2025-09-03T03:08:17",
            "upload_time_iso_8601": "2025-09-03T03:08:17.767240Z",
            "url": "https://files.pythonhosted.org/packages/51/4e/7a9c2bc16f03bc84a4634102c9c17d3f83e59189cd52816e734c59f0c73f/regolo-1.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "6dabb4d9e870da767c6b76d9c3b38cc66b407b0b7ad8db61d1e9836c96e86698",
                "md5": "88253ca9af1c628b823e8483b4f16e6b",
                "sha256": "381b406b0d8cdb907428db299e61b1317a22787d63acf96e248e52a54267e050"
            },
            "downloads": -1,
            "filename": "regolo-1.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "88253ca9af1c628b823e8483b4f16e6b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 21961,
            "upload_time": "2025-09-03T03:08:19",
            "upload_time_iso_8601": "2025-09-03T03:08:19.262229Z",
            "url": "https://files.pythonhosted.org/packages/6d/ab/b4d9e870da767c6b76d9c3b38cc66b407b0b7ad8db61d1e9836c96e86698/regolo-1.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-03 03:08:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "regolo-ai",
    "github_project": "python-client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "annotated-types",
            "specs": [
                [
                    "==",
                    "0.7.0"
                ]
            ]
        },
        {
            "name": "anyio",
            "specs": [
                [
                    "==",
                    "4.8.0"
                ]
            ]
        },
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2025.1.31"
                ]
            ]
        },
        {
            "name": "h11",
            "specs": [
                [
                    "==",
                    "0.14.0"
                ]
            ]
        },
        {
            "name": "httpcore",
            "specs": [
                [
                    "==",
                    "1.0.7"
                ]
            ]
        },
        {
            "name": "httpx",
            "specs": [
                [
                    "==",
                    "0.28.1"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.10"
                ]
            ]
        },
        {
            "name": "json-repair",
            "specs": [
                [
                    "==",
                    "0.35.0"
                ]
            ]
        },
        {
            "name": "pydantic",
            "specs": [
                [
                    "==",
                    "2.10.6"
                ]
            ]
        },
        {
            "name": "pydantic-core",
            "specs": [
                [
                    "==",
                    "2.27.2"
                ]
            ]
        },
        {
            "name": "sniffio",
            "specs": [
                [
                    "==",
                    "1.3.1"
                ]
            ]
        },
        {
            "name": "typing-extensions",
            "specs": [
                [
                    "==",
                    "4.12.2"
                ]
            ]
        },
        {
            "name": "json_repair",
            "specs": [
                [
                    "~=",
                    "0.35.0"
                ]
            ]
        },
        {
            "name": "click",
            "specs": [
                [
                    "==",
                    "8.1.8"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "~=",
                    "8.3.4"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": []
        },
        {
            "name": "pillow",
            "specs": [
                [
                    "~=",
                    "11.1.0"
                ]
            ]
        }
    ],
    "lcname": "regolo"
}
        
Elapsed time: 1.37565s