A python lib to call LLM API models.
Project description
LLM API for python
This python library connects to llm-api using python, it was build to mimic OpenAI's python library
Usage
You can install this library using pip
pip install llm-api-python
After running llm-api, simply configure your client as if it's OpenAI's python binding
import llm_api
llm_api.api_key = "<your llm-api api key here>"
completion = llm_api.ChatCompletion.create(messages=[
{
"role": "system",
"content": "You are a helpful assistant, please answer the users' questions with honesty and accuracy."
}, {
"role": "user", "content": "What is the capital of France?"
}
]) # returns a chat completion object
completion = llm_api.ChatCompletion.create(messages=[
...
], stream=True) # returns a generator
completion = await llm_api.ChatCompletion.acreate(messages=[
...
]) # returns a chat completion object
completion = await llm_api.ChatCompletion.acreate(messages=[
...
], stream=True) # returns a async generator
Limitations
request_id
andrequest_ms
are currently returned emptycreated
timestamp is not set by the serverfinish_reason
is hardcoded tostop
usage
values are set toNone
- the
model
attribute is not being used
Credit
OpenAI's python implementation since this implementation is technically a fork of it.
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
llm_api_python-0.0.2.tar.gz
(10.0 kB
view details)
Built Distribution
File details
Details for the file llm_api_python-0.0.2.tar.gz
.
File metadata
- Download URL: llm_api_python-0.0.2.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.8.18 Linux/6.2.0-1014-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f245d3254489016a4723b66819e59d0de971f7c18737204e03a8e3402c87c18 |
|
MD5 | 589fe76a852177bd64afaf7200ed8901 |
|
BLAKE2b-256 | efe65644d651e1f36b5519b047988fdb5e44fcdaec4917bfde99e7c60676ad81 |
File details
Details for the file llm_api_python-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: llm_api_python-0.0.2-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.8.18 Linux/6.2.0-1014-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaee9fea7feb5060d0cf197f64ea2e68c3fc9930843e1fbf3f1b4e37c9a1c944 |
|
MD5 | d2029efbe3b1ea7e119fc539e408d80f |
|
BLAKE2b-256 | e0ecc854dce88fb34d273e7e6fe5868229a55153addc1c2b010fb9a01d476a0c |