Skip to main content

llmuri -- URI support for LLMs

This project defines a standard URI for specifying LLMs and provides functionality to convert LLM strings for use with popular LLM packages.

Example

from llmuri import uri_to_litellm
from litellm import completion

for uri in [
    "llm:openai/gpt-4",
    "openai/gpt-4",
    "llm:ollama/llama2",
    "llm:mistralai/mistral-medium?temperature=0.2&max_tokens=4",
    "llm:ollama@example.com:11434/llama2",
]:
    kwargs = uri_to_litellm(uri)
    response = completion(
        messages=[{"content": "respond in 20 words. who are you?", "role": "user"}],
        **kwargs,
    )
    print(response)

Installation

pip install llmuri

URI Specification

[scheme:]provider[@host[:port]]/model-name[?parameter1=value1[&parameter2=value2]...

examples:

ollama/llama2
llm:ollama/llama2?temperature=0.2
llms:ollama@example.com:11434/llama2
  • scheme can be "llm" or "llms" to specify that the LLM is hosted behind an https web service. If the scheme is ommitted, "llm" is assumed.

  • provider is the name of the LLM API or service.

  • host is an optional hostname where the LLM service is located.

  • port is the service's port number.

  • model-name is the name of the model to be executed.

  • parameter-list is a list of model-specific parameters.

Canonical Abbreviations

The canonical set of well-known services is in canonical-abbreviations.csv.

In-process References

If the port portion of the URI is "mem", then the LLM is not accessed externally, but is instantiated in the current process.

The semantics of in-process references is a WIP and subject to change.

  • provider and host are available for llm specification.
llm:A@B:mem/mymodel  #  A,B are available
llmp:A@B:C/mymodel   #  A,B,C are available if we introduce a new scheme. bad idea?

Examples:

llm:MyTransformer@:mem        # Instantiate an instance of MyTransformer
llm:openai@:mem/gpt-3.5-turbo # Instantiate an instance of OpenAI() using gpt-3.5-turbo
llm:completions@mistralai:mem/mistral-medium  # completions interface?

Metadata

Release files for llmuri 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 llmuri 0.1.0
File Size Uploaded Provenance
llmuri-0.1.0.tar.gz 4.5 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 8.8 kB

Release files / llmuri-0.1.0.tar.gz

Download URL llmuri-0.1.0.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4ce492e52eacf7748a4a9f17035113e0b5a4f3ca82523ea4b90c4430faec1e4c
BLAKE2b-256 checksum
How to use checksums
722998e9b736f54b83a99ace06afb4934b2f775d1c155ef05e208c43b8510f4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.5

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

Download URL llmuri-0.1.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
149d0d83e62b94e0c24a3b41c829ec6b5f7d8b1096f5bfee78be73e188bf6e7c
BLAKE2b-256 checksum
How to use checksums
0e1396f008e8b7120ded696cf9643cc79da87c9bf042075168b21dc01ddc1db4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.5

Security for llmuri 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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