Skip to main content

LLM URI Parsing.

Project description

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?

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

llmuri-0.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

llmuri-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file llmuri-0.1.0.tar.gz.

File metadata

  • Download URL: llmuri-0.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.5

File hashes

Hashes for llmuri-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4ce492e52eacf7748a4a9f17035113e0b5a4f3ca82523ea4b90c4430faec1e4c
MD5 4779c69d1b09ec821f059c62d75b06cd
BLAKE2b-256 722998e9b736f54b83a99ace06afb4934b2f775d1c155ef05e208c43b8510f4c

See more details on using hashes here.

File details

Details for the file llmuri-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: llmuri-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.5

File hashes

Hashes for llmuri-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 149d0d83e62b94e0c24a3b41c829ec6b5f7d8b1096f5bfee78be73e188bf6e7c
MD5 3299f4c73293c510b78e5d1570be64bb
BLAKE2b-256 0e1396f008e8b7120ded696cf9643cc79da87c9bf042075168b21dc01ddc1db4

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