Content-Length: 4464233 | pFad | https://docs.agno.com/llms-full.txt
e # AgentUI Source: https://docs.agno.com/agent-os/agent-ui An Open Source AgentUI for your AgentOSCassandra also supports asynchronous operations, enabling concurrency and leading to better performance.
```python async_cassandra.py theme={null} import asyncio from agno.agent import Agent from agno.knowledge.embedder.mistral import MistralEmbedder from agno.knowledge.knowledge import Knowledge from agno.models.mistral import MistralChat from agno.vectordb.cassandra import Cassandra try: from cassandra.cluster import Cluster # type: ignore except (ImportError, ModuleNotFoundError): raise ImportError( "Could not import cassandra-driver python package.Please install it with pip install cassandra-driver." ) cluster = Cluster() session = cluster.connect() session.execute( """ CREATE KEYSPACE IF NOT EXISTS testkeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 } """ ) knowledge_base = Knowledge( vector_db=Cassandra( table_name="recipes", keyspace="testkeyspace", session=session, embedder=MistralEmbedder(), ), ) agent = Agent( model=MistralChat(), knowledge=knowledge_base, ) if __name__ == "__main__": asyncio.run(knowledge_base.add_content_async( url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf", ) ) # Create and use the agent asyncio.run( agent.aprint_response( "What are the health benefits of Khao Niew Dam Piek Maphrao Awn?", markdown=True, ) ) ```aload()
and aprint\_response()
methods with asyncio.run()
for non-blocking operations in high-throughput applications.
ChromaDB also supports asynchronous operations, enabling concurrency and leading to better performance.
```python async_chroma_db.py theme={null} # install chromadb - `pip install chromadb` import asyncio from agno.agent import Agent from agno.knowledge.knowledge import Knowledge from agno.vectordb.chroma import ChromaDb # Initialize ChromaDB vector_db = ChromaDb(collection="recipes", path="tmp/chromadb", persistent_client=True) # Create knowledge base knowledge = Knowledge( vector_db=vector_db, ) # Create and use the agent agent = Agent(knowledge=knowledge) if __name__ == "__main__": # Comment out after first run asyncio.run( knowledge.add_content_async(url="https://docs.agno.com/introduction/agents.md") ) # Create and use the agent asyncio.run( agent.aprint_response("What is the purpose of an Agno Agent?", markdown=True) ) ```add\_content\_async()
and aprint\_response()
methods with asyncio.run()
for non-blocking operations in high-throughput applications.
Clickhouse also supports asynchronous operations, enabling concurrency and leading to better performance.
```python async_clickhouse.py theme={null} import asyncio from agno.agent import Agent from agno.knowledge.knowledge import Knowledge from agno.db.sqlite import SqliteDb from agno.vectordb.clickhouse import Clickhouse agent = Agent( db=SqliteDb(db_file="agno.db"), knowledge=Knowledge( vector_db=Clickhouse( table_name="recipe_documents", host="localhost", port=8123, username="ai", password="ai", ), ), # Enable the agent to search the knowledge base search_knowledge=True, # Enable the agent to read the chat history read_chat_history=True, ) if __name__ == "__main__": # Comment out after first run asyncio.run(agent.knowledge.add_content_async( url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf" ) ) # Create and use the agent asyncio.run(agent.aprint_response("How to make Tom Kha Gai", markdown=True)) ```aload()
and aprint\_response()
methods with asyncio.run()
for non-blocking operations in high-throughput applications.
Couchbase also supports asynchronous operations, enabling concurrency and leading to better performance.
```python async_couchbase.py theme={null} import asyncio import os import time from agno.agent import Agent from agno.knowledge.embedder.openai import OpenAIEmbedder from agno.knowledge.knowledge import Knowledge from agno.vectordb.couchbase import CouchbaseSearch from couchbase.options import ClusterOptions, KnownConfigProfiles from couchbase.auth import PasswordAuthenticator from couchbase.management.search import SearchIndex # Couchbase connection settings username = os.getenv("COUCHBASE_USER") password = os.getenv("COUCHBASE_PASSWORD") connection_string = os.getenv("COUCHBASE_CONNECTION_STRING") # Create cluster options with authentication auth = PasswordAuthenticator(username, password) cluster_options = ClusterOptions(auth) cluster_options.apply_profile(KnownConfigProfiles.WanDevelopment) knowledge_base = Knowledge( vector_db=CouchbaseSearch( bucket_name="recipe_bucket", scope_name="recipe_scope", collection_name="recipes", couchbase_connection_string=connection_string, cluster_options=cluster_options, search_index="vector_search_fts_index", embedder=OpenAIEmbedder( id="text-embedding-3-large", dimensions=3072, api_key=os.getenv("OPENAI_API_KEY") ), wait_until_index_ready=60, overwrite=True ), ) # Create and use the agent agent = Agent(knowledge=knowledge_base) async def run_agent(): await knowledge_base.add_content_async( url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf", ) time.sleep(5) # Wait for the vector index to sync with KV await agent.aprint_response("How to make Thai curry?", markdown=True) if __name__ == "__main__": asyncio.run(run_agent()) ```aload()
and aprint\_response()
methods with asyncio.run()
for non-blocking operations in high-throughput applications.
LanceDB also supports asynchronous operations, enabling concurrency and leading to better performance.
```python async_lance_db.py theme={null} # install lancedb - `pip install lancedb` import asyncio from agno.agent import Agent from agno.knowledge.knowledge import Knowledge from agno.vectordb.lancedb import LanceDb # Initialize LanceDB vector_db = LanceDb( table_name="recipes", uri="tmp/lancedb", # You can change this path to store data elsewhere ) # Create knowledge base knowledge_base = Knowledge( vector_db=vector_db, ) agent = Agent(knowledge=knowledge_base, debug_mode=True) if __name__ == "__main__": # Load knowledge base asynchronously asyncio.run(knowledge_base.add_content_async( url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf" ) ) # Create and use the agent asynchronously asyncio.run(agent.aprint_response("How to make Tom Kha Gai", markdown=True)) ```aload()
and aprint\_response()
methods with asyncio.run()
for non-blocking operations in high-throughput applications.
Milvus also supports asynchronous operations, enabling concurrency and leading to better performance.
```python async_milvus_db.py theme={null} # install pymilvus - `pip install pymilvus` import asyncio from agno.agent import Agent from agno.knowledge.knowledge import Knowledge from agno.vectordb.milvus import Milvus # Initialize Milvus with local file vector_db = Milvus( collection="recipes", uri="tmp/milvus.db", # For local file-based storage ) # Create knowledge base knowledge_base = Knowledge( vector_db=vector_db, ) # Create agent with knowledge base agent = Agent(knowledge=knowledge_base) if __name__ == "__main__": # Load knowledge base asynchronously asyncio.run(knowledge_base.add_content_async( url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf" ) ) # Query the agent asynchronously asyncio.run(agent.aprint_response("How to make Tom Kha Gai", markdown=True)) ```aload()
and aprint\_response()
methods with asyncio.run()
for non-blocking operations in high-throughput applications.
MongoDB also supports asynchronous operations, enabling concurrency and leading to better performance.
```python async_mongodb.py theme={null} import asyncio from agno.agent import Agent from agno.knowledge.knowledge import Knowledge from agno.vectordb.mongodb import MongoDb # MongoDB Atlas connection string """ Example connection strings: "mongodb+srv://aload()
and aprint\_response()
methods with asyncio.run()
for non-blocking operations in high-throughput applications.
Several vector databases support asynchronous operations, offering improved performance through non-blocking operations, concurrent processing, reduced latency, and seamless integration with FastAPI and async agents.
aload
methods for async knowledge base loading in production environments.
PgVector also supports asynchronous operations, enabling concurrency and leading to better performance.
```python async_pgvector.py theme={null} import asyncio from agno.agent import Agent from agno.knowledge.knowledge import Knowledge from agno.vectordb.pgvector import PgVector db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai" vector_db = PgVector(table_name="recipes", db_url=db_url) knowledge_base = Knowledge( vector_db=vector_db, ) agent = Agent(knowledge=knowledge_base) if __name__ == "__main__": # Load knowledge base asynchronously asyncio.run(knowledge_base.add_content_async( url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf" ) ) # Create and use the agent asynchronously asyncio.run(agent.aprint_response("How to make Tom Kha Gai", markdown=True)) ```aload()
and aprint\_response()
methods with asyncio.run()
for non-blocking operations in high-throughput applications.
Pinecone also supports asynchronous operations, enabling concurrency and leading to better performance.
```python async_pinecone.py theme={null} import asyncio from os import getenv from agno.agent import Agent from agno.knowledge.knowledge import Knowledge from agno.vectordb.pineconedb import PineconeDb api_key = getenv("PINECONE_API_KEY") index_name = "thai-recipe-index" vector_db = PineconeDb( name=index_name, dimension=1536, metric="cosine", spec={"serverless": {"cloud": "aws", "region": "us-east-1"}}, api_key=api_key, ) knowledge_base = Knowledge( vector_db=vector_db, ) agent = Agent( knowledge=knowledge_base, # Enable the agent to search the knowledge base search_knowledge=True, # Enable the agent to read the chat history read_chat_history=True, ) if __name__ == "__main__": # Load knowledge base asynchronously asyncio.run(knowledge_base.add_content_async( url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf" ) ) # Create and use the agent asynchronously asyncio.run(agent.aprint_response("How to make Tom Kha Gai", markdown=True)) ```aload()
and aprint\_response()
methods with asyncio.run()
for non-blocking operations in high-throughput applications.
Qdrant also supports asynchronous operations, enabling concurrency and leading to better performance.
```python async_qdrant_db.py theme={null} import asyncio from agno.agent import Agent from agno.knowledge.knowledge import Knowledge from agno.vectordb.qdrant import Qdrant COLLECTION_NAME = "thai-recipes" # Initialize Qdrant with local instance vector_db = Qdrant( collection=COLLECTION_NAME, url="http://localhost:6333" ) # Create knowledge base knowledge_base = Knowledge( vector_db=vector_db, ) agent = Agent(knowledge=knowledge_base) if __name__ == "__main__": # Load knowledge base asynchronously asyncio.run(knowledge_base.add_content_async( url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf" ) ) # Create and use the agent asynchronously asyncio.run(agent.aprint_response("How to make Tom Kha Gai", markdown=True)) ```aload()
and aprint\_response()
with asyncio provides non-blocking operations, making your application more responsive under load.
SurrealDB also supports asynchronous operations, enabling concurrency and leading to better performance.
```python async_surrealdb_db.py theme={null} import asyncio from agno.agent import Agent from agno.knowledge.embedder.openai import OpenAIEmbedder from agno.knowledge.knowledge import Knowledge from agno.vectordb.surrealdb import SurrealDb from surrealdb import AsyncSurreal # SurrealDB connection parameters SURREALDB_URL = "ws://localhost:8000" SURREALDB_USER = "root" SURREALDB_PASSWORD = "root" SURREALDB_NAMESPACE = "test" SURREALDB_DATABASE = "test" # Create a client client = AsyncSurreal(url=SURREALDB_URL) surrealdb = SurrealDb( async_client=client, collection="recipes", # Collection name for storing documents efc=150, # HNSW construction time/accuracy trade-off m=12, # HNSW max number of connections per element search_ef=40, # HNSW search time/accuracy trade-off ) async def async_demo(): """Demonstrate asynchronous usage of SurrealDb""" await client.signin({"username": SURREALDB_USER, "password": SURREALDB_PASSWORD}) await client.use(namespace=SURREALDB_NAMESPACE, database=SURREALDB_DATABASE) knowledge_base = Knowledge( vector_db=surrealdb, embedder=OpenAIEmbedder(), ) await knowledge_base.add_content_async( url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf" ) agent = Agent(knowledge=knowledge_base) await agent.aprint_response( "What are the 3 categories of Thai SELECT is given to restaurants overseas?", markdown=True, ) if __name__ == "__main__": # Run asynchronous demo print("\nRunning asynchronous demo...") asyncio.run(async_demo()) ```aload()
and aprint\_response()
with asyncio provides non-blocking operations, making your application more responsive under load.
Weaviate also supports asynchronous operations, enabling concurrency and leading to better performance.
```python async_weaviate_db.py theme={null} import asyncio from agno.agent import Agent from agno.knowledge.knowledge import Knowledge from agno.vectordb.search import SearchType from agno.vectordb.weaviate import Distance, VectorIndex, Weaviate vector_db = Weaviate( collection="recipes_async", search_type=SearchType.hybrid, vector_index=VectorIndex.HNSW, distance=Distance.COSINE, local=True, # Set to False if using Weaviate Cloud and True if using local instance ) # Create knowledge base knowledge_base = Knowledge( vector_db=vector_db, ) agent = Agent( knowledge=knowledge_base, search_knowledge=True, ) if __name__ == "__main__": # Load knowledge base asynchronously asyncio.run(knowledge_base.add_content_async( url="https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf" ) ) # Create and use the agent asynchronously asyncio.run(agent.aprint_response("How to make Tom Kha Gai", markdown=True)) ```WeaviateAsyncClient
to provide non-blocking vector operations. This is particularly valuable for applications requiring high concurrency and throughput.
Fetched URL: https://docs.agno.com/llms-full.txt
Alternative Proxies: