print(f"Ingested document with ID: {doc.external_id}")
# Create a cache
print("\nCreating cache...")
cache_result=db.create_cache(
name="ai_overview_cache",
model="llama2",
gguf_file="llama-2-7b-chat.Q4_K_M.gguf",
docs=[doc.external_id]# Include our document in the cache
)
print("Cache created successfully")
# Get a reference to the cache
cache=db.get_cache("ai_overview_cache")
# Update the cache to process documents
print("Updating cache...")
cache.update()
print("Cache updated")
# Query the cache directly
print("\nQuerying the cache...")
response=cache.query(
"What are the different types of artificial intelligence?",
max_tokens=200,
temperature=0.7
)
print("Response from cache:")
print(response.completion)
# Add more documents to the cache (if needed)
additional_doc=db.ingest_text(
"Reinforcement learning is a type of machine learning where an agent learns to make decisions by taking actions in an environment to maximize rewards.",