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
Release history Release notifications | RSS feed
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.14.tar.gz
(25.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
ext_llm-0.1.14-py3-none-any.whl
(31.3 kB
view details)
File details
Details for the file ext_llm-0.1.14.tar.gz.
File metadata
- Download URL: ext_llm-0.1.14.tar.gz
- Upload date:
- Size: 25.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe5d9e350ca52312d7afcb6d98b791e3d0da1c4f03018423dbf7197843de25d9
|
|
| MD5 |
214b4327d8148ae855cf8acdafc490f6
|
|
| BLAKE2b-256 |
0095e02bddf8ebfc005111b4588cdb72480b904ba64ed2f3da7d1ed09109889f
|
File details
Details for the file ext_llm-0.1.14-py3-none-any.whl.
File metadata
- Download URL: ext_llm-0.1.14-py3-none-any.whl
- Upload date:
- Size: 31.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8b7ea176d172888871846668f9a15ec9f1a66c02f19ed2bb6ef21c06b0f58a0
|
|
| MD5 |
11e8b0e1ec7aea8b203f43e264c367a0
|
|
| BLAKE2b-256 |
9fbb14eba5adf55f254ec0e7c960551ea91d22b2de8c5e670705b71f3f195511
|