Skip to main content

Glueco LLM Plugin

PyPI version Python 3.10+

Typed LLM chat completions for the Glueco Gateway SDK.

Installation

pip install glueco-plugin-llm

Quick Start

from glueco_sdk import GatewayClient, FileKeyStorage, FileConfigStorage
from glueco_plugin_llm import llm_client

# Setup gateway client
client = GatewayClient(
    key_storage=FileKeyStorage(".gateway/keys.json"),
    config_storage=FileConfigStorage(".gateway/config.json"),
)

# Get transport and create LLM client
transport = client.get_transport()
llm = llm_client(transport)

# Make chat completion
response = llm.chat_completions(
    provider="groq",
    model="llama-3.1-8b-instant",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"},
    ],
    temperature=0.7,
)

print(response.content)

Streaming

for chunk in llm.chat_completions_stream(
    provider="groq",
    model="llama-3.1-8b-instant",
    messages=[{"role": "user", "content": "Tell me a story"}],
):
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Supported Providers

Provider Resource ID Models
OpenAI llm:openai gpt-4o, gpt-4o-mini, etc.
Groq llm:groq llama-3.1-8b-instant, llama-3.1-70b, etc.
Gemini llm:gemini gemini-1.5-flash, gemini-1.5-pro, etc.

Types

from glueco_plugin_llm import (
    ChatMessage,
    ChatCompletion,
    ChatCompletionChoice,
    ChatCompletionUsage,
)

# Create typed messages
messages = [
    ChatMessage(role="system", content="You are helpful."),
    ChatMessage(role="user", content="Hello!"),
]

# Response is fully typed
response: ChatCompletion = llm.chat_completions(...)
print(response.id)
print(response.model)
print(response.choices[0].message.content)
print(response.usage.total_tokens)

API Reference

llm_client(transport)

Factory function to create an LLM client.

LLMClient

llm.chat_completions(
    provider: str,          # "openai", "groq", "gemini"
    model: str,             # Model name
    messages: list,         # Conversation messages
    temperature: float,     # Optional (0.0-2.0)
    max_tokens: int,        # Optional
    response_format: dict,  # Optional
    **kwargs,               # Provider-specific params
) -> ChatCompletion

llm.chat_completions_stream(...) -> Iterator[ChatCompletionChunk]

License

MIT

Metadata

Release files for glueco-plugin-llm 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glueco-plugin-llm 0.1.0
File Size Uploaded
glueco_plugin_llm-0.1.0.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for glueco-plugin-llm 0.1.0
File Interpreter ABI Platform
glueco_plugin_llm-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / glueco_plugin_llm-0.1.0.tar.gz

Download URL glueco_plugin_llm-0.1.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1bd47e8a211fb13750087aeda93d892978d7ae6d0f995c8b3671af640a293569
BLAKE2b-256 checksum
How to use checksums
6c20acd6d7fbd2be7ed69e9b465a0e6993d47601fbe0d2ac53324c7032dcebe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / glueco_plugin_llm-0.1.0-py3-none-any.whl

Download URL glueco_plugin_llm-0.1.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03393027d94948c6832bb3b27eb0ba666c80db620d59f6ce2dfffb5b4a861d34
BLAKE2b-256 checksum
How to use checksums
09e665fdcf8f23b0d1b2f25cfec38efe023cf2d68741487d68f9ac6d525d1780
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page