diff --git a/docs/swarms/structs/flow.md b/docs/swarms/structs/agent.md similarity index 100% rename from docs/swarms/structs/flow.md rename to docs/swarms/structs/agent.md diff --git a/mkdocs.yml b/mkdocs.yml index 216e4552..76cc4d80 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -96,7 +96,7 @@ nav: - swarms.structs: - Overview: "swarms/structs/overview.md" - AutoScaler: "swarms/swarms/autoscaler.md" - - Flow: "swarms/structs/flow.md" + - Agent: "swarms/structs/agent.md" - SequentialWorkflow: 'swarms/structs/sequential_workflow.md' - swarms.memory: - PineconeVectorStoreStore: "swarms/memory/pinecone.md" diff --git a/playground/demos/xray/xray.py b/playground/demos/xray/xray.py index 5c68bc18..20e89e6d 100644 --- a/playground/demos/xray/xray.py +++ b/playground/demos/xray/xray.py @@ -54,7 +54,7 @@ def generate_treatment_plan(diagnosis): xray_image_path = "playground/demos/xray/xray2.jpg" -# Diagnosis +# Diagnosis diagnosis = analyze_xray_agent.run( task="Analyze the following XRAY", img=xray_image_path ) diff --git a/swarms/memory/qdrant.py b/swarms/memory/qdrant.py index 1d2fe145..acac82f5 100644 --- a/swarms/memory/qdrant.py +++ b/swarms/memory/qdrant.py @@ -6,6 +6,23 @@ from qdrant_client.http.models import Distance, VectorParams, PointStruct class Qdrant: + """ + Qdrant class for managing collections and performing vector operations using QdrantClient. + + Attributes: + client (QdrantClient): The Qdrant client for interacting with the Qdrant server. + collection_name (str): Name of the collection to be managed in Qdrant. + model (SentenceTransformer): The model used for generating sentence embeddings. + + Args: + api_key (str): API key for authenticating with Qdrant. + host (str): Host address of the Qdrant server. + port (int): Port number of the Qdrant server. Defaults to 6333. + collection_name (str): Name of the collection to be used or created. Defaults to "qdrant". + model_name (str): Name of the model to be used for embeddings. Defaults to "BAAI/bge-small-en-v1.5". + https (bool): Flag to indicate if HTTPS should be used. Defaults to True. + """ + def __init__( self, api_key: str, @@ -15,22 +32,6 @@ class Qdrant: model_name: str = "BAAI/bge-small-en-v1.5", https: bool = True, ): - """ - Qdrant class for managing collections and performing vector operations using QdrantClient. - - Attributes: - client (QdrantClient): The Qdrant client for interacting with the Qdrant server. - collection_name (str): Name of the collection to be managed in Qdrant. - model (SentenceTransformer): The model used for generating sentence embeddings. - - Args: - api_key (str): API key for authenticating with Qdrant. - host (str): Host address of the Qdrant server. - port (int): Port number of the Qdrant server. Defaults to 6333. - collection_name (str): Name of the collection to be used or created. Defaults to "qdrant". - model_name (str): Name of the model to be used for embeddings. Defaults to "BAAI/bge-small-en-v1.5". - https (bool): Flag to indicate if HTTPS should be used. Defaults to True. - """ try: self.client = QdrantClient(url=host, port=port, api_key=api_key) self.collection_name = collection_name diff --git a/swarms/structs/agent.py b/swarms/structs/agent.py index a311cfe2..3ce16e18 100644 --- a/swarms/structs/agent.py +++ b/swarms/structs/agent.py @@ -15,6 +15,7 @@ from swarms.utils.parse_code import extract_code_in_backticks_in_string from swarms.prompts.multi_modal_autonomous_instruction_prompt import ( MULTI_MODAL_AUTO_AGENT_SYSTEM_PROMPT_1, ) +from swarms.utils.pdf_to_text import pdf_to_text # System prompt FLOW_SYSTEM_PROMPT = f""" @@ -252,6 +253,10 @@ class Agent: self_healing_enabled: Optional[bool] = False, code_interpreter: Optional[bool] = False, multi_modal: Optional[bool] = None, + pdf_path: Optional[str] = None, + list_of_pdf: Optional[str] = None, + tokenizer: Optional[str] = None, + *args, **kwargs: Any, ): self.llm = llm @@ -282,6 +287,9 @@ class Agent: self.self_healing_enabled = self_healing_enabled self.code_interpreter = code_interpreter self.multi_modal = multi_modal + self.pdf_path = pdf_path + self.list_of_pdf = list_of_pdf + self.tokenizer = tokenizer # The max_loops will be set dynamically if the dynamic_loop if self.dynamic_loops: @@ -351,10 +359,6 @@ class Agent: return "\n".join(params_str_list) - # def parse_tool_command(self, text: str): - # # Parse the text for tool usage - # pass - def get_tool_description(self): """Get the tool description""" if self.tools: @@ -1111,6 +1115,31 @@ class Agent: run_code = self.code_executor.run(parsed_code) return run_code + def pdf_connector(self, pdf: str = None): + """Transforms the pdf into text + + Args: + pdf (str, optional): _description_. Defaults to None. + + Returns: + _type_: _description_ + """ + pdf = pdf or self.pdf_path + text = pdf_to_text(pdf) + return text + + def pdf_chunker(self, text: str = None): + """Chunk the pdf into sentences + + Args: + text (str, optional): _description_. Defaults to None. + + Returns: + _type_: _description_ + """ + text = text or self.pdf_connector() + pass + def tools_prompt_prep(self, docs: str = None, scenarios: str = None): """ Prepare the tool prompt