Metadata-Version: 2.4
Name: python-llm-factory
Version: 0.0.5
Summary: A flexible Python factory for working with multiple Large Language Model (LLM) providers (OpenAI, Anthropic, Gemini, Llama) using a unified interface, with robust configuration and extensibility.
Home-page: https://github.com/aviz92/python-llm-factory
Author: Avi Zaguri
Author-email: 
Project-URL: Repository, https://github.com/aviz92/python-llm-factory
Classifier: Framework :: Pytest
Classifier: Programming Language :: Python
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: setuptools
Requires-Dist: wheel
Requires-Dist: python-dotenv
Requires-Dist: pre-commit
Requires-Dist: colorlog
Requires-Dist: pytest
Requires-Dist: pathlib
Requires-Dist: PyYAML
Requires-Dist: pydantic
Requires-Dist: pydantic-settings
Requires-Dist: openai
Requires-Dist: anthropic
Requires-Dist: google-genai
Requires-Dist: instructor
Requires-Dist: instructor[anthropic]
Requires-Dist: instructor[google-genai]
Requires-Dist: custom-python-logger
Requires-Dist: pytest-plugins
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# llm-factory
A flexible Python factory for working with multiple Large Language Model (LLM) providers (OpenAI, Anthropic, Gemini, Llama) using a unified interface, with robust configuration and extensibility.

---

## Features
- ✅ Unified interface for multiple LLM providers (OpenAI, Anthropic, Gemini, Llama)
- ✅ Easy provider switching via configuration
- ✅ Pydantic-based response validation
- ✅ Environment variable-based secure configuration
- ✅ Extensible for new providers
- ✅ Supports model, temperature, max tokens, and retries per provider

---

## Installation
```bash
pip install python-llm-factory
```

---

## Configuration
The package uses environment variables for authentication and configuration. You can set these in a `.env` file or your environment:

```bash
# Required environment variables for each provider
OPENAI_API_KEY=your_openai_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key
GEMINI_API_KEY=your_gemini_api_key
```

---

## Examples

### Basic Usage: Creating a Completion

```python
from pydantic import BaseModel, Field
from python_llm_factory import LLMFactory
from python_llm_factory import Settings


class CompletionModel(BaseModel):
    response: str = Field(description="Your response to the user.")
    reasoning: str = Field(description="Explain your reasoning for the response.")


messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "If it takes 2 hours to dry 1 shirt out in the sun, how long will it take to dry 5 shirts?"},
]

llm = LLMFactory(
    settings=Settings().gemini.gemini_2_5_flash,
)
completion = llm.completions_create(
    response_model=CompletionModel,
    messages=messages,
)
print(f"Response: {completion.response}\n")
print(f"Reasoning: {completion.reasoning}")
```

---

## 🤝 Contributing
If you have a helpful tool, pattern, or improvement to suggest:
- Fork the repo <br>
- Create a new branch <br>
- Submit a pull request <br>
I welcome additions that promote clean, productive, and maintainable development. <br>

---

## 🙏 Thanks
Thanks for exploring this repository! <br>
Happy coding! <br>
