Skip to main content

LangChain integration for Zunno LLM and Embeddings

Project description

LangChain Zunno Integration

A LangChain integration for Zunno LLM and Embeddings, providing easy-to-use wrappers for text generation and embeddings.

Installation

pip install langchain-zunno

Quick Start

Text Generation (LLM)

from langchain_zunno import ZunnoLLM

# Create an LLM instance
llm = ZunnoLLM(model_name="mistral:latest")

# Generate text
response = llm.invoke("Hello, how are you?")
print(response)

Embeddings

from langchain_zunno import ZunnoLLMEmbeddings

# Create an embeddings instance
embeddings = ZunnoLLMEmbeddings(model_name="mistral:latest")

# Get embeddings for a single text
embedding = embeddings.embed_query("Hello, how are you?")
print(f"Embedding dimension: {len(embedding)}")

# Get embeddings for multiple texts
texts = ["Hello world", "How are you?", "Good morning"]
embeddings_list = embeddings.embed_documents(texts)
print(f"Number of embeddings: {len(embeddings_list)}")

Async Usage

import asyncio
from langchain_zunno import ZunnoLLM, ZunnoLLMEmbeddings

async def main():
    # Async LLM
    llm = ZunnoLLM(model_name="mistral:latest")
    response = await llm.ainvoke("Hello, how are you?")
    print(response)
    
    # Async embeddings
    embeddings = ZunnoLLMEmbeddings(model_name="mistral:latest")
    embedding = await embeddings.aembed_query("Hello, how are you?")
    print(f"Embedding dimension: {len(embedding)}")

asyncio.run(main())

Factory Functions

For convenience, you can use factory functions to create instances:

from langchain_zunno import create_zunno_llm, create_zunno_embeddings

# Create LLM
llm = create_zunno_llm(
    model_name="mistral:latest",
    temperature=0.7,
    max_tokens=100
)

# Create embeddings
embeddings = create_zunno_embeddings(
    model_name="mistral:latest"
)

Configuration

LLM Configuration

  • model_name: The name of the model to use
  • base_url: API endpoint (default: "http://15.206.124.44/v1/prompt-response")
  • temperature: Controls randomness in generation (default: 0.7)
  • max_tokens: Maximum number of tokens to generate (optional)
  • timeout: Request timeout in seconds (default: 300)

Embeddings Configuration

API Endpoints

The package connects to the following Zunno API endpoints:

  • Text Generation: http://15.206.124.44/v1/prompt-response
  • Embeddings: http://15.206.124.44/v1/text-embeddings

Error Handling

The package includes comprehensive error handling:

try:
    response = llm.invoke("Hello")
except Exception as e:
    print(f"Error: {e}")

Development

Installation for Development

git clone https://github.com/zunno/langchain-zunno.git
cd langchain-zunno
pip install -e ".[dev]"

Running Tests

pytest

Code Formatting

black .
isort .

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

Support

For support, please open an issue on GitHub or contact us at support@zunno.ai.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_zunno-0.1.3.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_zunno-0.1.3-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file langchain_zunno-0.1.3.tar.gz.

File metadata

  • Download URL: langchain_zunno-0.1.3.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for langchain_zunno-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e5547a219970b97c573792c22e211019517510ce80e0141a1ee7eb01c43f7230
MD5 f5f8c460898c3e0e9af2724eae5408ee
BLAKE2b-256 2f71e95663fa5df5cfccaed7fb88c58cf6c1ced64c7fd6d32380ecd3f6800c47

See more details on using hashes here.

File details

Details for the file langchain_zunno-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_zunno-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ef9b3c70227c3be7672d6d2485f750575cb66331e21d4ef1c619972f11c9071b
MD5 93b9567223021c9062a14f850dcce841
BLAKE2b-256 cd0b959544b6284ed6dafb3fa44404a8fbae5e39fb7bcfe874fa82ddf5c91c48

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page