|  |  | @ -118,179 +118,7 @@ agent.run("Generate a 10,000 word blog on health and wellness.") | 
			
		
	
		
		
			
				
					
					|  |  |  | import os |  |  |  | import os | 
			
		
	
		
		
			
				
					
					|  |  |  | from dotenv import load_dotenv |  |  |  | from dotenv import load_dotenv | 
			
		
	
		
		
			
				
					
					|  |  |  | from swarms import Agent, OpenAIChat |  |  |  | from swarms import Agent, OpenAIChat | 
			
		
	
		
		
			
				
					
					|  |  |  | from playground.memory.chromadb_example import ChromaDB |  |  |  | from swarms_memory import ChromaDB | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | import logging |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import os |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import uuid |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | from typing import Optional |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import chromadb |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | from swarms.utils.data_to_text import data_to_text |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | from swarms.utils.markdown_message import display_markdown_message |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | from swarms.memory.base_vectordb import BaseVectorDatabase |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | # Load environment variables |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | load_dotenv() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | # Results storage using local ChromaDB |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | class ChromaDB(BaseVectorDatabase): |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     ChromaDB database |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     Args: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         metric (str): The similarity metric to use. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         output (str): The name of the collection to store the results in. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         limit_tokens (int, optional): The maximum number of tokens to use for the query. Defaults to 1000. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         n_results (int, optional): The number of results to retrieve. Defaults to 2. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     Methods: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         add: _description_ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         query: _description_ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     Examples: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>> chromadb = ChromaDB( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>>     metric="cosine", |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>>     output="results", |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>>     llm="gpt3", |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>>     openai_api_key=OPENAI_API_KEY, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>> ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>> chromadb.add(task, result, result_id) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     def __init__( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         metric: str = "cosine", |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         output_dir: str = "swarms", |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         limit_tokens: Optional[int] = 1000, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         n_results: int = 3, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         docs_folder: str = None, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         verbose: bool = False, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     ): |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.metric = metric |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.output_dir = output_dir |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.limit_tokens = limit_tokens |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.n_results = n_results |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.docs_folder = docs_folder |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.verbose = verbose |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         # Disable ChromaDB logging |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         if verbose: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             logging.getLogger("chromadb").setLevel(logging.INFO) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         # Create Chroma collection |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         chroma_persist_dir = "chroma" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         chroma_client = chromadb.PersistentClient( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             settings=chromadb.config.Settings( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 persist_directory=chroma_persist_dir, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             ), |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         # Create ChromaDB client |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.client = chromadb.Client() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         # Create Chroma collection |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.collection = chroma_client.get_or_create_collection( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             name=output_dir, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             metadata={"hnsw:space": metric}, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         display_markdown_message( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             "ChromaDB collection created:" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             f" {self.collection.name} with metric: {self.metric} and" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             f" output directory: {self.output_dir}" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         # If docs |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         if docs_folder: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             display_markdown_message( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 f"Traversing directory: {docs_folder}" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             self.traverse_directory() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     def add( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         document: str, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     ): |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Add a document to the ChromaDB collection. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Args: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             document (str): The document to be added. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             condition (bool, optional): The condition to check before adding the document. Defaults to True. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Returns: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             str: The ID of the added document. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         try: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             doc_id = str(uuid.uuid4()) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             self.collection.add( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 ids=[doc_id], |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 documents=[document], |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             print("-----------------") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             print("Document added successfully") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             print("-----------------") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             return doc_id |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         except Exception as e: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             raise Exception(f"Failed to add document: {str(e)}") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     def query( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         query_text: str, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     ): |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Query documents from the ChromaDB collection. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Args: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             query (str): The query string. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             n_docs (int, optional): The number of documents to retrieve. Defaults to 1. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Returns: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             dict: The retrieved documents. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         try: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             docs = self.collection.query( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 query_texts=[query_text], |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 n_results=self.n_results, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             )["documents"] |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             return docs[0] |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         except Exception as e: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             raise Exception(f"Failed to query documents: {str(e)}") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     def traverse_directory(self): |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Traverse through every file in the given directory and its subdirectories, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         and return the paths of all files. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Parameters: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         - directory_name (str): The name of the directory to traverse. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Returns: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         - list: A list of paths to each file in the directory and its subdirectories. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         added_to_db = False |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         for root, dirs, files in os.walk(self.docs_folder): |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             for file in files: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 file_path = os.path.join(root, file)  # Change this line |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 _, ext = os.path.splitext(file_path) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 data = data_to_text(file_path) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 added_to_db = self.add(str(data)) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 print(f"{file_path} added to Database") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         return added_to_db |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | # Get the API key from the environment |  |  |  | # Get the API key from the environment | 
			
		
	
		
		
			
				
					
					|  |  |  | api_key = os.environ.get("OPENAI_API_KEY") |  |  |  | api_key = os.environ.get("OPENAI_API_KEY") | 
			
		
	
	
		
		
			
				
					|  |  | @ -334,218 +162,108 @@ An LLM equipped with long term memory and tools, a full stack agent capable of a | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | ```python |  |  |  | ```python | 
			
		
	
		
		
			
				
					
					|  |  |  | import logging |  |  |  | import logging | 
			
		
	
		
		
			
				
					
					|  |  |  | import os |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import uuid |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | from typing import Optional |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | import chromadb |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | from dotenv import load_dotenv |  |  |  | from dotenv import load_dotenv | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | from swarms.utils.data_to_text import data_to_text |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | from swarms.utils.markdown_message import display_markdown_message |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | from swarms.memory.base_vectordb import BaseVectorDatabase |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | from swarms import Agent, OpenAIChat |  |  |  | from swarms import Agent, OpenAIChat | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | import subprocess | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | # Making an instance of the ChromaDB class | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | memory = ChromaDB( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     metric="cosine", | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     n_results=3, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     output_dir="results", | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     docs_folder="docs", | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | # Load environment variables |  |  |  | # Tools | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | load_dotenv() |  |  |  | def terminal( | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     code: str, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | ): | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     """ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     Run code in the terminal. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     Args: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         code (str): The code to run in the terminal. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     Returns: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         str: The output of the code. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     """ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     out = subprocess.run( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         code, shell=True, capture_output=True, text=True | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     ).stdout | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     return str(out) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | def browser(query: str): | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     """ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     Search the query in the browser with the `browser` tool. | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     Args: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         query (str): The query to search in the browser. | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | # Results storage using local ChromaDB |  |  |  |     Returns: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | class ChromaDB(BaseVectorDatabase): |  |  |  |         str: The search results. | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     """ |  |  |  |     """ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     import webbrowser | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     url = f"https://www.google.com/search?q={query}" | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     webbrowser.open(url) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     return f"Searching for {query} in the browser." | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     ChromaDB database |  |  |  | def create_file(file_path: str, content: str): | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     """ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     Create a file using the file editor tool. | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     Args: |  |  |  |     Args: | 
			
		
	
		
		
			
				
					
					|  |  |  |         metric (str): The similarity metric to use. |  |  |  |         file_path (str): The path to the file. | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         output (str): The name of the collection to store the results in. |  |  |  |         content (str): The content to write to the file. | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         limit_tokens (int, optional): The maximum number of tokens to use for the query. Defaults to 1000. |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         n_results (int, optional): The number of results to retrieve. Defaults to 2. |  |  |  |     Returns: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |         str: The result of the file creation operation. | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     Methods: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         add: _description_ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         query: _description_ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     Examples: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>> chromadb = ChromaDB( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>>     metric="cosine", |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>>     output="results", |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>>     llm="gpt3", |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>>     openai_api_key=OPENAI_API_KEY, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>> ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         >>> chromadb.add(task, result, result_id) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     """ |  |  |  |     """ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     with open(file_path, "w") as file: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         file.write(content) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     return f"File {file_path} created successfully." | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     def __init__( |  |  |  | def file_editor(file_path: str, mode: str, content: str): | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         self, |  |  |  |     """ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         metric: str = "cosine", |  |  |  |     Edit a file using the file editor tool. | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         output_dir: str = "swarms", |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         limit_tokens: Optional[int] = 1000, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         n_results: int = 3, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         docs_folder: str = None, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         verbose: bool = False, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     ): |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.metric = metric |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.output_dir = output_dir |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.limit_tokens = limit_tokens |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.n_results = n_results |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.docs_folder = docs_folder |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.verbose = verbose |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         # Disable ChromaDB logging |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         if verbose: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             logging.getLogger("chromadb").setLevel(logging.INFO) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         # Create Chroma collection |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         chroma_persist_dir = "chroma" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         chroma_client = chromadb.PersistentClient( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             settings=chromadb.config.Settings( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 persist_directory=chroma_persist_dir, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             ), |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         # Create ChromaDB client |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.client = chromadb.Client() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         # Create Chroma collection |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self.collection = chroma_client.get_or_create_collection( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             name=output_dir, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             metadata={"hnsw:space": metric}, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         display_markdown_message( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             "ChromaDB collection created:" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             f" {self.collection.name} with metric: {self.metric} and" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             f" output directory: {self.output_dir}" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         # If docs |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         if docs_folder: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             display_markdown_message( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 f"Traversing directory: {docs_folder}" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             self.traverse_directory() |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     def add( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         document: str, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     ): |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Add a document to the ChromaDB collection. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Args: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             document (str): The document to be added. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             condition (bool, optional): The condition to check before adding the document. Defaults to True. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Returns: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             str: The ID of the added document. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         try: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             doc_id = str(uuid.uuid4()) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             self.collection.add( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 ids=[doc_id], |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 documents=[document], |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             ) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             print("-----------------") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             print("Document added successfully") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             print("-----------------") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             return doc_id |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         except Exception as e: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             raise Exception(f"Failed to add document: {str(e)}") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     def query( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         self, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         query_text: str, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     ): |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Query documents from the ChromaDB collection. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Args: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             query (str): The query string. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             n_docs (int, optional): The number of documents to retrieve. Defaults to 1. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Returns: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             dict: The retrieved documents. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         try: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             docs = self.collection.query( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 query_texts=[query_text], |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 n_results=self.n_results, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 *args, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 **kwargs, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             )["documents"] |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             return docs[0] |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         except Exception as e: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             raise Exception(f"Failed to query documents: {str(e)}") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     def traverse_directory(self): |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Traverse through every file in the given directory and its subdirectories, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         and return the paths of all files. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Parameters: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         - directory_name (str): The name of the directory to traverse. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         Returns: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         - list: A list of paths to each file in the directory and its subdirectories. |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         """ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         added_to_db = False |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         for root, dirs, files in os.walk(self.docs_folder): |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             for file in files: |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 file_path = os.path.join(root, file)  # Change this line |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 _, ext = os.path.splitext(file_path) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 data = data_to_text(file_path) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 added_to_db = self.add(str(data)) |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 print(f"{file_path} added to Database") |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         return added_to_db |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     Args: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         file_path (str): The path to the file. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         mode (str): The mode to open the file in. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         content (str): The content to write to the file. | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | # Making an instance of the ChromaDB class |  |  |  |     Returns: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | memory = ChromaDB( |  |  |  |         str: The result of the file editing operation. | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     metric="cosine", |  |  |  |     """ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     n_results=3, |  |  |  |     with open(file_path, mode) as file: | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     output_dir="results", |  |  |  |         file.write(content) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     docs_folder="docs", |  |  |  |     return f"File {file_path} edited successfully." | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | ) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | # Initialize a tool |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | def search_api(query: str): |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     # Add your logic here |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     return query |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | # Initializing the agent with the Gemini instance and other parameters |  |  |  | # Agent | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | agent = Agent( |  |  |  | agent = Agent( | 
			
		
	
		
		
			
				
					
					|  |  |  |     agent_name="Covid-19-Chat", |  |  |  |     agent_name="Devin", | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     agent_description=( |  |  |  |     system_prompt=( | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         "This agent provides information about COVID-19 symptoms." |  |  |  |         "Autonomous agent that can interact with humans and other" | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         " agents. Be Helpful and Kind. Use the tools provided to" | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         " assist the user. Return all code in markdown format." | 
			
		
	
		
		
			
				
					
					|  |  |  |     ), |  |  |  |     ), | 
			
		
	
		
		
			
				
					
					|  |  |  |     llm=OpenAIChat(), |  |  |  |     llm=llm, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     max_loops="auto", |  |  |  |     max_loops="auto", | 
			
		
	
		
		
			
				
					
					|  |  |  |     autosave=True, |  |  |  |     autosave=True, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     dashboard=False, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     streaming_on=True, | 
			
		
	
		
		
			
				
					
					|  |  |  |     verbose=True, |  |  |  |     verbose=True, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     stopping_token="<DONE>", | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     interactive=True, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     tools=[terminal, browser, file_editor, create_file], | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     code_interpreter=True, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     # streaming=True, | 
			
		
	
		
		
			
				
					
					|  |  |  |     long_term_memory=memory, |  |  |  |     long_term_memory=memory, | 
			
		
	
		
		
			
				
					
					|  |  |  |     stopping_condition="finish", |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     tools=[search_api], |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | ) |  |  |  | ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | # Defining the task and image path |  |  |  | # Run the agent | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | task = ("What are the symptoms of COVID-19?",) |  |  |  | out = agent("Create a new file for a plan to take over the world.") | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | # Running the agent with the specified task and image |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | out = agent.run(task) |  |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  | print(out) |  |  |  | print(out) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | ``` |  |  |  | ``` | 
			
		
	
	
		
		
			
				
					|  |  | 
 |