Document Ingestion
Document Retrieval
Data Organization
Document Updates
Batch Operations
Knowledge Graph Operations
Cache Management
Client
close
Close the HTTP session or client
def close() -> None
def close() -> None
async def close() -> None
Parameters
None
Returns
None
Examples
from morphik import Morphik
db = Morphik()
# Perform operations
doc = db.ingest_text("Sample content")
# Close the session when done
db.close()
from morphik import Morphik
db = Morphik()
# Perform operations
doc = db.ingest_text("Sample content")
# Close the session when done
db.close()
import asyncio
from morphik import AsyncMorphik
async def main():
db = AsyncMorphik()
# Perform operations
doc = await db.ingest_text("Sample content")
# Close the client when done
await db.close()
asyncio.run(main())
Context Manager Alternative
Instead of manually calling close()
, you can use the Morphik client as a context manager:
from morphik import Morphik
with Morphik() as db:
doc = db.ingest_text("Sample content")
# Session is automatically closed when exiting the with block
from morphik import Morphik
with Morphik() as db:
doc = db.ingest_text("Sample content")
# Session is automatically closed when exiting the with block
from morphik import AsyncMorphik
async with AsyncMorphik() as db:
doc = await db.ingest_text("Sample content")
# Client is automatically closed when exiting the with block
Was this page helpful?