Metadata-Version: 2.5
Name: langchain-sovereigneg
Version: 0.1.1
Summary: LangChain and LangGraph integration for SovereignEG, the Egyptian sovereign AI platform
Project-URL: Homepage, https://sovereigneg.com
Project-URL: Documentation, https://sovereigneg.com/docs/langchain
Project-URL: Source, https://github.com/sovereigneg/langchain-sovereigneg
Author: SovereignEG
License-Expression: MIT
License-File: LICENSE
Keywords: arabic,egypt,langchain,langgraph,llm,openai-compatible,sovereign-ai,sovereigneg
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: <4.0,>=3.10
Requires-Dist: langchain-core<2.0.0,>=1.0.0
Requires-Dist: langchain-openai<2.0.0,>=1.0.0
Requires-Dist: typing-extensions>=4.7
Description-Content-Type: text/markdown

# langchain-sovereigneg

LangChain and LangGraph integration for [SovereignEG](https://sovereigneg.com), the Egyptian sovereign AI platform: 230+ local and international models behind one OpenAI-compatible API, billed in Egyptian pounds.

تكامل رسمي بين LangChain و LangGraph ومنصة SovereignEG — منصة الذكاء الاصطناعي السيادية المصرية. موديلات محلية وعالمية من خلال API واحد، والدفع بالجنيه المصري.

## Install

```bash
pip install -U langchain-sovereigneg
export SOVEREIGNEG_API_KEY="your-api-key"   # https://sovereigneg.com/dashboard/keys
```

## Chat models

```python
from langchain_sovereigneg import ChatSovereignEG

llm = ChatSovereignEG(model="gpt-oss-20b", temperature=0)
print(llm.invoke("اشرح يعني إيه LangGraph في جملتين").content)
```

Use any chat model ID from the [SovereignEG catalog](https://sovereigneg.com). Streaming, async, tool calling and structured output work the same as with `ChatOpenAI`:

```python
for chunk in llm.stream("Write a haiku about the Nile"):
    print(chunk.text, end="")
```

## Embeddings

```python
from langchain_sovereigneg import SovereignEGEmbeddings

embeddings = SovereignEGEmbeddings(model="SovereignEG/embeddinggemma-300m")
vector = embeddings.embed_query("مرحبا بالعالم")
```

## LangGraph agent

```bash
pip install -U langchain langchain-sovereigneg
```

```python
from langchain_core.tools import tool
from langchain.agents import create_agent  # runs on LangGraph
from langchain_sovereigneg import ChatSovereignEG


@tool
def egp_to_usd(amount: float, rate: float) -> float:
    """Convert Egyptian pounds to US dollars at the given rate."""
    return round(amount / rate, 2)


agent = create_agent(ChatSovereignEG(model="gpt-oss-20b"), tools=[egp_to_usd])
result = agent.invoke(
    {
        "messages": [
            {"role": "user", "content": "How much is 5000 EGP at 48.5 per dollar?"}
        ]
    }
)
print(result["messages"][-1].content)
```

For agents, pick a catalog model that supports function calling.

## Configuration

| Argument   | Environment variable   | Default                              |
|------------|------------------------|--------------------------------------|
| `api_key`  | `SOVEREIGNEG_API_KEY`  | none (required on the default URL)   |
| `base_url` | `SOVEREIGNEG_API_BASE` | `https://backend.sovereigneg.com/v1` |

Set `base_url` to point at a dedicated or private SovereignEG deployment.

## Other frameworks

SovereignEG works with any OpenAI-compatible client. Guides for LlamaIndex, CrewAI, Open WebUI, OpenCode and more are at [sovereigneg.com/docs/integrations](https://sovereigneg.com/docs/integrations).

## Development

```bash
uv sync --all-groups
uv run pytest tests/unit_tests                              # offline
SOVEREIGNEG_API_KEY=... uv run pytest tests/integration_tests # live API
```

## License

MIT
