Remote inference for language models
Project description
Remoteinference
Simple package to perform remote inference on language models of different providers.
Getting started
Install the package
pip install remoteinference
To access an OpenAI model simply import the OpenAILLM and use the chat_completion endpoint to send your contents to the server endpoint. As a response you will receive a valid JSON containing the typicall OpenAI API conform response in a dictionary:
import os
from remoteinference.models import OpenAILLM
from remoteinference.util import user_prompt
model_type = 'gpt-4o-mini'
model = OpenAILLM(
api_key=os.environ.get('OPEANI_API_KEY'),
model=model_type
)
response = model.chat_completion(
prompt=[user_prompt('Who are you?')],
temperature=0.5,
max_tokens=50
)
print(response['choices'][0]['message']['content'])
If you have a LLM running on a remote server using llama.cpp you can initalize the model by running:
from remoteinference.models import LlamaCPPLLM
from remoteinference.util import user_prompt
# initalize the model
model = LlamaCPPLLM(
server_address='localhost',
server_port=8080
)
# run simple completion
response = model.chat_completion(
prompt=[user_prompt('Who are you?')],
temperature=0.5,
max_tokens=50
)
print(response['choices'][0]['message']['content'])
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
remoteinference-0.0.6.tar.gz
(5.6 kB
view details)
File details
Details for the file remoteinference-0.0.6.tar.gz.
File metadata
- Download URL: remoteinference-0.0.6.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c124df05a517d3ecd8cc93e4e99279e30acc084335adfad155ec1696ea7628c6
|
|
| MD5 |
ba1942349087fbdc739996b78d68230c
|
|
| BLAKE2b-256 |
a36cfdedf06bd96c7e212df914b6dbc724fac2019b95a56ee8689b753df9c3c9
|