knowledgeai-client


Nameknowledgeai-client JSON
Version 0.6.0 PyPI version JSON
download
home_pagehttps://github.com/arvato-systems-aila-solutions/KnowledgeAI-Python-Client
SummaryA python client for the Avvia Intelligence - Knowledge AI Rest API
upload_time2024-05-03 13:31:10
maintainerNone
docs_urlNone
authorArvato Systems
requires_python>=3.11
licenseMIT
keywords ai knowledge retrieval arvato systems avvia intelligence knowledgeai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Avvia Intelligence - KnowledgeAI Python Client

Version: 0.6.0, (c) 2024 Arvato Systems

This library is designed to provide easy access to the KnowledgeAI backend service. It enables users to manage projects, upload documents, and perform various tasks programmatically. The client offers an intuitive interface for seamless integration into Python applications.

## Installation
```bash
pip install knowledgeai-client
```
```bash
poetry add knowledgeai-client
```

## Usage
```python
from knowledgeai import KnowledgeAIClient

# Initialize the KnowledgeAIClient
client = KnowledgeAIClient(url="https://your-knowledgeai-service.com", api_key="your_api_key")

# Uploads all files in a directory to the specified project
client.upload_directory(project_id="project_id", directory="/path/to/directory", roles="admin,user")

# Uploads multiple documents to the specified project
client.index_documents(project_id="project_id", files=["/path/to/file1.txt", "/path/to/file2.txt"], roles="user,admin")

# Indexes the specified URL to the specified project
client.index_urls(project_id="project_id", index_urls=["https://www.example.com"], roles="user")

# Lists all projects
projects = client.list_projects()
for project in projects:
    print(project.name)

# Gets the project with the specified ID
project = client.get_project(project_id=1, with_documents=True)
print(project.name)

# Creates a new project with the specified name
project = client.create_project(project_name="New Project", prompt="x", language=IsoLanguage.ENGLISH, llm=LLM.OPENAI)
print(project.name)

# Updates the specified project
project = client.get_project(project_id=1)
project.name = "New Project Name"
response = client.update_project(project)

# Updates the configuration of the specified project
project = client.update_project_configuration(project_id=1, key=ProjectConfigKey.WELCOME_MESSAGE, value="value")

# Asks a question to the specified project
response = client.ask(project_id=1, question="What is the capital of Germany?")
print(response.answer)

# Retrieves documents for the specified project
references = client.retrieve(project_id=1, query="What is the capital of Germany?", retrieval_type=Retriever.default)
for reference in references:
    print(reference.content)

# Delete document from project
client.delete_document(project_id=1, document_id=1)

# Delete all documents of a project
client.delete_all_documents(project_id=1)

# Delete project
client.delete_project(project_id=1)

```

## Documentation

The `KnowledgeAIClient` facilitates seamless communication with the Avvia Intelligence KnowledgeAI service, allowing users to manage projects, upload documents, and perform various other tasks programmatically. It provides an intuitive interface to interact with the KnowledgeAI platform, enabling easy integration into Python applications.

### Class: KnowledgeAIClient

#### Constructor: `__init__(url: str, api_key: str, timeout: int = 30) -> None`

Initializes a new instance of the `KnowledgeAIClient` class.

- `url` (str): The URL of the KnowledgeAI service.
- `api_key` (str): The API key for authentication.
- `timeout` (int, optional): The timeout for API requests in seconds. Defaults to 30.

#### Method: `upload_directory(project_id: int, directory: str, roles: str = "user") -> None`

Convenience method to upload all files in a directory to the specified project.

- `project_id` (int): The ID of the project to upload the documents to.
- `directory` (str): The path to the directory containing the files to upload.
- `roles` (str, optional): The roles to assign to the uploaded documents. Comma-separated list. Defaults to "user".


#### Method: `index_documents(project_id: int, files: List[str], roles: str = "user") -> None`

Uploads multiple documents to the specified project.

- `project_id` (int): The ID of the project to upload the documents to.
- `files` (List[str]): A list of file paths to upload.
- `roles` (str, optional): The roles to assign to the uploaded documents. Comma-separated list. Defaults to "user".


#### Method: `index_urls(project_id: int, index_urls: List[str], roles: Optional[str]) -> None`

Indexes the specified URL to the specified project.

- `project_id` (int): The ID of the project to index the URL to.
- `index_urls` (List[str]): The URLs to index.
- `roles` (str, optional): The roles to assign to the indexed document. Comma-separated list. Defaults to "user".


#### Method: `list_projects() -> List[Project]`

Lists all projects.

Returns:
- `List[Project]`: A list of projects.


#### Method: `get_project(project_id: int, with_documents: bool = False) -> Project`

Gets the project with the specified ID.

- `project_id` (int): The ID of the project to get.
- `with_documents` (bool, optional): Whether to include the documents in the response.

Returns:
- `Project`: The project with the specified ID.


#### Method: `create_project(project_name: str, prompt: str, language: IsoLanguage = IsoLanguage.ENGLISH, llm: LLM = LLM.OPENAI) -> Project`

Creates a new project with the specified name.

- `project_name` (str): The name of the project to create.
- `language` (IsoLanguage, optional): The language of the project. Defaults to IsoLanguage.ENGLISH.
- `llm` (LLM, optional): The language model to use. Defaults to LLM.OPENAI.
- `prompt` (str, optional): The prompt to use for the project.

Returns:
- `Project`: The created project.


#### Method: `update_project(project: Project) -> Response`

Updates the specified project.

- `project` (Project): The project to update.

Returns:
- `Response`: The updated project.


#### Method: `update_project_configuration(project_id: int, key: ProjectConfigKey, value: str) -> Project`

Updates the configuration of the specified project.

- `project_id` (int): The ID of the project to update the configuration for.
- `key` (str): The key of the configuration to update.
- `value` (str): The value to update the configuration to.

Returns:
- `Project`: The updated project.


#### Method: `ask(project_id: int, question: str) -> AskResponse`

Asks a question to the specified project.

- `project_id` (int): The ID of the project to ask the question to.
- `question` (str): The question to ask.

Returns:
- `AskResponse`: The response to the question.


#### Method: `retrieve(project_id: int, query: str, retrieval_type: Retriever = Retriever.default) -> List[RetrievedDocument]`

Retrieves documents for the specified project.

- `project_id` (int): The ID of the project to retrieve documents from.
- `query` (str): The query to retrieve documents for.
- `retrieval_type` (Retriever, optional): The type of retrieval to use.

Returns:
- `List[RetrievedDocument]`: The retrieved documents.

#### Method: `delete_project(project_id: int) -> None`

This method is used to delete a specific project.

- `project_id` (int): The ID of the project to be deleted.

#### Method: `delete_document(project_id: int, document_id: int) -> None`

This method is used to delete a specific document from a project.

- `project_id` (int): The ID of the project from which the document will be deleted.
- `document_id` (int): The ID of the document to be deleted.

#### Method: `delete_all_documents(project_id: int) -> None`

This method is used to delete all documents from a specific project.

- `project_id` (int): The ID of the project from which all documents will be deleted.


### Schema Description

Before diving into the usage of `KnowledgeAIClient`, it's important to understand the schema used in the API. Here are the key classes and enums used:

#### ProjectConfigKey (Enum)

Defines keys for project configuration settings such as `BOTSERVICE_APP_ID`, `BOTSERVICE_APP_PASSWORD`, `BOTSERVICE_SECRET`, and `WELCOME_MESSAGE`.

#### Plan (Enum)

Represents different plans available such as `FREE`, `BASIC`, `PREMIUM`, and `ENTERPRISE`.

#### IsoLanguage (Enum)

Defines ISO language codes for languages such as `GERMAN` and `ENGLISH`.

#### LLM (Enum)

Represents different language models like `OPENAI`, `GOOGLE`, and `ANTHROPIC`.

#### AskResponse (Model)

Represents a response to a question with attributes `question`, `answer`, `source_paragraphs`, and `source_documents`.

#### Retriever (Enum)

Defines different types of retrievers such as `default`, `multiquery`, and `compression`.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/arvato-systems-aila-solutions/KnowledgeAI-Python-Client",
    "name": "knowledgeai-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "AI, Knowledge Retrieval, arvato systems, avvia intelligence, knowledgeai",
    "author": "Arvato Systems",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/86/33/c85dff997253f8b682aa85ab77bb75d604cce1258030e39de084bffd151f/knowledgeai_client-0.6.0.tar.gz",
    "platform": null,
    "description": "\n# Avvia Intelligence - KnowledgeAI Python Client\n\nVersion: 0.6.0, (c) 2024 Arvato Systems\n\nThis library is designed to provide easy access to the KnowledgeAI backend service. It enables users to manage projects, upload documents, and perform various tasks programmatically. The client offers an intuitive interface for seamless integration into Python applications.\n\n## Installation\n```bash\npip install knowledgeai-client\n```\n```bash\npoetry add knowledgeai-client\n```\n\n## Usage\n```python\nfrom knowledgeai import KnowledgeAIClient\n\n# Initialize the KnowledgeAIClient\nclient = KnowledgeAIClient(url=\"https://your-knowledgeai-service.com\", api_key=\"your_api_key\")\n\n# Uploads all files in a directory to the specified project\nclient.upload_directory(project_id=\"project_id\", directory=\"/path/to/directory\", roles=\"admin,user\")\n\n# Uploads multiple documents to the specified project\nclient.index_documents(project_id=\"project_id\", files=[\"/path/to/file1.txt\", \"/path/to/file2.txt\"], roles=\"user,admin\")\n\n# Indexes the specified URL to the specified project\nclient.index_urls(project_id=\"project_id\", index_urls=[\"https://www.example.com\"], roles=\"user\")\n\n# Lists all projects\nprojects = client.list_projects()\nfor project in projects:\n    print(project.name)\n\n# Gets the project with the specified ID\nproject = client.get_project(project_id=1, with_documents=True)\nprint(project.name)\n\n# Creates a new project with the specified name\nproject = client.create_project(project_name=\"New Project\", prompt=\"x\", language=IsoLanguage.ENGLISH, llm=LLM.OPENAI)\nprint(project.name)\n\n# Updates the specified project\nproject = client.get_project(project_id=1)\nproject.name = \"New Project Name\"\nresponse = client.update_project(project)\n\n# Updates the configuration of the specified project\nproject = client.update_project_configuration(project_id=1, key=ProjectConfigKey.WELCOME_MESSAGE, value=\"value\")\n\n# Asks a question to the specified project\nresponse = client.ask(project_id=1, question=\"What is the capital of Germany?\")\nprint(response.answer)\n\n# Retrieves documents for the specified project\nreferences = client.retrieve(project_id=1, query=\"What is the capital of Germany?\", retrieval_type=Retriever.default)\nfor reference in references:\n    print(reference.content)\n\n# Delete document from project\nclient.delete_document(project_id=1, document_id=1)\n\n# Delete all documents of a project\nclient.delete_all_documents(project_id=1)\n\n# Delete project\nclient.delete_project(project_id=1)\n\n```\n\n## Documentation\n\nThe `KnowledgeAIClient` facilitates seamless communication with the Avvia Intelligence KnowledgeAI service, allowing users to manage projects, upload documents, and perform various other tasks programmatically. It provides an intuitive interface to interact with the KnowledgeAI platform, enabling easy integration into Python applications.\n\n### Class: KnowledgeAIClient\n\n#### Constructor: `__init__(url: str, api_key: str, timeout: int = 30) -> None`\n\nInitializes a new instance of the `KnowledgeAIClient` class.\n\n- `url` (str): The URL of the KnowledgeAI service.\n- `api_key` (str): The API key for authentication.\n- `timeout` (int, optional): The timeout for API requests in seconds. Defaults to 30.\n\n#### Method: `upload_directory(project_id: int, directory: str, roles: str = \"user\") -> None`\n\nConvenience method to upload all files in a directory to the specified project.\n\n- `project_id` (int): The ID of the project to upload the documents to.\n- `directory` (str): The path to the directory containing the files to upload.\n- `roles` (str, optional): The roles to assign to the uploaded documents. Comma-separated list. Defaults to \"user\".\n\n\n#### Method: `index_documents(project_id: int, files: List[str], roles: str = \"user\") -> None`\n\nUploads multiple documents to the specified project.\n\n- `project_id` (int): The ID of the project to upload the documents to.\n- `files` (List[str]): A list of file paths to upload.\n- `roles` (str, optional): The roles to assign to the uploaded documents. Comma-separated list. Defaults to \"user\".\n\n\n#### Method: `index_urls(project_id: int, index_urls: List[str], roles: Optional[str]) -> None`\n\nIndexes the specified URL to the specified project.\n\n- `project_id` (int): The ID of the project to index the URL to.\n- `index_urls` (List[str]): The URLs to index.\n- `roles` (str, optional): The roles to assign to the indexed document. Comma-separated list. Defaults to \"user\".\n\n\n#### Method: `list_projects() -> List[Project]`\n\nLists all projects.\n\nReturns:\n- `List[Project]`: A list of projects.\n\n\n#### Method: `get_project(project_id: int, with_documents: bool = False) -> Project`\n\nGets the project with the specified ID.\n\n- `project_id` (int): The ID of the project to get.\n- `with_documents` (bool, optional): Whether to include the documents in the response.\n\nReturns:\n- `Project`: The project with the specified ID.\n\n\n#### Method: `create_project(project_name: str, prompt: str, language: IsoLanguage = IsoLanguage.ENGLISH, llm: LLM = LLM.OPENAI) -> Project`\n\nCreates a new project with the specified name.\n\n- `project_name` (str): The name of the project to create.\n- `language` (IsoLanguage, optional): The language of the project. Defaults to IsoLanguage.ENGLISH.\n- `llm` (LLM, optional): The language model to use. Defaults to LLM.OPENAI.\n- `prompt` (str, optional): The prompt to use for the project.\n\nReturns:\n- `Project`: The created project.\n\n\n#### Method: `update_project(project: Project) -> Response`\n\nUpdates the specified project.\n\n- `project` (Project): The project to update.\n\nReturns:\n- `Response`: The updated project.\n\n\n#### Method: `update_project_configuration(project_id: int, key: ProjectConfigKey, value: str) -> Project`\n\nUpdates the configuration of the specified project.\n\n- `project_id` (int): The ID of the project to update the configuration for.\n- `key` (str): The key of the configuration to update.\n- `value` (str): The value to update the configuration to.\n\nReturns:\n- `Project`: The updated project.\n\n\n#### Method: `ask(project_id: int, question: str) -> AskResponse`\n\nAsks a question to the specified project.\n\n- `project_id` (int): The ID of the project to ask the question to.\n- `question` (str): The question to ask.\n\nReturns:\n- `AskResponse`: The response to the question.\n\n\n#### Method: `retrieve(project_id: int, query: str, retrieval_type: Retriever = Retriever.default) -> List[RetrievedDocument]`\n\nRetrieves documents for the specified project.\n\n- `project_id` (int): The ID of the project to retrieve documents from.\n- `query` (str): The query to retrieve documents for.\n- `retrieval_type` (Retriever, optional): The type of retrieval to use.\n\nReturns:\n- `List[RetrievedDocument]`: The retrieved documents.\n\n#### Method: `delete_project(project_id: int) -> None`\n\nThis method is used to delete a specific project.\n\n- `project_id` (int): The ID of the project to be deleted.\n\n#### Method: `delete_document(project_id: int, document_id: int) -> None`\n\nThis method is used to delete a specific document from a project.\n\n- `project_id` (int): The ID of the project from which the document will be deleted.\n- `document_id` (int): The ID of the document to be deleted.\n\n#### Method: `delete_all_documents(project_id: int) -> None`\n\nThis method is used to delete all documents from a specific project.\n\n- `project_id` (int): The ID of the project from which all documents will be deleted.\n\n\n### Schema Description\n\nBefore diving into the usage of `KnowledgeAIClient`, it's important to understand the schema used in the API. Here are the key classes and enums used:\n\n#### ProjectConfigKey (Enum)\n\nDefines keys for project configuration settings such as `BOTSERVICE_APP_ID`, `BOTSERVICE_APP_PASSWORD`, `BOTSERVICE_SECRET`, and `WELCOME_MESSAGE`.\n\n#### Plan (Enum)\n\nRepresents different plans available such as `FREE`, `BASIC`, `PREMIUM`, and `ENTERPRISE`.\n\n#### IsoLanguage (Enum)\n\nDefines ISO language codes for languages such as `GERMAN` and `ENGLISH`.\n\n#### LLM (Enum)\n\nRepresents different language models like `OPENAI`, `GOOGLE`, and `ANTHROPIC`.\n\n#### AskResponse (Model)\n\nRepresents a response to a question with attributes `question`, `answer`, `source_paragraphs`, and `source_documents`.\n\n#### Retriever (Enum)\n\nDefines different types of retrievers such as `default`, `multiquery`, and `compression`.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python client for the Avvia Intelligence - Knowledge AI Rest API",
    "version": "0.6.0",
    "project_urls": {
        "Homepage": "https://github.com/arvato-systems-aila-solutions/KnowledgeAI-Python-Client"
    },
    "split_keywords": [
        "ai",
        " knowledge retrieval",
        " arvato systems",
        " avvia intelligence",
        " knowledgeai"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2ffeceace219b327e9e23681ed0c0171d5b41edb5d8eca323a33df37dafb37b2",
                "md5": "59aa0562b732206d6241808dcbda1efb",
                "sha256": "ed3b2ba3a92d6e90cc20b220b4a1191c552cdacf8ec33c5de8f8aa1f374403f1"
            },
            "downloads": -1,
            "filename": "knowledgeai_client-0.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "59aa0562b732206d6241808dcbda1efb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 10687,
            "upload_time": "2024-05-03T13:31:08",
            "upload_time_iso_8601": "2024-05-03T13:31:08.587111Z",
            "url": "https://files.pythonhosted.org/packages/2f/fe/ceace219b327e9e23681ed0c0171d5b41edb5d8eca323a33df37dafb37b2/knowledgeai_client-0.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8633c85dff997253f8b682aa85ab77bb75d604cce1258030e39de084bffd151f",
                "md5": "3c17c39b0431460a46ec372cce8971a4",
                "sha256": "154bc5cb6a3c3db900f6487eb3813be9fa9da8b45dd897d4d866411a22d52268"
            },
            "downloads": -1,
            "filename": "knowledgeai_client-0.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "3c17c39b0431460a46ec372cce8971a4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 11323,
            "upload_time": "2024-05-03T13:31:10",
            "upload_time_iso_8601": "2024-05-03T13:31:10.120219Z",
            "url": "https://files.pythonhosted.org/packages/86/33/c85dff997253f8b682aa85ab77bb75d604cce1258030e39de084bffd151f/knowledgeai_client-0.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-03 13:31:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "arvato-systems-aila-solutions",
    "github_project": "KnowledgeAI-Python-Client",
    "github_not_found": true,
    "lcname": "knowledgeai-client"
}
        
Elapsed time: 0.24610s