Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging

from .knowledge_base import KnowledgeBase

__version__ = "0.1.0a0"

_handler = logging.StreamHandler()
Expand Down
102 changes: 90 additions & 12 deletions src/ke/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,100 @@ class HandleRequest(BaseModel):


class ClientProtocol(Protocol):
def ke_is_available(self) -> bool: ...
def ke_version(self) -> str: ...
def get_knowledge_base(self, id: str) -> KnowledgeBaseInfo | None: ...
def get_all_knowledge_bases(self) -> list[KnowledgeBaseInfo]: ...
def register_kb(self, info: KnowledgeBaseInfo, reregister: bool = True) -> None: ...
def unregister_kb(self, id: str) -> None: ...
def get_knowledge_interactions(
self, kb_id: str
) -> list[KnowledgeInteractionInfo]: ...
"""Interface for communicating with a Knowledge Engine runtime."""

def ke_is_available(self) -> bool:
"""Return ``True`` if the KE runtime is reachable, ``False`` otherwise."""
...

def ke_version(self) -> str:
"""Return the version string of the KE runtime.

Raises:
UnexpectedHttpResponseError: If the KE runtime returns an unexpected HTTP
response.
"""
...

def get_knowledge_base(self, id: str) -> KnowledgeBaseInfo | None:
"""Return the KB with the given ID, or ``None`` if it does not exist.

Raises:
UnexpectedHttpResponseError: If the KE runtime returns an unexpected HTTP
response.
"""
...

def get_all_knowledge_bases(self) -> list[KnowledgeBaseInfo]:
"""Return all KBs registered at the KE runtime.

Raises:
UnexpectedHttpResponseError: If the KE runtime returns an unexpected HTTP
response.
"""
...

def register_kb(self, info: KnowledgeBaseInfo, reregister: bool = True) -> None:
"""Register a KB at the KE runtime, optionally re-registering if it already
exists.

Raises:
UnexpectedHttpResponseError: If the KE runtime returns an unexpected HTTP
response.
"""
...

def unregister_kb(self, id: str) -> None:
"""Unregister the KB with the given ID from the KE runtime.

Raises:
SmartConnectorNotFoundError: If no smart connector exists for the given KB
ID.
UnexpectedHttpResponseError: If the KE runtime returns an unexpected HTTP
response.
"""
...

def get_knowledge_interactions(self, kb_id: str) -> list[KnowledgeInteractionInfo]:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misschien get_all_knowledge_interactions noemen zodat de naming consistent is met de get_all_knowledge_bases

"""Return all knowledge interactions registered for the given KB.

Raises:
SmartConnectorNotFoundError: If no smart connector exists for the given KB
ID.
UnexpectedHttpResponseError: If the KE runtime returns an unexpected HTTP
response.
"""
...

def register_ki(
self, kb_id: str, ki: KnowledgeInteractionInfo
) -> KnowledgeInteractionInfo: ...
def poll_ki_call(self, kb_id: str) -> PollResult: ...
) -> KnowledgeInteractionInfo:
"""Register a knowledge interaction for the given KB and return it with its
assigned ID set in the info.

Raises:
SmartConnectorNotFoundError: If no smart connector exists for the given KB
ID.
UnexpectedHttpResponseError: If the KE runtime returns an unexpected HTTP
response.
"""
...

def poll_ki_call(self, kb_id: str) -> PollResult:
"""Poll the KE runtime for an incoming KI call for the given KB.

Raises:
SmartConnectorNotFoundError: If no smart connector exists for the given KB
ID.
UnexpectedHttpResponseError: If the KE runtime returns an unexpected HTTP
response.
"""
...


class Client(ClientProtocol):
"""HTTP client for the Knowledge Engine REST API."""

class Client:
def __init__(self, ke_url: str):
self.ke_url = ke_url

Expand Down
Loading
Loading