Metadata-Version: 2.4
Name: resynth
Version: 0.1.2
Summary: Research Paper Synthesis Agent - Fetch, process, and query academic papers with AI-powered answers
Author-email: ReSynth Team <norizzabhii@gmail.com>
Maintainer-email: ReSynth Team <norizzabhii@gmail.com>
License: MIT License
        
        Copyright (c) 2024 ReSynth Team
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/resynth-ai/resynth
Project-URL: Documentation, https://github.com/resynth-ai/resynth/blob/main/README.md
Project-URL: Repository, https://github.com/resynth-ai/resynth
Project-URL: Bug Tracker, https://github.com/resynth-ai/resynth/issues
Project-URL: Changelog, https://github.com/resynth-ai/resynth/blob/main/CHANGELOG.md
Keywords: research papers,academic literature,machine learning,natural language processing,question answering,information retrieval,arxiv,pubmed,embeddings,vector database,citation generation,paper synthesis
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Education
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi>=0.104.0
Requires-Dist: uvicorn[standard]>=0.24.0
Requires-Dist: streamlit>=1.28.0
Requires-Dist: requests>=2.31.0
Requires-Dist: arxiv>=1.4.0
Requires-Dist: PyPDF2>=3.0.0
Requires-Dist: sentence-transformers>=2.2.0
Requires-Dist: chromadb>=0.4.0
Requires-Dist: openai>=1.0.0
Requires-Dist: python-dotenv>=1.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: scikit-learn>=1.3.0
Requires-Dist: nltk>=3.8.0
Requires-Dist: spacy>=3.7.0
Requires-Dist: beautifulsoup4>=4.12.0
Requires-Dist: biopython>=1.81.0
Requires-Dist: tqdm>=4.66.0
Requires-Dist: pandas>=2.0.0
Requires-Dist: plotly>=5.17.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=22.0.0; extra == "dev"
Requires-Dist: flake8>=5.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: isort>=5.10.0; extra == "dev"
Requires-Dist: pre-commit>=2.20.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=5.0.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
Requires-Dist: myst-parser>=0.18.0; extra == "docs"
Dynamic: license-file

# ReSynth - Research Paper Synthesis Agent

[![PyPI version](https://badge.fury.io/py/resynth.svg)](https://badge.fury.io/py/resynth)
[![Python versions](https://img.shields.io/pypi/pyversions/resynth)](https://pypi.org/project/resynth/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Tests](https://github.com/resynth-ai/resynth/workflows/Tests/badge.svg)](https://github.com/resynth-ai/resynth/actions)

**ReSynth** is an intelligent agent that fetches research papers, processes them through advanced chunking and embedding, and answers queries with proper academic citations. Perfect for researchers, students, and anyone working with academic literature.

## Features

- **Multi-Source Paper Fetching**: Retrieve papers from arXiv, PubMed, and more
- **Intelligent Processing**: Advanced text chunking with semantic boundaries
- **Vector Storage**: Efficient storage and retrieval with ChromaDB
- **AI-Powered Answers**: Synthesize responses using OpenAI or local models
- **Citation Management**: Automatic citation generation in multiple styles (APA, MLA, numeric)
- **Multiple Interfaces**: Web UI, REST API, and command-line interface
- **Quality Metrics**: Retrieval quality validation and confidence scoring

## Quick Start

### Installation

```bash
# Install from PyPI
pip install resynth

# Or install with development dependencies
pip install resynth[dev]
```

### Basic Usage

```python
import resynth

# Initialize the agent
agent = resynth.ReSynthAgent()

# Search and process papers
papers = agent.search_and_process(
    query="machine learning interpretability",
    source="arxiv",
    max_papers=5
)

# Query the processed papers
answer = agent.query(
    "What are the main challenges in deep learning interpretability?",
    citation_style="apa"
)

print(answer.answer)
print(answer.bibliography)
```

### Command Line Interface

```bash
# Search and process papers
resynth --search "transformer architectures" --max-papers 5

# Query processed papers
resynth --query "How do attention mechanisms work?" --citation-style numeric

# Show system statistics
resynth --stats
```

### Web Interface

```bash
# Start the web interface
resynth-web

# Or use streamlit directly
streamlit run resynth.web
```

### API Server

```bash
# Start the API server
resynth-api

# Then access the API at http://localhost:8000
# Interactive docs at http://localhost:8000/docs
```

## Requirements

- Python 3.8+
- Optional: OpenAI API key for enhanced answer synthesis
- Optional: spaCy model (`python -m spacy download en_core_web_sm`)

## Configuration

Create a `.env` file:

```bash
cp .env.example .env
# Edit .env with your configuration
```

Key configuration options:

```bash
# OpenAI API Key (optional, for enhanced synthesis)
OPENAI_API_KEY=your_openai_api_key_here

# Vector database settings
CHROMA_PERSIST_DIRECTORY=./chroma_db
CHROMA_COLLECTION_NAME=research_papers

# Retrieval settings
TOP_K_RETRIEVAL=5
SIMILARITY_THRESHOLD=0.7

# Chunking settings
CHUNK_SIZE=1000
CHUNK_OVERLAP=200
```

## Usage Examples

### Research Paper Analysis

```python
import resynth

# Initialize agent
agent = resynth.ReSynthAgent()

# Process recent papers on a topic
agent.search_and_process(
    query="large language model alignment",
    source="arxiv",
    max_papers=10,
    fetch_content=True
)

# Get comprehensive analysis
answer = agent.query(
    "What are the main approaches to LLM alignment?",
    citation_style="author_date"
)

print(f"Answer: {answer.answer}")
print(f"Confidence: {answer.confidence_score:.2f}")
print(f"Sources: {len(answer.source_chunks)} papers")
```

### Comparison Study

```python
# Compare different methodologies
answer = agent.query(
    "Compare transformer architectures: BERT vs GPT vs T5",
    citation_style="apa"
)

# The answer will include:
# - Detailed comparison of architectures
# - Proper citations for each model
# - Confidence assessment
# - Source references
```

### Literature Review

```python
# Systematic literature review
agent.search_and_process(
    query="climate change machine learning applications",
    source="both",  # arxiv and pubmed
    max_papers=20
)

# Get overview
overview = agent.query(
    "What are the main applications of ML in climate research?",
    citation_style="numeric"
)

# Get specific methodology info
methods = agent.query(
    "What machine learning methods are most commonly used?",
    citation_style="mla"
)
```

## Architecture

```
ReSynth/
├── Paper Fetchers     # arXiv, PubMed integration
├── Text Processors    # Chunking, cleaning, preprocessing
├── Embedding Engine  # Vector generation and storage
├── Retrieval System   # Query processing and similarity search
├── Answer Synthesizer # AI-powered response generation
└── Citation Manager   # Automatic citation formatting
```

## Citation Styles

ReSynth supports multiple citation formats:

- **APA**: (Smith, 2023)
- **MLA**: Smith, John. "Title." *Journal* (2023)
- **Numeric**: [1], [2], [3]
- **Author-Date**: (Smith, 2023)

## Quality Metrics

Every answer includes quality assessment:

- **Confidence Score**: 0.0-1.0 based on source quality
- **Retrieval Quality**: Validation of search results
- **Source Diversity**: Number of unique papers referenced
- **Similarity Metrics**: Average and minimum similarity scores

## API Endpoints

When running the API server:

```bash
# Process papers
POST /process
{
  "query": "machine learning interpretability",
  "source": "arxiv",
  "max_papers": 5
}

# Query papers
POST /query
{
  "query": "What are interpretability methods?",
  "citation_style": "apa",
  "top_k": 5
}

# Get statistics
GET /stats

# List papers
GET /papers
```

## Testing

```bash
# Run all tests
pytest

# Run with coverage
pytest --cov=resynth --cov-report=html

# Run specific test categories
pytest -m unit      # Unit tests only
pytest -m integration  # Integration tests only
```

## Contributing

We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

### Development Setup

```bash
# Clone the repository
git clone https://github.com/resynth-ai/resynth.git
cd resynth

# Install development dependencies
pip install -e ".[dev]"

# Set up pre-commit hooks
pre-commit install

# Run tests
make test
```

## Documentation

- [Full Documentation](https://github.com/resynth-ai/resynth/blob/main/docs/README.md)
- [API Reference](https://github.com/resynth-ai/resynth/blob/main/docs/api.md)
- [Examples](https://github.com/resynth-ai/resynth/blob/main/examples/)

## Roadmap

- [ ] Support for more paper sources (IEEE Xplore, Google Scholar)
- [ ] Advanced query expansion with semantic search
- [ ] Paper summarization and key point extraction
- [ ] Collaborative filtering and recommendation
- [ ] Export to various formats (LaTeX, Word, Markdown)
- [ ] Integration with reference managers (Zotero, Mendeley)

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Built with [FastAPI](https://fastapi.tiangolo.com/), [Streamlit](https://streamlit.io/), and [ChromaDB](https://www.trychroma.com/)
- Paper fetching powered by [arXiv](https://arxiv.org/) and [PubMed](https://pubmed.ncbi.nlm.nih.gov/)
- Embeddings from [OpenAI](https://openai.com/) and [Hugging Face](https://huggingface.co/)
- Citation formatting inspired by academic standards

## Support

- [Report Issues](https://github.com/resynth-ai/resynth/issues)
- [Discussions](https://github.com/resynth-ai/resynth/discussions)
- [Email](mailto:resynth@example.com)

---

**If you find ReSynth useful, please give us a star on GitHub!**
