esperanto


Nameesperanto JSON
Version 0.7.0 PyPI version JSON
download
home_pageNone
SummaryA unified interface for various AI model providers
upload_time2024-12-18 22:32:29
maintainerNone
docs_urlNone
authorNone
requires_python<3.14,>=3.10
licenseMIT
keywords ai anthropic elevenlabs google llm openai speech-to-text text-to-speech
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Esperanto 🌐

[![PyPI version](https://badge.fury.io/py/esperanto.svg)](https://badge.fury.io/py/esperanto)
[![PyPI Downloads](https://img.shields.io/pypi/dm/esperanto)](https://pypi.org/project/esperanto/)
[![Coverage](https://img.shields.io/badge/coverage-87%25-brightgreen)](https://github.com/lfnovo/esperanto)
[![Python Versions](https://img.shields.io/pypi/pyversions/esperanto)](https://pypi.org/project/esperanto/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Esperanto is a powerful Python library that provides a unified interface for interacting with various Large Language Model (LLM) providers. It simplifies the process of working with different AI models (LLMs, Embedders, Transcribers) APIs by offering a consistent interface while maintaining provider-specific optimizations.

## Features ✨

- **Unified Interface**: Work with multiple LLM providers using a consistent API
- **Provider Support**:
  - OpenAI (GPT-4, GPT-3.5, o1, Whisper, TTS)
  - Anthropic (Claude 3)
  - OpenRouter (Access to multiple models)
  - xAI (Grok)
  - Groq (Mixtral, Llama, Whisper)
  - Google GenAI (Gemini LLM, Text To Speech, Embedding)
  - Vertex AI (Google Cloud)
  - Ollama (Local deployment)
  - ElevenLabs (Text-to-Speech)

- **Embedding Support**: Multiple embedding providers for vector representations
- **Speech-to-Text Support**: Transcribe audio using multiple providers
- **Text-to-Speech Support**: Generate speech using multiple providers
- **Async Support**: Both synchronous and asynchronous API calls
- **Streaming**: Support for streaming responses
- **Structured Output**: JSON output formatting (where supported)
- **LangChain Integration**: Easy conversion to LangChain chat models

For detailed information about our providers, check out:
- [LLM Providers Documentation](https://github.com/lfnovo/esperanto/blob/main/docs/llm.md)
- [Embedding Providers Documentation](https://github.com/lfnovo/esperanto/blob/main/docs/embedding.md)
- [Speech-to-Text Providers Documentation](https://github.com/lfnovo/esperanto/blob/main/docs/speech_to_text.md)
- [Text-to-Speech Providers Documentation](https://github.com/lfnovo/esperanto/blob/main/docs/text_to_speech.md)

## Installation 🚀

Install Esperanto using pip:

```bash
pip install esperanto
```

For specific providers, install with their extras:

```bash
# For OpenAI support
pip install "esperanto[openai]"

# For Anthropic support
pip install "esperanto[anthropic]"

# For Google (GenAI) support
pip install "esperanto[google]"

# For Vertex AI support
pip install "esperanto[vertex]"

# For Groq support
pip install "esperanto[groq]"

# For Ollama support
pip install "esperanto[ollama]"

# For all providers
pip install "esperanto[all]"
```

## Provider Support Matrix

| Provider    | LLM Support | Embedding Support | Speech-to-Text | Text-to-Speech | JSON Mode |
|------------|-------------|------------------|----------------|----------------|-----------|
| OpenAI     | ✅          | ✅               | ✅             | ✅             | ✅        |
| Anthropic  | ✅          | ❌               | ❌             | ❌             | ✅        |
| Groq       | ✅          | ❌               | ✅             | ❌             | ✅        |
| Google (GenAI)     | ✅          | ✅               | ❌             | ✅             | ✅        |
| Vertex AI  | ✅          | ✅               | ❌             | ❌             | ❌        |
| Ollama     | ✅          | ✅               | ❌             | ❌             | ❌        |
| ElevenLabs | ❌          | ❌               | ❌             | ✅             | ❌        |

## Quick Start 🏃‍♂️

You can use Esperanto in two ways: directly with provider-specific classes or through the AI Factory.

### Using AI Factory

```python
from esperanto.factory import AIFactory

# Create an LLM instance
model = AIFactory.create_llm("openai", "gpt-3.5-turbo")
messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "What's the capital of France?"},
]
response = model.chat_complete(messages)

# Create an embedding instance
model = AIFactory.create_embedding("openai", "text-embedding-3-small")
texts = ["Hello, world!", "Another text"]
embeddings = model.embed(texts)
```

## Standardized Responses

All providers in Esperanto return standardized response objects, making it easy to work with different models without changing your code.

### LLM Responses

```python
from esperanto.factory import AIFactory

model = AIFactory.create_llm("openai", "gpt-3.5-turbo")
messages = [{"role": "user", "content": "Hello!"}]

# All LLM responses follow this structure
response = model.chat_complete(messages)
print(response.choices[0].message.content)  # The actual response text
print(response.choices[0].message.role)     # 'assistant'
print(response.model)                       # The model used
print(response.usage.total_tokens)          # Token usage information

# For streaming responses
for chunk in model.chat_complete(messages):
    print(chunk.choices[0].delta.content)   # Partial response text
```

### Embedding Responses

```python
from esperanto.factory import AIFactory

model = AIFactory.create_embedding("openai", "text-embedding-3-small")
texts = ["Hello, world!", "Another text"]

# All embedding responses follow this structure
response = model.embed(texts)
print(response.data[0].embedding)     # Vector for first text
print(response.data[0].index)         # Index of the text (0)
print(response.model)                 # The model used
print(response.usage.total_tokens)    # Token usage information
```

The standardized response objects ensure consistency across different providers, making it easy to:
- Switch between providers without changing your application code
- Handle responses in a uniform way
- Access common attributes like token usage and model information

## Links 🔗

- **Documentation**: [GitHub Documentation](https://github.com/lfnovo/esperanto#readme)
- **Source Code**: [GitHub Repository](https://github.com/lfnovo/esperanto)
- **Issue Tracker**: [GitHub Issues](https://github.com/lfnovo/esperanto/issues)

## License 📄

This project is licensed under the MIT License - see the [LICENSE](https://github.com/lfnovo/esperanto/blob/main/LICENSE) file for details.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "esperanto",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.14,>=3.10",
    "maintainer_email": null,
    "keywords": "ai, anthropic, elevenlabs, google, llm, openai, speech-to-text, text-to-speech",
    "author": null,
    "author_email": "LUIS NOVO <lfnovo@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/ea/c5/9b1a90a74bd26ddcbe1f638282d74d51607ee965fe57c174c4fba42dd25a/esperanto-0.7.0.tar.gz",
    "platform": null,
    "description": "# Esperanto \ud83c\udf10\n\n[![PyPI version](https://badge.fury.io/py/esperanto.svg)](https://badge.fury.io/py/esperanto)\n[![PyPI Downloads](https://img.shields.io/pypi/dm/esperanto)](https://pypi.org/project/esperanto/)\n[![Coverage](https://img.shields.io/badge/coverage-87%25-brightgreen)](https://github.com/lfnovo/esperanto)\n[![Python Versions](https://img.shields.io/pypi/pyversions/esperanto)](https://pypi.org/project/esperanto/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nEsperanto is a powerful Python library that provides a unified interface for interacting with various Large Language Model (LLM) providers. It simplifies the process of working with different AI models (LLMs, Embedders, Transcribers) APIs by offering a consistent interface while maintaining provider-specific optimizations.\n\n## Features \u2728\n\n- **Unified Interface**: Work with multiple LLM providers using a consistent API\n- **Provider Support**:\n  - OpenAI (GPT-4, GPT-3.5, o1, Whisper, TTS)\n  - Anthropic (Claude 3)\n  - OpenRouter (Access to multiple models)\n  - xAI (Grok)\n  - Groq (Mixtral, Llama, Whisper)\n  - Google GenAI (Gemini LLM, Text To Speech, Embedding)\n  - Vertex AI (Google Cloud)\n  - Ollama (Local deployment)\n  - ElevenLabs (Text-to-Speech)\n\n- **Embedding Support**: Multiple embedding providers for vector representations\n- **Speech-to-Text Support**: Transcribe audio using multiple providers\n- **Text-to-Speech Support**: Generate speech using multiple providers\n- **Async Support**: Both synchronous and asynchronous API calls\n- **Streaming**: Support for streaming responses\n- **Structured Output**: JSON output formatting (where supported)\n- **LangChain Integration**: Easy conversion to LangChain chat models\n\nFor detailed information about our providers, check out:\n- [LLM Providers Documentation](https://github.com/lfnovo/esperanto/blob/main/docs/llm.md)\n- [Embedding Providers Documentation](https://github.com/lfnovo/esperanto/blob/main/docs/embedding.md)\n- [Speech-to-Text Providers Documentation](https://github.com/lfnovo/esperanto/blob/main/docs/speech_to_text.md)\n- [Text-to-Speech Providers Documentation](https://github.com/lfnovo/esperanto/blob/main/docs/text_to_speech.md)\n\n## Installation \ud83d\ude80\n\nInstall Esperanto using pip:\n\n```bash\npip install esperanto\n```\n\nFor specific providers, install with their extras:\n\n```bash\n# For OpenAI support\npip install \"esperanto[openai]\"\n\n# For Anthropic support\npip install \"esperanto[anthropic]\"\n\n# For Google (GenAI) support\npip install \"esperanto[google]\"\n\n# For Vertex AI support\npip install \"esperanto[vertex]\"\n\n# For Groq support\npip install \"esperanto[groq]\"\n\n# For Ollama support\npip install \"esperanto[ollama]\"\n\n# For all providers\npip install \"esperanto[all]\"\n```\n\n## Provider Support Matrix\n\n| Provider    | LLM Support | Embedding Support | Speech-to-Text | Text-to-Speech | JSON Mode |\n|------------|-------------|------------------|----------------|----------------|-----------|\n| OpenAI     | \u2705          | \u2705               | \u2705             | \u2705             | \u2705        |\n| Anthropic  | \u2705          | \u274c               | \u274c             | \u274c             | \u2705        |\n| Groq       | \u2705          | \u274c               | \u2705             | \u274c             | \u2705        |\n| Google (GenAI)     | \u2705          | \u2705               | \u274c             | \u2705             | \u2705        |\n| Vertex AI  | \u2705          | \u2705               | \u274c             | \u274c             | \u274c        |\n| Ollama     | \u2705          | \u2705               | \u274c             | \u274c             | \u274c        |\n| ElevenLabs | \u274c          | \u274c               | \u274c             | \u2705             | \u274c        |\n\n## Quick Start \ud83c\udfc3\u200d\u2642\ufe0f\n\nYou can use Esperanto in two ways: directly with provider-specific classes or through the AI Factory.\n\n### Using AI Factory\n\n```python\nfrom esperanto.factory import AIFactory\n\n# Create an LLM instance\nmodel = AIFactory.create_llm(\"openai\", \"gpt-3.5-turbo\")\nmessages = [\n    {\"role\": \"system\", \"content\": \"You are a helpful assistant.\"},\n    {\"role\": \"user\", \"content\": \"What's the capital of France?\"},\n]\nresponse = model.chat_complete(messages)\n\n# Create an embedding instance\nmodel = AIFactory.create_embedding(\"openai\", \"text-embedding-3-small\")\ntexts = [\"Hello, world!\", \"Another text\"]\nembeddings = model.embed(texts)\n```\n\n## Standardized Responses\n\nAll providers in Esperanto return standardized response objects, making it easy to work with different models without changing your code.\n\n### LLM Responses\n\n```python\nfrom esperanto.factory import AIFactory\n\nmodel = AIFactory.create_llm(\"openai\", \"gpt-3.5-turbo\")\nmessages = [{\"role\": \"user\", \"content\": \"Hello!\"}]\n\n# All LLM responses follow this structure\nresponse = model.chat_complete(messages)\nprint(response.choices[0].message.content)  # The actual response text\nprint(response.choices[0].message.role)     # 'assistant'\nprint(response.model)                       # The model used\nprint(response.usage.total_tokens)          # Token usage information\n\n# For streaming responses\nfor chunk in model.chat_complete(messages):\n    print(chunk.choices[0].delta.content)   # Partial response text\n```\n\n### Embedding Responses\n\n```python\nfrom esperanto.factory import AIFactory\n\nmodel = AIFactory.create_embedding(\"openai\", \"text-embedding-3-small\")\ntexts = [\"Hello, world!\", \"Another text\"]\n\n# All embedding responses follow this structure\nresponse = model.embed(texts)\nprint(response.data[0].embedding)     # Vector for first text\nprint(response.data[0].index)         # Index of the text (0)\nprint(response.model)                 # The model used\nprint(response.usage.total_tokens)    # Token usage information\n```\n\nThe standardized response objects ensure consistency across different providers, making it easy to:\n- Switch between providers without changing your application code\n- Handle responses in a uniform way\n- Access common attributes like token usage and model information\n\n## Links \ud83d\udd17\n\n- **Documentation**: [GitHub Documentation](https://github.com/lfnovo/esperanto#readme)\n- **Source Code**: [GitHub Repository](https://github.com/lfnovo/esperanto)\n- **Issue Tracker**: [GitHub Issues](https://github.com/lfnovo/esperanto/issues)\n\n## License \ud83d\udcc4\n\nThis project is licensed under the MIT License - see the [LICENSE](https://github.com/lfnovo/esperanto/blob/main/LICENSE) file for details.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A unified interface for various AI model providers",
    "version": "0.7.0",
    "project_urls": {
        "documentation": "https://github.com/lfnovo/esperanto#readme",
        "homepage": "https://github.com/lfnovo/esperanto",
        "repository": "https://github.com/lfnovo/esperanto"
    },
    "split_keywords": [
        "ai",
        " anthropic",
        " elevenlabs",
        " google",
        " llm",
        " openai",
        " speech-to-text",
        " text-to-speech"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dd0dfd8a4393ed787ee5ac596ca600360a5be9df58b09914860ebb429b025e2a",
                "md5": "f4313613df6acbee9264786d0457361d",
                "sha256": "b4ced4a0d266fdfe12864e2b56f05781a36ae2f3d4ffd98598636c7082fafe3a"
            },
            "downloads": -1,
            "filename": "esperanto-0.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f4313613df6acbee9264786d0457361d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.14,>=3.10",
            "size": 42990,
            "upload_time": "2024-12-18T22:32:26",
            "upload_time_iso_8601": "2024-12-18T22:32:26.958819Z",
            "url": "https://files.pythonhosted.org/packages/dd/0d/fd8a4393ed787ee5ac596ca600360a5be9df58b09914860ebb429b025e2a/esperanto-0.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "eac59b1a90a74bd26ddcbe1f638282d74d51607ee965fe57c174c4fba42dd25a",
                "md5": "333c7498c96c1e998bef2c695bfb8cee",
                "sha256": "a512a37e2d8586d46aa52cbbcec58b327ba75996a83d6cdadde3b0b2683706d1"
            },
            "downloads": -1,
            "filename": "esperanto-0.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "333c7498c96c1e998bef2c695bfb8cee",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.14,>=3.10",
            "size": 549221,
            "upload_time": "2024-12-18T22:32:29",
            "upload_time_iso_8601": "2024-12-18T22:32:29.862697Z",
            "url": "https://files.pythonhosted.org/packages/ea/c5/9b1a90a74bd26ddcbe1f638282d74d51607ee965fe57c174c4fba42dd25a/esperanto-0.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-18 22:32:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lfnovo",
    "github_project": "esperanto#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "esperanto"
}
        
Elapsed time: 0.42818s