Skip to main content

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 authentication
  • ANSWERS_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.1.1.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

eai_answers_lib-0.1.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file eai_answers_lib-0.1.1.tar.gz.

File metadata

  • Download URL: eai_answers_lib-0.1.1.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.4

File hashes

Hashes for eai_answers_lib-0.1.1.tar.gz
Algorithm Hash digest
SHA256 fc10509628be29a4cdf487ec9ac3b39916a4295ee4fe0a88c272ec4e3807e8fe
MD5 7b7b26b26b4d8063281292908718e9d0
BLAKE2b-256 4fe0432637bcbc41275a49736d8d7388544b3a94cff15a8f290d7176a7b6dad2

See more details on using hashes here.

File details

Details for the file eai_answers_lib-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for eai_answers_lib-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1002705e4f87216b48f2dfad65c09a94caf8fca6d368ba29d3cf920b3276db2f
MD5 dc360934013ca67334bf65d4e8c3fda0
BLAKE2b-256 21aea7c4a04a8fddbe84975dc678a89269835d35168cbd18091ce4d507bb7da5

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