A python lib to call LLM API models.
Project description
LLM API for python
This python library connects to (llm-api)[https://github.com/1b5d/llm-api] using python, it was build to mimic (OpenAI's python library)[https://github.com/openai/openai-python]
Usage
You can install this library using pip
pip install llm-api-python
After running (llm-api)[https://github.com/1b5d/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.Completion.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 completion object
completion = llm_api.Completion.create(messages=[
...
], stream=True) # returns a generator
completion = await llm_api.Completion.acreate(messages=[
...
]) # returns a completion object
completion = await llm_api.Completion.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.1.tar.gz
(10.0 kB
view hashes)
Built Distribution
Close
Hashes for llm_api_python-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93bef15477e9d74dde2922e9cf43be0eaa9e25e7aedeaca98ce93b5431409cd6 |
|
MD5 | 19a8841e12af244f8608764db0e6573d |
|
BLAKE2b-256 | ee1e47f5f8eb39f7c98efc9d17a9cecf5fc50687e6512fec8bdb92c0cce453c1 |