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
Metadata
Release files for eai_answers_lib 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| eai_answers_lib-0.2.0.tar.gz | 12.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| eai_answers_lib-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.8 kB
Release files / eai_answers_lib-0.2.0.tar.gz
| Download URL | eai_answers_lib-0.2.0.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d13c9e72ed1a48bf5d63c62a3ce331079b9d1cafd001610d26b9e5f4725e5998
|
|
BLAKE2b-256 checksum How to use checksums |
043d63b442816b232865c52e160fe7c12c198d088a67f32b793034a8ff7f0902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.4
|
Release files / eai_answers_lib-0.2.0-py3-none-any.whl
| Download URL | eai_answers_lib-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
953e14f57e1e23b11b2da8922268144834ecd5d552ccf3952bfb38e4d53ae50e
|
|
BLAKE2b-256 checksum How to use checksums |
16f4e134fbf001365e7ad6b8630353d770ce214982e3352e552bc90747869fd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.4
|