Updates to chat completions and completions endpoints
For the completions and chat completions endpoints, we use extra_body for additional parameters.
If audio_format is present, the prompt will be transcribed to text. It is assumed it is base64 encoded audio in the audio_format specified. Accepted formats currently are wav, m4a, webm, and potentially others that ffmpeg can convert.
If system_message is present, it will be used as the system message for the completion.
If voice is present, the completion will be converted to audio using the specified voice.
If not streaming, the audio will be returned in the response in the audio beside the text or content keys.
If streaming, the audio will be streamed in the response in audio/wav format.
Usage example:
import openai
openai.base_url = "http://localhost:8091/v1/"
openai.api_key = "Your LOCAL_LLM_API_KEY from your .env file"
completion = openai.completions.create(
model="phi-2-dpo",
prompt=voice_response["data"],
temperature=0.3,
max_tokens=1024,
top_p=0.90,
n=1,
stream=False,
extra_body={"system_message": "You are a creative assistant.", "audio_format": "wav", "voice": "default"},
)
print(completion.choices[0].text)
# Base64 audio that you can save to a wav file to play, or play through other means.
audio_response = completion.choices[0]["audio"]
Added Cloning Text to Speech
wav
file and put it in thevoices
folder to use it.Usage example:
Added Speech to Text functionality
Usage example:
Updates to chat completions and completions endpoints
For the completions and chat completions endpoints, we use
extra_body
for additional parameters.audio_format
is present, the prompt will be transcribed to text. It is assumed it is base64 encoded audio in theaudio_format
specified. Accepted formats currently arewav
,m4a
,webm
, and potentially others thatffmpeg
can convert.system_message
is present, it will be used as the system message for the completion.voice
is present, the completion will be converted to audio using the specified voice.audio
beside thetext
orcontent
keys.audio/wav
format.Usage example: