Metadata-Version: 2.4
Name: shopagent-core
Version: 0.1.0
Summary: Core LangGraph agent, RAG, and tools for ShopAgent-OS - import into your own Python backend.
License-Expression: MIT
Project-URL: Repository, https://github.com/sri-mathi/ShopAgent
Requires-Python: >=3.12
Description-Content-Type: text/markdown
Requires-Dist: groq>=0.37.1
Requires-Dist: python-dotenv>=1.2.3
Requires-Dist: sentence-transformers>=6.1.0
Requires-Dist: chromadb>=1.5.9
Requires-Dist: langgraph>=1.2.12
Requires-Dist: langchain-groq>=1.1.3
Requires-Dist: pydantic>=2.13.5
Provides-Extra: langfuse
Requires-Dist: langfuse>=4.15.6; extra == "langfuse"
Requires-Dist: langchain>=1.4.2; extra == "langfuse"
Provides-Extra: shopify
Requires-Dist: requests>=2.34.2; extra == "shopify"

# shopagent-core

Core LangGraph agent, RAG pipeline, and store-data tools for [ShopAgent-OS](https://github.com/sri-mathi/ShopAgent) — a self-hosted e-commerce AI agent. Import this into your own Python backend if you already have one and just want the agent logic, rather than running ShopAgent-OS's own prebuilt FastAPI server.

If you don't have an existing backend, it's usually simpler to deploy the full `backend/` app from the repo as-is (see the main repo README) instead of wiring this library in by hand.

## Install

```bash
pip install shopagent-core
```

Optional extras:
```bash
pip install "shopagent-core[langfuse]"   # tracing/observability
pip install "shopagent-core[shopify]"    # Shopify Admin API store adapter
```

## Configuration

Reads these environment variables (e.g. via a `.env` file with `python-dotenv`, which this package already depends on):

| Variable | Required | Purpose |
|---|---|---|
| `GROQ_API_KEY` | yes | Your Groq account's API key, used for the LLM calls. |
| `STORE_ADAPTER_TYPE` | no (default `json`) | `json` for flat-file product/order/policy data, or `shopify` for a live Shopify store. |
| `SHOPAGENT_PRODUCTS_PATH`, `SHOPAGENT_ORDERS_PATH`, `SHOPAGENT_POLICIES_PATH` | no | Paths to your own JSON/Markdown store data files, when using the `json` adapter. |
| `SHOPIFY_SHOP_DOMAIN`, `SHOPIFY_CLIENT_ID`, `SHOPIFY_CLIENT_SECRET` | only with `shopify` adapter | Your Shopify Admin API credentials. |
| `LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY` | no | Enables Langfuse tracing when both are set; the agent runs normally without them. |

## Usage

```python
from shopagent_core.agent.graph import run_agent

reply = run_agent(
    user_message="What shoes do you have in stock?",
    session_id="some-session-id",       # optional: keeps conversation history in memory
    customer_email="jane@example.com",  # optional: enables automatic order-ownership verification
)
print(reply)
```

`run_agent` is synchronous and returns a plain string reply. It's up to your own backend to wrap this in a route, handle authentication, and apply rate limiting — this package only provides the agent itself, not a server.

## License

MIT
