Skip to main content

Loads a Langchain LLM by model name as a string.

Project description

pypi testing badge black badge

Loads a Langchain LLM by model name as a string.

Installation

pip install llmloader

Or install from GitHub directly:

pip install git+https://github.com/rbturnbull/llmloader.git

Usage

Load the LLM with the llmloader.load function. e.g.

import llmloader

llm = llmloader.load("gpt-4o")
result = llm.invoke("Write me a haiku about love")

llm = llmloader.load("claude-3-5-sonnet-20240620")
result = llm.invoke("Write me a haiku about love")

llm = llmloader.load("grok-4-latest")
result = llm.invoke("Write me a haiku about love")

llm = llmloader.load("mistral-small-latest")
result = llm.invoke("Write me a haiku about love")

llm = llmloader.load("meta-llama/Llama-3.3-70B-Instruct")
result = llm.invoke("Write me a haiku about love")

CLI

You can test out prompts and models on the command line. Make sure you have your API keys set in your environment or add the key with the --api-key flag.

llmloader "Write me a haiku about love" --model gpt-4o-mini
llmloader "Write me a haiku about love" --model gpt-4o
llmloader "Write me a haiku about love" --model claude-3-5-sonnet-20240620
llmloader "Write me a haiku about love" --model grok-4-latest
llmloader "Write me a haiku about love" --model mistral-small-latest
llmloader "Write me a haiku about love" --model meta-llama/Meta-Llama-3-8B-Instruct
llmloader "Write me a haiku about love" --model meta-llama/Llama-3.3-70B-Instruct
llmloader --help

Environment Variables

To use custom models deployed with Azure OpenAI, you need to set the following environment variables:

  • AZURE_OPENAI_API_KEY: Your Azure OpenAI API key.

  • AZURE_OPENAI_API_VERSION: The API version to use (e.g., “2024-02-15-preview”).

  • AZURE_OPENAI_ENDPOINT: The endpoint URL for your Azure OpenAI service.

--model should match the deployment name in your Azure OpenAI resource.

Note: If llmloader detects the OPENAI_API_KEY environment variable, it will use the OpenAI API by default if a valid model name is provided.

Credit

Robert Turnbull (Melbourne Data Analytics Platform, University of Melbourne)

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

llmloader-0.1.6.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

llmloader-0.1.6-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file llmloader-0.1.6.tar.gz.

File metadata

  • Download URL: llmloader-0.1.6.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.1 Darwin/24.6.0

File hashes

Hashes for llmloader-0.1.6.tar.gz
Algorithm Hash digest
SHA256 522c576b3b1226c61c7202ccf16af51fcf283c91601ed9b37e8a026dc0619ebe
MD5 b6c988f223f49d73e21a96283329e03c
BLAKE2b-256 3e9041a359f1537eadc2d63b030790b5f49ab208136805e11d8940a930f02008

See more details on using hashes here.

File details

Details for the file llmloader-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: llmloader-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.13.1 Darwin/24.6.0

File hashes

Hashes for llmloader-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 412c20c3995e1b07b749decbe0ad52c12f293db8be14e3c1e85a6743abb87abf
MD5 eabe2c0ed9930d6d4e59e27692ba831e
BLAKE2b-256 39bb04b0cb7b055045fb420c98f43793af299136c96ec2cc63cedc2adfd102d8

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