Skip to main content

LLM Development Kit for common APIs

Project description

Logo

Streamline LLM Interactions in Python


PyPi License

Installation

pip install llmdk

Basic Usage

Client

from llmdk import Llmdk, Providers

# You can also set OPENAI_API_KEY
client = Llmdk(
    provider=Providers.OPENAI,
    model_name='gpt-4o-mini',
    # api_key='***',
)

Generate

Prompt

output = client.generate(
    'Who are you?',
    # system='Write in Portuguese.',
)

List of messages

output = client.generate(
    messages=[
        # {'role': 'system', 'content': 'Write in Portuguese.'},
        {'role': 'user', 'content': 'Who are you?'},
    ],
)

Stream

Prompt

for chunk in client.stream(
    'Who are you?',
    # system='Write in Portuguese.',
):
    print(chunk, end='', flush=True)

List of messages

for chunk in client.stream([
    # {'role': 'system', 'content': 'Write in Portuguese.'},
    {'role': 'user', 'content': 'Who are you?'},
]):
    print(chunk, end='', flush=True)

Supported Providers

Anthropic

from llmdk import Llmdk, Providers

# You can also set ANTHROPIC_API_KEY
client = Llmdk(
    provider=Providers.ANTHROPIC,
    model_name='claude-3-5-sonnet-20240620',
    # api_key='***',
)

Groq

from llmdk import Llmdk, Providers

# You can also set GROQ_API_KEY
client = Llmdk(
    provider=Providers.GROQ,
    model_name='llama-3.1-70b-versatile',
    # api_key='***',
)

HuggingFace

from llmdk import Llmdk, Providers

# You can also set HF_TOKEN
client = Llmdk(
    provider=Providers.HUGGINGFACE,
    model_name='meta-llama/Meta-Llama-3.1-70B-Instruct',
    # api_key='***',
)

Ollama

from llmdk import Llmdk, Providers

client = Llmdk(
    provider=Providers.OLLAMA,
    model_name='llama3.2:1b',
    # base_url='http://localhost:11434',
)

OpenAI

from llmdk import Llmdk, Providers

# You can also set OPENAI_API_KEY
client = Llmdk(
    provider=Providers.OPENAI,
    model_name='gpt-4o-mini',
    # api_key='***',
)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

llmdk-1.2410.1-py3-none-any.whl (28.2 kB view hashes)

Uploaded Python 3

Supported by

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