Chat Completions
openwebui_client.completions
OpenWebUI completions class for handling file parameters in chat completions.
OpenWebUICompletions
Bases: Completions
Extended Completions class that supports the 'files' parameter for OpenWebUI.
Source code in openwebui_client/completions.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
__init__(client)
Initialize the OpenWebUI completions handler.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client
|
OpenAI
|
The OpenAI client to use for requests |
required |
Source code in openwebui_client/completions.py
create(*, messages, model, audio=NOT_GIVEN, files=NOT_GIVEN, frequency_penalty=NOT_GIVEN, function_call=NOT_GIVEN, functions=NOT_GIVEN, logit_bias=NOT_GIVEN, logprobs=NOT_GIVEN, max_completion_tokens=NOT_GIVEN, max_tokens=NOT_GIVEN, metadata=NOT_GIVEN, modalities=NOT_GIVEN, n=NOT_GIVEN, parallel_tool_calls=NOT_GIVEN, prediction=NOT_GIVEN, presence_penalty=NOT_GIVEN, reasoning_effort=NOT_GIVEN, response_format=NOT_GIVEN, seed=NOT_GIVEN, service_tier=NOT_GIVEN, stop=NOT_GIVEN, store=NOT_GIVEN, stream=NOT_GIVEN, stream_options=NOT_GIVEN, temperature=NOT_GIVEN, tool_choice=NOT_GIVEN, tools=NOT_GIVEN, top_logprobs=NOT_GIVEN, top_p=NOT_GIVEN, user=NOT_GIVEN, web_search_options=NOT_GIVEN, extra_headers=None, extra_query=None, extra_body=None, timeout=NOT_GIVEN)
Create a chat completion with support for the 'files' parameter.
This overrides the standard create method to handle the 'files' parameter that OpenWebUI supports but is not in the standard OpenAI API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
messages
|
Iterable[ChatCompletionMessageParam]
|
A list of messages comprising the conversation so far. |
required |
model
|
Union[str, ChatModel]
|
ID of the model to use. |
required |
files
|
Union[Optional[Collection[FileObject]], NotGiven]
|
A list of file IDs to attach to the completion request (OpenWebUI specific). |
NOT_GIVEN
|
audio
|
Union[Optional[ChatCompletionAudioParam], NotGiven]
|
Audio input parameters. |
NOT_GIVEN
|
frequency_penalty
|
Union[Optional[float], NotGiven]
|
Penalizes repeated tokens according to frequency. |
NOT_GIVEN
|
function_call
|
Union[FunctionCall, NotGiven]
|
Controls how the model uses functions. |
NOT_GIVEN
|
functions
|
Union[Iterable[Function], NotGiven]
|
Functions the model may call to interact with external systems. |
NOT_GIVEN
|
logit_bias
|
Union[Optional[Dict[str, int]], NotGiven]
|
Modifies likelihood of specific tokens appearing in completion. |
NOT_GIVEN
|
logprobs
|
Union[Optional[bool], NotGiven]
|
Whether to return log probabilities of the output tokens. |
NOT_GIVEN
|
max_completion_tokens
|
Union[Optional[int], NotGiven]
|
Maximum number of tokens that can be generated for completions. |
NOT_GIVEN
|
max_tokens
|
Union[Optional[int], NotGiven]
|
Maximum number of tokens to generate in the response. |
NOT_GIVEN
|
metadata
|
Union[Optional[Metadata], NotGiven]
|
Additional metadata to include in the completion. |
NOT_GIVEN
|
modalities
|
Union[Optional[List[Literal['text', 'audio']]], NotGiven]
|
List of modalities the model should handle. |
NOT_GIVEN
|
n
|
Union[Optional[int], NotGiven]
|
How many completions to generate for each prompt. |
NOT_GIVEN
|
parallel_tool_calls
|
Union[bool, NotGiven]
|
Whether function and tool calls should be made in parallel. |
NOT_GIVEN
|
prediction
|
Union[Optional[ChatCompletionPredictionContentParam], NotGiven]
|
Control specifics of prediction content. |
NOT_GIVEN
|
presence_penalty
|
Union[Optional[float], NotGiven]
|
Penalizes new tokens based on their presence so far. |
NOT_GIVEN
|
reasoning_effort
|
Union[Optional[ReasoningEffort], NotGiven]
|
Controls how much effort the model spends reasoning. |
NOT_GIVEN
|
response_format
|
Union[ResponseFormat, NotGiven]
|
Format in which the model should generate responses. |
NOT_GIVEN
|
seed
|
Union[Optional[int], NotGiven]
|
Enables deterministic sampling for consistent outputs. |
NOT_GIVEN
|
service_tier
|
Union[Optional[Literal['auto', 'default', 'flex']], NotGiven]
|
The service tier to use for the request. |
NOT_GIVEN
|
stop
|
Union[Optional[str], List[str], None, NotGiven]
|
Sequences where the API will stop generating further tokens. |
NOT_GIVEN
|
store
|
Union[Optional[bool], NotGiven]
|
Whether to persist completion for future retrieval. |
NOT_GIVEN
|
stream
|
Union[Optional[Literal[False]], Literal[True], NotGiven]
|
Whether to stream back partial progress. |
NOT_GIVEN
|
stream_options
|
Union[Optional[ChatCompletionStreamOptionsParam], NotGiven]
|
Options for streaming responses. |
NOT_GIVEN
|
temperature
|
Union[Optional[float], NotGiven]
|
Controls randomness in the response. |
NOT_GIVEN
|
tool_choice
|
Union[ChatCompletionToolChoiceOptionParam, NotGiven]
|
Controls how the model selects tools. |
NOT_GIVEN
|
tools
|
Union[Iterable[ChatCompletionToolParam], NotGiven]
|
List of tools the model may call. |
NOT_GIVEN
|
top_logprobs
|
Union[Optional[int], NotGiven]
|
Number of log probabilities to return per token. |
NOT_GIVEN
|
top_p
|
Union[Optional[float], NotGiven]
|
Controls diversity via nucleus sampling. |
NOT_GIVEN
|
user
|
Union[str, NotGiven]
|
Unique identifier representing your end-user. |
NOT_GIVEN
|
web_search_options
|
Union[WebSearchOptions, NotGiven]
|
Options to configure web search behavior. |
NOT_GIVEN
|
extra_headers
|
Union[Headers, None]
|
Additional HTTP headers. |
None
|
extra_query
|
Union[Query, None]
|
Additional query parameters. |
None
|
extra_body
|
Union[Body, None]
|
Additional body parameters. |
None
|
timeout
|
Union[float, Timeout, None, NotGiven]
|
Request timeout in seconds. |
NOT_GIVEN
|
Returns:
Type | Description |
---|---|
Union[ChatCompletion, Stream[ChatCompletionChunk]]
|
A ChatCompletion object containing the model's response. |
Source code in openwebui_client/completions.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|