Skip to main content

Install

pip install moorcheh-edge

Two ways to use the package

ApproachWhen to use
MoorchehEdge SDKStart Docker + call API from Python (embeds text locally)
MoorchehEdgeApiClientTalk to an already running server (raw HTTP)

SDK example (text store)

from moorcheh_edge import MoorchehEdge

with MoorchehEdge(port=8080) as edge:
    print(edge.health())
    edge.upload_documents([{"id": "doc-1", "text": "Hello world"}])
    for hit in edge.search_text("Hello world", top_k=5):
        print(hit["id"], hit["score"])
    result = edge.answer_text("Who won the football match?", top_k=5)
    print(result["answer"])

HTTP client example

from moorcheh_edge import MoorchehEdgeApiClient

client = MoorchehEdgeApiClient("http://localhost:8080")
print(client.health())
client.upload({
    "store_mode": "vector",
    "items": [{"id": "a", "vector": [...]}],
})
print(client.search({"query": [...], "top_k": 5}))

Errors

Failed API calls raise MoorchehEdgeApiError with:
  • status_code
  • message
  • body - parsed JSON from the server when available
from moorcheh_edge import MoorchehEdgeApiError

try:
    client.upload({"store_mode": "vector", "items": [...]})
except MoorchehEdgeApiError as exc:
    if exc.is_item_limit_exceeded:
        print(exc.body)