From 17d75259ea8c2530f6c2e64f70a05ce83629dd91 Mon Sep 17 00:00:00 2001 From: LittleMouse Date: Wed, 23 Apr 2025 17:45:47 +0800 Subject: [PATCH] [upload] Add Docs --- docs/Chat_Completions.md | 44 +++++++++++++++++++++++++++++++++++++++ docs/Models.md | 20 ++++++++++++++++++ docs/Speech_to_text.md | 45 ++++++++++++++++++++++++++++++++++++++++ docs/Text_to_speech.md | 33 +++++++++++++++++++++++++++++ 4 files changed, 142 insertions(+) create mode 100644 docs/Chat_Completions.md create mode 100644 docs/Models.md create mode 100644 docs/Speech_to_text.md create mode 100644 docs/Text_to_speech.md diff --git a/docs/Chat_Completions.md b/docs/Chat_Completions.md new file mode 100644 index 0000000..cff675b --- /dev/null +++ b/docs/Chat_Completions.md @@ -0,0 +1,44 @@ +# Chat Completions +The Chat Completions API endpoint will generate a model response from a list of messages comprising a conversation. + +# Create chat completion +`post https://api.openai.com/v1/chat/completions` + +```python +from openai import OpenAI +openai = OpenAI( + api_key="sk-", + base_url="http://192.168.20.186:8000/v1" +) + +completion = client.chat.completions.create( + model="qwen2.5-0.5b-p256-ax630c", + messages=[ + {"role": "developer", "content": "You are a helpful assistant."}, + {"role": "user", "content": "Hello!"} + ] +) + +print(completion.choices[0].message) +``` + +## Request body + +### messages `array` Required +A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, images, and audio. + +### model `string` Required +Model ID used to generate the response, like `qwen2.5-0.5b-p256-ax630c` or `deepseek-r1-1.5b-p256-ax630c`. StackFlow offers a wide range of models with different capabilities, performance characteristics. Refer to the model Docs to browse and compare available models. + +### audio +`Audio output is not currently supported` + +### function_call +`function_call is not currently supported` + +### max_tokens `integer` Optional +The maximum number of tokens that can be generated in the chat completion. + +### response_format `object` Optional +An object specifying the format that the model must output. +`Currently only supported format is json_object.` \ No newline at end of file diff --git a/docs/Models.md b/docs/Models.md new file mode 100644 index 0000000..9229088 --- /dev/null +++ b/docs/Models.md @@ -0,0 +1,20 @@ +# Models +List and describe the various models available in the API. You can refer to the Models documentation to understand what models are available and the differences between them. + +# List models +`get http://192.168.20.186:8000/v1/models` + +Lists the currently available models, and provides basic information about each one such as the owner and availability. + +```python +from openai import OpenAI +openai = OpenAI( + api_key="sk-", + base_url="http://192.168.20.186:8000/v1" +) + +client.models.list() +``` + +## Returns +A list of model objects. \ No newline at end of file diff --git a/docs/Speech_to_text.md b/docs/Speech_to_text.md new file mode 100644 index 0000000..94ba957 --- /dev/null +++ b/docs/Speech_to_text.md @@ -0,0 +1,45 @@ +# Audio +Learn how to turn audio into text or text into audio. + +# Create speech +post https://192.168.20.186:8000/v1/audio/speech + +Generates audio from the input text. + +```python +from pathlib import Path +from openai import OpenAI + +openai = OpenAI( + api_key="sk-", + base_url="http://192.168.20.186:8000/v1" +) + +speech_file_path = Path(__file__).parent / "speech.mp3" +with openai.audio.speech.with_streaming_response.create( + model="gpt-4o-mini-tts", + voice="alloy", + input="The quick brown fox jumped over the lazy dog." +) as response: + response.stream_to_file(speech_file_path) +``` + +## Request body + +### input `string` Required +The text to generate audio for. The maximum length is `1024` characters. + +### model `string` Required +One of the available TTS models: `melotts-zh-cn`, `melotts-en-us`. + +### voice +`Voice selection is not currently supported` + +### response_format `string` Optional Defaults to mp3 +The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav`, and `pcm`. + +### speed `number` Optional Defaults to 1 +The speed of the generated audio. Select a value from `0.25` to `2.0`. `1.0` is the default. + +## Returns +The audio file content. \ No newline at end of file diff --git a/docs/Text_to_speech.md b/docs/Text_to_speech.md new file mode 100644 index 0000000..b7f8757 --- /dev/null +++ b/docs/Text_to_speech.md @@ -0,0 +1,33 @@ +# Create transcription +`post http://192.168.20.186:8000/v1/audio/transcriptions` +Transcribes audio into the input language. + +```python +from openai import OpenAI +client = OpenAI( + api_key="sk-", + base_url="http://192.168.20.186:8000/v1" +) + +audio_file = open("speech.mp3", "rb") +transcript = client.audio.transcriptions.create( + model="whisper-tiny", + language="en", + file=audio_file +) +``` + +## Request body + +### file file Required +The audio file object (not file name) to transcribe, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. + +### model `string` Required +ID of the model to use. The options are `whisper-tiny`, `whisper-base`, and `whisper-small`. + +### language `string` Required +The language of the input audio. Supplying the input language in ISO-639-1 (e.g. en) format will improve accuracy and latency. + +### response_format string Optional +Defaults to json +`Currently only supported format is json.` \ No newline at end of file