import os
from avenieca.api.eca import ECA
from avenieca.api.model import Config, DocumentInsert
# Initialize client
config = Config(
uri="http://localhost:2580/v1",
username=os.getenv("USERNAME"),
password=os.getenv("PASSWORD")
)
eca = ECA(config)
# Create a document with auto-embedding
document = DocumentInsert(
doc_id="weather_001",
text="The temperature on May 3rd at 1pm was 28 degrees Celsius.",
embed=True
)
res, status = eca.document.create(data=document)
if status == 201:
doc_id = res.id
print(f"Created document {doc_id}")
print(f"Status: {res.status}")
# Get the document
res, status = eca.document.get_one(db_id=doc_id)
print(f"Retrieved: {res.text}")
# Update the document
updated = DocumentInsert(
doc_id="weather_001",
text="The temperature on May 3rd at 1pm was 29 degrees Celsius.",
embed=False
)
res, status = eca.document.update(db_id=doc_id, data=updated)
print(f"Updated: {res.text}")
# Re-embed after update
res, status = eca.document.embed(db_id=doc_id)
print(f"Re-embedded: {res.status}")
# Get all documents
res, status = eca.document.get_all()
print(f"Total documents: {len(res)}")