Library to interact with Expert AI Answers engine
Project description
Answers Lib
Library to interact with Expert AI Answers engine.
Installation
pip install eai-answers-lib
Or install with dev dependencies for development:
pip install eai-answers-lib[dev]
Quick Start
from eai_answers_lib import Answers, QueryRequest
# Create Answers client
a = Answers(endpoint="https://your-api.example.com/api")
# Create query request using schema (recommended)
query = QueryRequest(question="What are the effects of dietary insect meal?")
# Execute query
result = a(query, pkg="my_knowledge_base", collection="my_collection")
Usage with Dict (Auto-converted)
from eai_answers_lib import Answers
a = Answers(endpoint="https://your-api.example.com/api")
# Pass as dict - automatically converted to QueryRequest
result = a(
{"question": "Your question here"},
pkg="my_knowledge_base",
collection="my_collection"
)
Query Request Options
The QueryRequest schema supports all API options:
from eai_answers_lib import QueryRequest, QueryImage, QueryParams
query = QueryRequest(
question="Your question",
config_name="default",
user="user@example.com",
images=[
QueryImage(name="image1", data="base64...", mime_type="image/png")
],
params=QueryParams(
filters=["tag:important"],
top_k_docs=10,
debug=True
),
neural={"score_ranges": {...}},
generative={"generative_answer": True, "stream": False}
)
Authentication
a = Answers(
endpoint="https://your-api.example.com/api",
enable_auth=True,
client_id="your-client-id",
client_secret="your-client-secret",
auth_url="https://auth.example.com",
auth_path="auth",
realm="your-realm"
)
Environment Variables
ANSWERS_ENDPOINT- API endpoint URL (required)ANSWERS_OWNER_ACCOUNT- Default owner account (default: "default")ANSWERS_CLIENT_ID- Client ID for authenticationANSWERS_CLIENT_SECRET- Client secret for authentication
Knowledge Base Operations
from eai_answers_lib import Answers
a = Answers(endpoint="https://api.example.com", enable_auth=True)
# List user directories
dirs = a.get_user_dirs("user@example.com")
# List collections in a directory
collections = a.get_dir_collections("root_dir_id")
# Check if KB exists
exists = a.kb_exists("my_kb")
# Create a new KB
a.add_kb("my_new_kb", "user@example.com")
# Create collection
collection_id = a.create_collection("my_kb", "My Collection")
Documentation
Build Sphinx documentation:
pip install sphinx sphinx-rtd-theme
sphinx-build -b html docs docs/_build
open docs/_build/index.html
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
eai_answers_lib-0.1.2.tar.gz
(10.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eai_answers_lib-0.1.2.tar.gz.
File metadata
- Download URL: eai_answers_lib-0.1.2.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ea8c58650cd808dfb2828ca7b6ce675df1cb5331868bb00ae1ae224b2557b77
|
|
| MD5 |
d1ad2c9fe93143114a4046076b670414
|
|
| BLAKE2b-256 |
4dd9f20a3486477cb8551e026ca5fb88e3857ca65f8f6c0af9ad3af2ba0d04ea
|
File details
Details for the file eai_answers_lib-0.1.2-py3-none-any.whl.
File metadata
- Download URL: eai_answers_lib-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ed668c9861fc84d6fdf0fd66473700023399b8155f946d998bf504600eff581
|
|
| MD5 |
f31df0a87bc411e57b25ea277167232c
|
|
| BLAKE2b-256 |
51c2e24d7fabd9bf1045d4566bb3df4999dd28cfa9e245caab5557a0f88e4313
|