Metadata-Version: 2.4
Name: far-search
Version: 1.0.0
Summary: Lightweight SDK for Federal Acquisition Regulations (FAR) search - no LangChain required
Home-page: https://github.com/blueskylineassets/far-search-tool
Author: Daniel Chang
Author-email: yschang@blueskylineassets.com
Project-URL: Homepage, https://github.com/blueskylineassets/far-search-tool
Project-URL: Documentation, https://github.com/blueskylineassets/far-search-tool#readme
Project-URL: RapidAPI, https://rapidapi.com/yschang/api/far-rag-federal-acquisition-regulation-search
Keywords: far,federal-acquisition-regulations,government-contracting,semantic-search,rag,compliance,procurement
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.28.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# FAR Search - Core SDK

[![PyPI version](https://badge.fury.io/py/far-search.svg)](https://pypi.org/project/far-search/)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

**Lightweight SDK** for semantic search over Federal Acquisition Regulations (FAR).

No LangChain dependency - just `requests`. Perfect for:
- Simple scripts and notebooks
- Serverless functions (minimal cold start)
- Projects that don't use LangChain
- Lightweight microservices

## Installation

```bash
pip install far-search
```

**Size comparison:**
- `far-search`: ~10KB + requests (~1MB total)
- `far-search-tool`: ~15KB + LangChain (~150MB total)

## Quick Start

```python
from far_search_core import FARSearchClient

# Auto-registers on first use - no API key needed!
client = FARSearchClient()

# Search
results = client.search("cybersecurity requirements", top_k=5)

for clause in results:
    print(f"{clause.id}: {clause.title}")
    print(f"  Score: {clause.similarity_score:.1%}")
    print(f"  URL: {clause.url}")
```

## Convenience Function

```python
from far_search_core import search_far

# One-liner search
results = search_far("small business set aside requirements")
```

## FARClause Object

Each result is a `FARClause` dataclass:

```python
@dataclass
class FARClause:
    id: str              # e.g., "52.204-2"
    title: str           # e.g., "Security Requirements"
    text: str            # Full clause text
    source: str          # e.g., "FAR Part 52"
    url: str             # acquisition.gov URL
    similarity_score: float  # 0.0 - 1.0
```

## Get Formatted Text (for LLMs)

```python
client = FARSearchClient()

# Get pre-formatted text for LLM context
text = client.search_text("contract termination procedures")
print(text)
```

## Get Specific Clause

```python
client = FARSearchClient()

clause = client.get_clause("52.203-1")
if clause:
    print(clause.text)
```

## Configuration

```python
# With explicit API key
client = FARSearchClient(api_key="far_live_...")

# With RapidAPI key (for higher limits)
client = FARSearchClient(rapidapi_key="your-rapidapi-key")

# Environment variables
# export FAR_API_KEY=far_live_...
# export FAR_QUIET=1  # Suppress usage warnings
```

## Pricing

| Plan | Price | Queries/Month |
|------|-------|---------------|
| **Free** | $0 | 500 |
| **Pro** | $29/mo | 5,000 |
| **Ultra** | $199/mo | 150,000 |

Auto-registers on first use. Upgrade at [RapidAPI](https://rapidapi.com/yschang/api/far-rag-federal-acquisition-regulation-search).

## Error Handling

```python
from far_search_core import FARSearchClient, FARAPIError, FARRateLimitError

client = FARSearchClient()

try:
    results = client.search("my query")
except FARRateLimitError:
    print("Rate limit exceeded - upgrade your plan")
except FARAPIError as e:
    print(f"API error: {e}")
```

## Related Packages

| Package | Use Case |
|---------|----------|
| **far-search** (this) | Lightweight, no dependencies |
| **far-search-tool** | LangChain tool integration |
| **far-search-crewai** | CrewAI multi-agent tool |
| **far-search-autogpt** | AutoGPT plugin |
| **far-oracle** | MCP Server for Claude Desktop |

## License

MIT License - see [LICENSE](LICENSE) for details.

