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
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.2.0.tar.gz
(12.1 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.2.0.tar.gz.
File metadata
- Download URL: eai_answers_lib-0.2.0.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d13c9e72ed1a48bf5d63c62a3ce331079b9d1cafd001610d26b9e5f4725e5998
|
|
| MD5 |
1142bb1cc69b378fe43f045f7d001f14
|
|
| BLAKE2b-256 |
043d63b442816b232865c52e160fe7c12c198d088a67f32b793034a8ff7f0902
|
File details
Details for the file eai_answers_lib-0.2.0-py3-none-any.whl.
File metadata
- Download URL: eai_answers_lib-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
953e14f57e1e23b11b2da8922268144834ecd5d552ccf3952bfb38e4d53ae50e
|
|
| MD5 |
e89dc151c18a205cfa22d3ebba8e8530
|
|
| BLAKE2b-256 |
16f4e134fbf001365e7ad6b8630353d770ce214982e3352e552bc90747869fd7
|