Skip to main content

A wrapper library to abstract common llm providers

Project description

ext_llm - a wrapper library for common LLMs (WIP)

Installation

pip install ext_llm

Usage

from concurrent.futures import Future
import ext_llm
from ext_llm.llm.response import Response
from ext_llm.llm.stream import Stream

#read config yaml file
config : str = open("config.yaml").read()

#initialize extllm library
extllm = ext_llm.init(config)

#request a client via user defined presets. In this instance it's "groq-llama"
llm_client = extllm.get_client("groq-llama")

#you can request e concurrent client, based on the same preset. This will allow for non blocking concurrent requests.
llm_concurrent_client = extllm.get_concurrent_client("groq-llama")

#Non blocking call. This will return a future object that will be resolved when the request is completed.
future1: Future [Response | Stream] = llm_concurrent_client.generate_text("You are an helpful assistant", "Recite the first article of the Italian Constitution")

#Blocking call. This will return the result of the request. The result can be either a Response or a Stream object.
#Response or Stream are defined by the user in the config file.
#If the "invocation_method" is "converse" then the result is a Response.
#If the "invocation_method" is "converse_stream" then the result is a Stream.
#A stream has to be handled differently from a response.
result: Response | Stream = llm_client.generate_text("You are an helpful assistant", "Recite the first amendment of the American constitution")


print(result.metadata)
print(result)

print(future1.result().metadata)
print(future1.result())

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

ext_llm-0.1.13.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

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

ext_llm-0.1.13-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file ext_llm-0.1.13.tar.gz.

File metadata

  • Download URL: ext_llm-0.1.13.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for ext_llm-0.1.13.tar.gz
Algorithm Hash digest
SHA256 f3d9aa7a0cd9e0ffe5340e4651ab81ca6da81a6f2ee009311e90bb832e33f79d
MD5 d701af41d794015f084fafbdd271bc2e
BLAKE2b-256 b05c070d11fd986a4fa91a04b0ac94c62843017b864b1e47d17a4473450e9f34

See more details on using hashes here.

File details

Details for the file ext_llm-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: ext_llm-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 30.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for ext_llm-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 3f3d3a015023c7c0ab1d0622cd56e86e295e7f8f23def130db8fb586a1cd546d
MD5 188b0347944a05c7029be6afb612b4db
BLAKE2b-256 1e7fc81e1dce63a462760ce491438a05fc58e06c7640cf86525ab4557037452d

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