Metadata-Version: 2.4
Name: sciborg-async
Version: 1.0.0
Summary: SciBORG: A framework for building agents that automate scientific discovery
Author-email: Chopra Lab - Atharva Parikh and Matthew Muhoberac <chopralab@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/chopralab/sciborg
Project-URL: Documentation, https://github.com/chopralab/sciborg#readme
Project-URL: Repository, https://github.com/chopralab/sciborg
Project-URL: Issues, https://github.com/chopralab/sciborg/issues
Keywords: ai,agents,scientific-discovery,langchain,automation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: langchain>=1.0.5
Requires-Dist: langchain-classic>=1.0.0
Requires-Dist: langchain-community>=0.4.1
Requires-Dist: langchain-core>=1.0.4
Requires-Dist: langchain-openai>=1.0.2
Requires-Dist: langchain-text-splitters>=1.0.0
Requires-Dist: langsmith>=0.3.33
Requires-Dist: pydantic>=2.12.4
Requires-Dist: pydantic-core>=2.41.0
Requires-Dist: numpy>=2.3.4
Requires-Dist: typing-extensions>=4.13.2
Requires-Dist: setuptools>=75.1.0
Requires-Dist: protobuf>=6.30.2
Requires-Dist: pandas>=2.3.3
Requires-Dist: requests>=2.32.5
Requires-Dist: beautifulsoup4>=4.14.2
Requires-Dist: faiss-cpu>=1.12.0
Requires-Dist: sentence-transformers>=5.1.2
Requires-Dist: torch>=2.9.0
Requires-Dist: transformers>=4.57.1
Requires-Dist: pymupdf>=1.26.6
Requires-Dist: pdf2image>=1.17.0
Requires-Dist: pdfplumber>=0.11.8
Requires-Dist: pytesseract>=0.3.13
Requires-Dist: Pillow>=11.2.1
Requires-Dist: matplotlib>=3.10.1
Requires-Dist: networkx>=3.4.2
Requires-Dist: tqdm>=4.67.1
Requires-Dist: python-dotenv>=1.0.1
Requires-Dist: nest-asyncio>=1.6.0
Requires-Dist: tiktoken>=0.8.0
Requires-Dist: tenacity>=9.0.0
Requires-Dist: psutil>=6.0.0
Requires-Dist: spython>=0.3.14
Requires-Dist: PyJWT>=2.10.1
Provides-Extra: dev
Requires-Dist: pytest>=8.3.2; extra == "dev"
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
Dynamic: license-file

# SciBORG

<img src="images/SciBORG Logo.png" alt="SciBORG Banner Image" width="" height="150">

SciBORG is an innovative framework designed for building agents that can rapidly automate scientific discovery. It's built to be modular, extensible, and easy to integrate with new components and agents, making it suitable for diverse research domains. 

This framework allows for smooth integration of various AI agents, each customizable to specific tasks, making it ideal for research labs, academic institutions, and organizations focusing on scientific discovery. By leveraging SciBORG, teams can automate complex workflows, empowering researchers to focus on innovative thinking and problem-solving.

Task:(some tracking tags go here)

<h3>Key Features</h3>

- Modular Design: Easily add, replace, or upgrade agents as per project needs.
- Extensible Framework: Integrate new components effortlessly.
- Agent Library: Ready-to-use agents like the RAG agent, which supports retrieval-augmented generation for scientific Q&A tasks.
- Benchmarking and Testing: Built-in benchmarking tools to ensure reliability and effectiveness of each agent.

## Quick Start Guide

### Pre-requisites
For compatibility, it's recommended to use a virtual environment with Python 3.10. Follow these steps to set it up:
```shell
python3.10 -m venv sciborg-env
source sciborg-env/bin/activate
```

### Installation
To install the SciBORG agent, clone the repository and install the dependencies using the following commands:
```shell
git clone https://github.com/chopralab/sciborg.git
cd sciborg
pip install -r requirements.txt
```

### Testing the Installation
Test the installation by running the following command:
```python
import os
os.environ['OPENAI_API_KEY'] = "<YOUR_API_KEY_HERE>"

import sys
sys.path.insert(1, "path to the parent of this folder") 

from langchain_openai import ChatOpenAI
from sciborg.ai.agents.core import create_sciborg_chat_agent
from sciborg.ai.chains.microservice import module_to_microservice
from sciborg.ai.chains.workflow import create_workflow_planner_chain, create_workflow_constructor_chain

from sciborg.utils.drivers import MicrowaveSynthesizer, MicrowaveSynthesizerObject, PubChemCaller
from sciborg.core.library.base import BaseDriverMicroservice
```
If the above command runs without any errors, the installation was successful and the SciBORG agent is ready to use.

### Directory Structure
If the installation was successful, the directory structure should look like this:
```
sciborg/
  sciborg/          # Main package (installed via pip)
    ai/             # AI agents, chains, memory, prompts, schema, tools
    core/           # Core infrastructure (commands, library, parameters, workflows)
    utils/          # Utilities (benchmarking, example drivers)
    embeddings/     # Embeddings data
  notebooks/        # Example notebooks (not in package)
  tests/            # Test suite (not in package)
  README.md
  requirements.txt
  pyproject.toml
```

#### Directory Structure Explanation:

- `sciborg/ai/`: Contains implementations of various AI agents that drive SciBORG's functionality, including the RAG agent and other pre-built agents.
- `sciborg/core/`: The core logic and infrastructure that powers SciBORG, including utilities for agent management, execution, and task orchestration.
- `sciborg/embeddings/`: Stores embeddings data used for document similarity and context retrieval.
- `sciborg/utils/`: Utility scripts and helper functions that support various tasks across SciBORG, like benchmarking. Also contains example drivers in `sciborg/utils/drivers/`.
- `notebooks/`: Jupyter notebooks providing tutorials, demos, and examples for using SciBORG agents. This folder is highly recommended for new users to understand SciBORG's capabilities.
- `tests/`: All testing code including unit tests and integration tests.

## Creating Agents

### Making the microservice for the agents
#### Microwave Synthesizer microservice
```python
file_path = 'path_to_json/driver_MicroSynth.json'

driver_command_microservice = module_to_microservice(MicrowaveSynthesizer)

with open(file_path, 'w') as outfile:
    outfile.write(driver_command_microservice.model_dump_json(indent=2))
```
#### PubChem microservice
```python
file_path = 'path_to_json/driver_pubchem.json'

pubchem_command_microservice = module_to_microservice(PubChemCaller)

with open(file_path, 'w') as outfile:
    outfile.write(pubchem_command_microservice.model_dump_json(indent=2))
```

### RAG Agent

The RAG Agent (Retrieval-Augmented Generation) is used for answering scientific questions based on provided context. To use the RAG agent, run the following command:

```python
rag_agent = create_sciborg_chat_agent(
    microservice=driver_command_microservice,
    rag_vectordb_path = '<path>/embeddings/NIH_docs_embeddings',
    llm=ChatOpenAI(model='gpt-4'),
    human_interaction=False,
    verbose=True
)
```

### Pubchem Agent
```python
pubchem_agent = create_sciborg_chat_agent(
    microservice=pubchem_command_microservice,
    llm=ChatOpenAI(model='gpt-4'),
    human_interaction=False,
    verbose=True
)
```

### PubChem and RAG Agent
```python
pubchem_and_rag_agent = create_sciborg_chat_agent(
    microservice=pubchem_command_microservice,
    rag_vectordb_path = '<path>/embeddings/NIH_docs_embeddings',
    llm=ChatOpenAI(model='gpt-4'),
    human_interaction=False,
    verbose=True
)
```

What do these paramaters mean?
- `microservice`: The microservice that the agent will use to interact with external services or APIs.
- `rag_vectordb_path`: The path to the document embeddings used by the RAG agent for context retrieval.
- `llm`: The language model used by the agent for generating responses. In this case, it's the GPT-4 model.
- `human_interaction`: A boolean flag to enable or disable human interaction with the agent.

For detailed demonstrations and examples, refer to the Jupyter notebooks `notebooks/SI/SI_traces_01.ipynb` and `notebooks/SI/SI_traces_02.ipynb` in the repository.
Task: link the folder to the notebooks

## Benchmarking the Agents

SciBORG includes benchmarking scripts to evaluate the performance of each agent. There are three ways to benchmark the agents:
- State Based Benchmarking
- Path Based Benchmarking
- RegEx Based Benchmarking

For additional details on benchmarking and usage, refer to the `notebooks/SI/SI_benchmarks_01.ipynb`, `notebooks/SI/SI_benchmarks_02.ipynb` and `notebooks/SI/SI_benchmarks_03.ipynb` notebooks.
Task: link the folder to the notebooks

## Additional Resources (adding soon...)
Explore additional details on extending SciBORG's functionality with custom integrations:
- Creating Custom Integrations: Learn how to add new agents to SciBORG, configure workflows, and customize agents for specific needs. (add in readme file to help do this)
- Adding Custom Document Embeddings: Understand how to integrate different embeddings for specialized document types or formats. (add in a readme file and a code file to help do this)
