The Document class provides methods for creating, retrieving, updating, and deleting documents. Documents can be embedded for use with the retrieval system and can be created from existing ESS or Sequence objects.
Returns a tuple of (DocumentResponse | Error, status_code)
Example:
res, status = eca.document.create_from_sequence( module_id="air_conditioner", sequence_id=4)if status == 201: print(f"Created document from sequence: {res.doc_id}")
import osfrom avenieca.api.eca import ECAfrom avenieca.api.model import Config, DocumentInsert# Initialize clientconfig = Config( uri="http://localhost:2580/v1", username=os.getenv("USERNAME"), password=os.getenv("PASSWORD"))eca = ECA(config)# Create a documentdocument = DocumentInsert( doc_id="user_guide_001", text="This is a comprehensive guide on using the air conditioner system.", embed=False # We'll embed it separately)res, status = eca.document.create(data=document)print(f"Created document with DB ID: {res.id}")# Embed the documentembed_res, embed_status = eca.document.embed(db_id=res.id)print(f"Document embedding status: {embed_res.status}")# Retrieve the documentget_res, get_status = eca.document.get_one(db_id=res.id)print(f"Retrieved document: {get_res.doc_id}")# Update the documentupdated_doc = DocumentInsert( doc_id="user_guide_001", text="This is an updated comprehensive guide on using the air conditioner system.", embed=True)update_res, update_status = eca.document.update( db_id=res.id, data=updated_doc)print(f"Updated document: {update_res.doc_id}")# List all documentsall_docs, all_status = eca.document.get_all()print(f"\nTotal documents: {len(all_docs)}")for doc in all_docs: print(f" - {doc.doc_id}: {doc.text[:40]}...")