Skip to main content

A package for managing qBud assistants and chats

Project description

qBud Python Client

qbud helps to make interaction with qBud assistants easier. Its aim is to provide a low-code solution for interactions with assistants that you have configured via the UI.

How to Install

Installing is easy:

pip install qbud

We recommend python>=3.9, but the client may run with older versions as well. The only external dependency is the widely used requests library, which is installed when running the above command.

Configuration

Authentication is done with a per-assistant access key, generated from your account.

Variable Required Default Purpose
QBUD_ASSISTANT_ACCESS_KEY yes* Access key for the assistant. *Optional if you pass access_key=... to Assistant() directly.
QBUD_BASE_URL no https://api.qbud.ai Override the API host (e.g. for staging).

Quickstart

1. Connect to an assistant

Make sure you have built an assistant via our UI. When you're editing the assistant there, copy the ID from the address bar (after /assistants/) and pair it with your assistant access key:

from qbud import Assistant

assistant = Assistant("<your-assistant-id>", access_key="<your-access-key>")
# or, with QBUD_ASSISTANT_ACCESS_KEY set in the environment:
assistant = Assistant("<your-assistant-id>")

2. Send messages

Create a chat with assistant.create_chat() and call send_message(...) on it:

chat = assistant.create_chat()
response = chat.send_message("Hi!")
print(response)
> {"content": "Hi there!", "role": "assistant"}

Saving and loading chats

By design, chat message history cannot be retrieved from our API. If you need history across sessions, save chats locally:

from qbud import Chat

# save a Chat object as JSON (message history only — the access key is
# never written to disk, since it is a bearer credential for the chat)
chat.save("chat.json")

# ...session terminates

# load a Chat instance from the saved JSON. The result is read-only:
# get_messages() works, but send_message() requires a live chat created
# via Assistant.create_chat().
chat = Chat.load("chat.json")

You can also inspect the in-memory history with get_messages(...):

print(chat.get_messages())
> [{"content": "Hi!", "role": "user"}, {"content": "Hi there!", "role": "assistant"}]

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

qbud-0.2.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qbud-0.2.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file qbud-0.2.0.tar.gz.

File metadata

  • Download URL: qbud-0.2.0.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for qbud-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a33815638a17a9f462d19eeab95fa19704816b108373748ff469f0fb34a0bebe
MD5 2d326c54efbd62c01f1bf40bd033e44d
BLAKE2b-256 16213a5afb5f32602ce107fbe3f467dacbe3832f62c5ad8fe0d5536b87d8395a

See more details on using hashes here.

File details

Details for the file qbud-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: qbud-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for qbud-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94fe3110b20dcf187d5c7fa58603c2abc19216b3ce1aff150ade714aef10afd0
MD5 6ae44fd3de58c2f68f8fc1dbde7544ef
BLAKE2b-256 ecf2e55fcf82006f1adc8d9857c0115fcd183b215011931fc2b44d7f2654c0ab

See more details on using hashes here.

Supported by

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