telnyx 5.100.0 → 5.101.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/telnyx/models/ai/chat_create_completion_params.rb +36 -1
- data/lib/telnyx/models/ai/openai/chat_create_completion_params.rb +458 -0
- data/lib/telnyx/models/ai/openai/chat_create_completion_response.rb +12 -0
- data/lib/telnyx/models/ai/openai_list_models_params.rb +16 -0
- data/lib/telnyx/models/ai/openai_list_models_response.rb +52 -0
- data/lib/telnyx/resources/ai/chat.rb +9 -2
- data/lib/telnyx/resources/ai/openai/chat.rb +96 -0
- data/lib/telnyx/resources/ai/openai.rb +26 -0
- data/lib/telnyx/resources/ai.rb +7 -5
- data/lib/telnyx/version.rb +1 -1
- data/lib/telnyx.rb +5 -0
- data/rbi/telnyx/models/ai/chat_create_completion_params.rbi +58 -0
- data/rbi/telnyx/models/ai/openai/chat_create_completion_params.rbi +963 -0
- data/rbi/telnyx/models/ai/openai/chat_create_completion_response.rbi +15 -0
- data/rbi/telnyx/models/ai/openai_list_models_params.rbi +29 -0
- data/rbi/telnyx/models/ai/openai_list_models_response.rbi +96 -0
- data/rbi/telnyx/resources/ai/chat.rbi +11 -1
- data/rbi/telnyx/resources/ai/openai/chat.rbi +147 -0
- data/rbi/telnyx/resources/ai/openai.rbi +16 -0
- data/rbi/telnyx/resources/ai.rbi +5 -5
- data/sig/telnyx/models/ai/chat_create_completion_params.rbs +26 -0
- data/sig/telnyx/models/ai/openai/chat_create_completion_params.rbs +434 -0
- data/sig/telnyx/models/ai/openai/chat_create_completion_response.rbs +11 -0
- data/sig/telnyx/models/ai/openai_list_models_params.rbs +17 -0
- data/sig/telnyx/models/ai/openai_list_models_response.rbs +58 -0
- data/sig/telnyx/resources/ai/chat.rbs +2 -0
- data/sig/telnyx/resources/ai/openai/chat.rbs +41 -0
- data/sig/telnyx/resources/ai/openai.rbs +6 -0
- metadata +17 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b788d1ec382c32e4625205edebf53eb059dc17bcd9d695140ba97acb0d79364c
|
|
4
|
+
data.tar.gz: 4c680da1dbfbce503ac6fd68ad1367a3c1c357746df9fcbbc9cc487860bf15e2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45db13e01d2bd85f40ca9ef2f070a632f9cd5028431a4509ad05084b9a0f5ba9184080eddda29402b2fbe254830f646101c44325d285d2f8c5dfb16f97c5bc54
|
|
7
|
+
data.tar.gz: 77978113e121bd4d8b47893dc143d54a04b4cc9ad28b79ce77d56d50b570fc7d4d45172d529ac5d550505881c5332887bc1f94685cf8e0ad3ef2daf1d782a043
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 5.101.0 (2026-05-07)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v5.100.0...v5.101.0](https://github.com/team-telnyx/telnyx-ruby/compare/v5.100.0...v5.101.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* inference: expose chat completions and models under /ai/openai ([4711564](https://github.com/team-telnyx/telnyx-ruby/commit/47115648db8895fabe3913e086b23705c8a1851a))
|
|
10
|
+
|
|
3
11
|
## 5.100.0 (2026-05-06)
|
|
4
12
|
|
|
5
13
|
Full Changelog: [v5.99.0...v5.100.0](https://github.com/team-telnyx/telnyx-ruby/compare/v5.99.0...v5.100.0)
|
data/README.md
CHANGED
|
@@ -125,6 +125,21 @@ module Telnyx
|
|
|
125
125
|
# @return [Telnyx::Models::AI::ChatCreateCompletionParams::ResponseFormat, nil]
|
|
126
126
|
optional :response_format, -> { Telnyx::AI::ChatCreateCompletionParams::ResponseFormat }
|
|
127
127
|
|
|
128
|
+
# @!attribute seed
|
|
129
|
+
# If specified, the system will make a best effort to sample deterministically,
|
|
130
|
+
# such that repeated requests with the same `seed` and parameters should return
|
|
131
|
+
# the same result.
|
|
132
|
+
#
|
|
133
|
+
# @return [Integer, nil]
|
|
134
|
+
optional :seed, Integer
|
|
135
|
+
|
|
136
|
+
# @!attribute stop
|
|
137
|
+
# Up to 4 sequences where the API will stop generating further tokens. The
|
|
138
|
+
# returned text will not contain the stop sequence.
|
|
139
|
+
#
|
|
140
|
+
# @return [String, Array<String>, nil]
|
|
141
|
+
optional :stop, union: -> { Telnyx::AI::ChatCreateCompletionParams::Stop }
|
|
142
|
+
|
|
128
143
|
# @!attribute stream
|
|
129
144
|
# Whether or not to stream data-only server-sent events as they become available.
|
|
130
145
|
#
|
|
@@ -178,7 +193,7 @@ module Telnyx
|
|
|
178
193
|
# @return [Boolean, nil]
|
|
179
194
|
optional :use_beam_search, Telnyx::Internal::Type::Boolean
|
|
180
195
|
|
|
181
|
-
# @!method initialize(messages:, api_key_ref: nil, best_of: nil, early_stopping: nil, enable_thinking: nil, frequency_penalty: nil, guided_choice: nil, guided_json: nil, guided_regex: nil, length_penalty: nil, logprobs: nil, max_tokens: nil, min_p: nil, model: nil, n: nil, presence_penalty: nil, response_format: nil, stream: nil, temperature: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, use_beam_search: nil, request_options: {})
|
|
196
|
+
# @!method initialize(messages:, api_key_ref: nil, best_of: nil, early_stopping: nil, enable_thinking: nil, frequency_penalty: nil, guided_choice: nil, guided_json: nil, guided_regex: nil, length_penalty: nil, logprobs: nil, max_tokens: nil, min_p: nil, model: nil, n: nil, presence_penalty: nil, response_format: nil, seed: nil, stop: nil, stream: nil, temperature: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, use_beam_search: nil, request_options: {})
|
|
182
197
|
# Some parameter documentations has been truncated, see
|
|
183
198
|
# {Telnyx::Models::AI::ChatCreateCompletionParams} for more details.
|
|
184
199
|
#
|
|
@@ -216,6 +231,10 @@ module Telnyx
|
|
|
216
231
|
#
|
|
217
232
|
# @param response_format [Telnyx::Models::AI::ChatCreateCompletionParams::ResponseFormat] Use this is you want to guarantee a JSON output without defining a schema. For c
|
|
218
233
|
#
|
|
234
|
+
# @param seed [Integer] If specified, the system will make a best effort to sample deterministically, su
|
|
235
|
+
#
|
|
236
|
+
# @param stop [String, Array<String>] Up to 4 sequences where the API will stop generating further tokens. The returne
|
|
237
|
+
#
|
|
219
238
|
# @param stream [Boolean] Whether or not to stream data-only server-sent events as they become available.
|
|
220
239
|
#
|
|
221
240
|
# @param temperature [Float] Adjusts the "creativity" of the model. Lower values make the model more determin
|
|
@@ -337,6 +356,22 @@ module Telnyx
|
|
|
337
356
|
end
|
|
338
357
|
end
|
|
339
358
|
|
|
359
|
+
# Up to 4 sequences where the API will stop generating further tokens. The
|
|
360
|
+
# returned text will not contain the stop sequence.
|
|
361
|
+
module Stop
|
|
362
|
+
extend Telnyx::Internal::Type::Union
|
|
363
|
+
|
|
364
|
+
variant String
|
|
365
|
+
|
|
366
|
+
variant -> { Telnyx::Models::AI::ChatCreateCompletionParams::Stop::StringArray }
|
|
367
|
+
|
|
368
|
+
# @!method self.variants
|
|
369
|
+
# @return [Array(String, Array<String>)]
|
|
370
|
+
|
|
371
|
+
# @type [Telnyx::Internal::Type::Converter]
|
|
372
|
+
StringArray = Telnyx::Internal::Type::ArrayOf[String]
|
|
373
|
+
end
|
|
374
|
+
|
|
340
375
|
module ToolChoice
|
|
341
376
|
extend Telnyx::Internal::Type::Enum
|
|
342
377
|
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Telnyx
|
|
4
|
+
module Models
|
|
5
|
+
module AI
|
|
6
|
+
module OpenAI
|
|
7
|
+
# @see Telnyx::Resources::AI::OpenAI::Chat#create_completion
|
|
8
|
+
class ChatCreateCompletionParams < Telnyx::Internal::Type::BaseModel
|
|
9
|
+
extend Telnyx::Internal::Type::RequestParameters::Converter
|
|
10
|
+
include Telnyx::Internal::Type::RequestParameters
|
|
11
|
+
|
|
12
|
+
# @!attribute messages
|
|
13
|
+
# A list of the previous chat messages for context.
|
|
14
|
+
#
|
|
15
|
+
# @return [Array<Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message>]
|
|
16
|
+
required :messages,
|
|
17
|
+
-> { Telnyx::Internal::Type::ArrayOf[Telnyx::AI::OpenAI::ChatCreateCompletionParams::Message] }
|
|
18
|
+
|
|
19
|
+
# @!attribute api_key_ref
|
|
20
|
+
# If you are using an external inference provider like xAI or OpenAI, this field
|
|
21
|
+
# allows you to pass along a reference to your API key. After creating an
|
|
22
|
+
# [integration secret](https://developers.telnyx.com/api-reference/integration-secrets/create-a-secret)
|
|
23
|
+
# for you API key, pass the secret's `identifier` in this field.
|
|
24
|
+
#
|
|
25
|
+
# @return [String, nil]
|
|
26
|
+
optional :api_key_ref, String
|
|
27
|
+
|
|
28
|
+
# @!attribute best_of
|
|
29
|
+
# This is used with `use_beam_search` to determine how many candidate beams to
|
|
30
|
+
# explore.
|
|
31
|
+
#
|
|
32
|
+
# @return [Integer, nil]
|
|
33
|
+
optional :best_of, Integer
|
|
34
|
+
|
|
35
|
+
# @!attribute early_stopping
|
|
36
|
+
# This is used with `use_beam_search`. If `true`, generation stops as soon as
|
|
37
|
+
# there are `best_of` complete candidates; if `false`, a heuristic is applied and
|
|
38
|
+
# the generation stops when is it very unlikely to find better candidates.
|
|
39
|
+
#
|
|
40
|
+
# @return [Boolean, nil]
|
|
41
|
+
optional :early_stopping, Telnyx::Internal::Type::Boolean
|
|
42
|
+
|
|
43
|
+
# @!attribute enable_thinking
|
|
44
|
+
# Whether to enable the thinking/reasoning phase for models that support it (e.g.,
|
|
45
|
+
# QwQ, Qwen3). When set to false, the model will skip the internal reasoning step
|
|
46
|
+
# and respond directly, which can reduce latency. Defaults to true.
|
|
47
|
+
#
|
|
48
|
+
# @return [Boolean, nil]
|
|
49
|
+
optional :enable_thinking, Telnyx::Internal::Type::Boolean
|
|
50
|
+
|
|
51
|
+
# @!attribute frequency_penalty
|
|
52
|
+
# Higher values will penalize the model from repeating the same output tokens.
|
|
53
|
+
#
|
|
54
|
+
# @return [Float, nil]
|
|
55
|
+
optional :frequency_penalty, Float
|
|
56
|
+
|
|
57
|
+
# @!attribute guided_choice
|
|
58
|
+
# If specified, the output will be exactly one of the choices.
|
|
59
|
+
#
|
|
60
|
+
# @return [Array<String>, nil]
|
|
61
|
+
optional :guided_choice, Telnyx::Internal::Type::ArrayOf[String]
|
|
62
|
+
|
|
63
|
+
# @!attribute guided_json
|
|
64
|
+
# Must be a valid JSON schema. If specified, the output will follow the JSON
|
|
65
|
+
# schema.
|
|
66
|
+
#
|
|
67
|
+
# @return [Hash{Symbol=>Object}, nil]
|
|
68
|
+
optional :guided_json, Telnyx::Internal::Type::HashOf[Telnyx::Internal::Type::Unknown]
|
|
69
|
+
|
|
70
|
+
# @!attribute guided_regex
|
|
71
|
+
# If specified, the output will follow the regex pattern.
|
|
72
|
+
#
|
|
73
|
+
# @return [String, nil]
|
|
74
|
+
optional :guided_regex, String
|
|
75
|
+
|
|
76
|
+
# @!attribute length_penalty
|
|
77
|
+
# This is used with `use_beam_search` to prefer shorter or longer completions.
|
|
78
|
+
#
|
|
79
|
+
# @return [Float, nil]
|
|
80
|
+
optional :length_penalty, Float
|
|
81
|
+
|
|
82
|
+
# @!attribute logprobs
|
|
83
|
+
# Whether to return log probabilities of the output tokens or not. If true,
|
|
84
|
+
# returns the log probabilities of each output token returned in the `content` of
|
|
85
|
+
# `message`.
|
|
86
|
+
#
|
|
87
|
+
# @return [Boolean, nil]
|
|
88
|
+
optional :logprobs, Telnyx::Internal::Type::Boolean
|
|
89
|
+
|
|
90
|
+
# @!attribute max_tokens
|
|
91
|
+
# Maximum number of completion tokens the model should generate.
|
|
92
|
+
#
|
|
93
|
+
# @return [Integer, nil]
|
|
94
|
+
optional :max_tokens, Integer
|
|
95
|
+
|
|
96
|
+
# @!attribute min_p
|
|
97
|
+
# This is an alternative to `top_p` that
|
|
98
|
+
# [many prefer](https://github.com/huggingface/transformers/issues/27670). Must be
|
|
99
|
+
# in [0, 1].
|
|
100
|
+
#
|
|
101
|
+
# @return [Float, nil]
|
|
102
|
+
optional :min_p, Float
|
|
103
|
+
|
|
104
|
+
# @!attribute model
|
|
105
|
+
# The language model to chat with.
|
|
106
|
+
#
|
|
107
|
+
# @return [String, nil]
|
|
108
|
+
optional :model, String
|
|
109
|
+
|
|
110
|
+
# @!attribute n
|
|
111
|
+
# This will return multiple choices for you instead of a single chat completion.
|
|
112
|
+
#
|
|
113
|
+
# @return [Float, nil]
|
|
114
|
+
optional :n, Float
|
|
115
|
+
|
|
116
|
+
# @!attribute presence_penalty
|
|
117
|
+
# Higher values will penalize the model from repeating the same output tokens.
|
|
118
|
+
#
|
|
119
|
+
# @return [Float, nil]
|
|
120
|
+
optional :presence_penalty, Float
|
|
121
|
+
|
|
122
|
+
# @!attribute response_format
|
|
123
|
+
# Use this is you want to guarantee a JSON output without defining a schema. For
|
|
124
|
+
# control over the schema, use `guided_json`.
|
|
125
|
+
#
|
|
126
|
+
# @return [Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::ResponseFormat, nil]
|
|
127
|
+
optional :response_format, -> { Telnyx::AI::OpenAI::ChatCreateCompletionParams::ResponseFormat }
|
|
128
|
+
|
|
129
|
+
# @!attribute seed
|
|
130
|
+
# If specified, the system will make a best effort to sample deterministically,
|
|
131
|
+
# such that repeated requests with the same `seed` and parameters should return
|
|
132
|
+
# the same result.
|
|
133
|
+
#
|
|
134
|
+
# @return [Integer, nil]
|
|
135
|
+
optional :seed, Integer
|
|
136
|
+
|
|
137
|
+
# @!attribute stop
|
|
138
|
+
# Up to 4 sequences where the API will stop generating further tokens. The
|
|
139
|
+
# returned text will not contain the stop sequence.
|
|
140
|
+
#
|
|
141
|
+
# @return [String, Array<String>, nil]
|
|
142
|
+
optional :stop, union: -> { Telnyx::AI::OpenAI::ChatCreateCompletionParams::Stop }
|
|
143
|
+
|
|
144
|
+
# @!attribute stream
|
|
145
|
+
# Whether or not to stream data-only server-sent events as they become available.
|
|
146
|
+
#
|
|
147
|
+
# @return [Boolean, nil]
|
|
148
|
+
optional :stream, Telnyx::Internal::Type::Boolean
|
|
149
|
+
|
|
150
|
+
# @!attribute temperature
|
|
151
|
+
# Adjusts the "creativity" of the model. Lower values make the model more
|
|
152
|
+
# deterministic and repetitive, while higher values make the model more random and
|
|
153
|
+
# creative.
|
|
154
|
+
#
|
|
155
|
+
# @return [Float, nil]
|
|
156
|
+
optional :temperature, Float
|
|
157
|
+
|
|
158
|
+
# @!attribute tool_choice
|
|
159
|
+
#
|
|
160
|
+
# @return [Symbol, Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::ToolChoice, nil]
|
|
161
|
+
optional :tool_choice, enum: -> { Telnyx::AI::OpenAI::ChatCreateCompletionParams::ToolChoice }
|
|
162
|
+
|
|
163
|
+
# @!attribute tools
|
|
164
|
+
# The `function` tool type follows the same schema as the
|
|
165
|
+
# [OpenAI Chat Completions API](https://platform.openai.com/docs/api-reference/chat).
|
|
166
|
+
# The `retrieval` tool type is unique to Telnyx. You may pass a list of
|
|
167
|
+
# [embedded storage buckets](https://developers.telnyx.com/api-reference/embeddings/embed-documents)
|
|
168
|
+
# for retrieval-augmented generation.
|
|
169
|
+
#
|
|
170
|
+
# @return [Array<Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Tool::Function, Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Tool::Retrieval>, nil]
|
|
171
|
+
optional :tools,
|
|
172
|
+
-> { Telnyx::Internal::Type::ArrayOf[union: Telnyx::AI::OpenAI::ChatCreateCompletionParams::Tool] }
|
|
173
|
+
|
|
174
|
+
# @!attribute top_logprobs
|
|
175
|
+
# This is used with `logprobs`. An integer between 0 and 20 specifying the number
|
|
176
|
+
# of most likely tokens to return at each token position, each with an associated
|
|
177
|
+
# log probability.
|
|
178
|
+
#
|
|
179
|
+
# @return [Integer, nil]
|
|
180
|
+
optional :top_logprobs, Integer
|
|
181
|
+
|
|
182
|
+
# @!attribute top_p
|
|
183
|
+
# An alternative or complement to `temperature`. This adjusts how many of the top
|
|
184
|
+
# possibilities to consider.
|
|
185
|
+
#
|
|
186
|
+
# @return [Float, nil]
|
|
187
|
+
optional :top_p, Float
|
|
188
|
+
|
|
189
|
+
# @!attribute use_beam_search
|
|
190
|
+
# Setting this to `true` will allow the model to
|
|
191
|
+
# [explore more completion options](https://huggingface.co/blog/how-to-generate#beam-search).
|
|
192
|
+
# This is not supported by OpenAI.
|
|
193
|
+
#
|
|
194
|
+
# @return [Boolean, nil]
|
|
195
|
+
optional :use_beam_search, Telnyx::Internal::Type::Boolean
|
|
196
|
+
|
|
197
|
+
# @!method initialize(messages:, api_key_ref: nil, best_of: nil, early_stopping: nil, enable_thinking: nil, frequency_penalty: nil, guided_choice: nil, guided_json: nil, guided_regex: nil, length_penalty: nil, logprobs: nil, max_tokens: nil, min_p: nil, model: nil, n: nil, presence_penalty: nil, response_format: nil, seed: nil, stop: nil, stream: nil, temperature: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, use_beam_search: nil, request_options: {})
|
|
198
|
+
# Some parameter documentations has been truncated, see
|
|
199
|
+
# {Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams} for more details.
|
|
200
|
+
#
|
|
201
|
+
# @param messages [Array<Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message>] A list of the previous chat messages for context.
|
|
202
|
+
#
|
|
203
|
+
# @param api_key_ref [String] If you are using an external inference provider like xAI or OpenAI, this field a
|
|
204
|
+
#
|
|
205
|
+
# @param best_of [Integer] This is used with `use_beam_search` to determine how many candidate beams to exp
|
|
206
|
+
#
|
|
207
|
+
# @param early_stopping [Boolean] This is used with `use_beam_search`. If `true`, generation stops as soon as ther
|
|
208
|
+
#
|
|
209
|
+
# @param enable_thinking [Boolean] Whether to enable the thinking/reasoning phase for models that support it (e.g.,
|
|
210
|
+
#
|
|
211
|
+
# @param frequency_penalty [Float] Higher values will penalize the model from repeating the same output tokens.
|
|
212
|
+
#
|
|
213
|
+
# @param guided_choice [Array<String>] If specified, the output will be exactly one of the choices.
|
|
214
|
+
#
|
|
215
|
+
# @param guided_json [Hash{Symbol=>Object}] Must be a valid JSON schema. If specified, the output will follow the JSON schem
|
|
216
|
+
#
|
|
217
|
+
# @param guided_regex [String] If specified, the output will follow the regex pattern.
|
|
218
|
+
#
|
|
219
|
+
# @param length_penalty [Float] This is used with `use_beam_search` to prefer shorter or longer completions.
|
|
220
|
+
#
|
|
221
|
+
# @param logprobs [Boolean] Whether to return log probabilities of the output tokens or not. If true, return
|
|
222
|
+
#
|
|
223
|
+
# @param max_tokens [Integer] Maximum number of completion tokens the model should generate.
|
|
224
|
+
#
|
|
225
|
+
# @param min_p [Float] This is an alternative to `top_p` that [many prefer](https://github.com/huggingf
|
|
226
|
+
#
|
|
227
|
+
# @param model [String] The language model to chat with.
|
|
228
|
+
#
|
|
229
|
+
# @param n [Float] This will return multiple choices for you instead of a single chat completion.
|
|
230
|
+
#
|
|
231
|
+
# @param presence_penalty [Float] Higher values will penalize the model from repeating the same output tokens.
|
|
232
|
+
#
|
|
233
|
+
# @param response_format [Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::ResponseFormat] Use this is you want to guarantee a JSON output without defining a schema. For c
|
|
234
|
+
#
|
|
235
|
+
# @param seed [Integer] If specified, the system will make a best effort to sample deterministically, su
|
|
236
|
+
#
|
|
237
|
+
# @param stop [String, Array<String>] Up to 4 sequences where the API will stop generating further tokens. The returne
|
|
238
|
+
#
|
|
239
|
+
# @param stream [Boolean] Whether or not to stream data-only server-sent events as they become available.
|
|
240
|
+
#
|
|
241
|
+
# @param temperature [Float] Adjusts the "creativity" of the model. Lower values make the model more determin
|
|
242
|
+
#
|
|
243
|
+
# @param tool_choice [Symbol, Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::ToolChoice]
|
|
244
|
+
#
|
|
245
|
+
# @param tools [Array<Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Tool::Function, Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Tool::Retrieval>] The `function` tool type follows the same schema as the [OpenAI Chat Completions
|
|
246
|
+
#
|
|
247
|
+
# @param top_logprobs [Integer] This is used with `logprobs`. An integer between 0 and 20 specifying the number
|
|
248
|
+
#
|
|
249
|
+
# @param top_p [Float] An alternative or complement to `temperature`. This adjusts how many of the top
|
|
250
|
+
#
|
|
251
|
+
# @param use_beam_search [Boolean] Setting this to `true` will allow the model to [explore more completion options]
|
|
252
|
+
#
|
|
253
|
+
# @param request_options [Telnyx::RequestOptions, Hash{Symbol=>Object}]
|
|
254
|
+
|
|
255
|
+
class Message < Telnyx::Internal::Type::BaseModel
|
|
256
|
+
# @!attribute content
|
|
257
|
+
#
|
|
258
|
+
# @return [String, Array<Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message::Content::TextAndImageArray>]
|
|
259
|
+
required :content, union: -> { Telnyx::AI::OpenAI::ChatCreateCompletionParams::Message::Content }
|
|
260
|
+
|
|
261
|
+
# @!attribute role
|
|
262
|
+
#
|
|
263
|
+
# @return [Symbol, Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message::Role]
|
|
264
|
+
required :role, enum: -> { Telnyx::AI::OpenAI::ChatCreateCompletionParams::Message::Role }
|
|
265
|
+
|
|
266
|
+
# @!method initialize(content:, role:)
|
|
267
|
+
# @param content [String, Array<Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message::Content::TextAndImageArray>]
|
|
268
|
+
# @param role [Symbol, Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message::Role]
|
|
269
|
+
|
|
270
|
+
# @see Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message#content
|
|
271
|
+
module Content
|
|
272
|
+
extend Telnyx::Internal::Type::Union
|
|
273
|
+
|
|
274
|
+
variant String
|
|
275
|
+
|
|
276
|
+
variant -> { Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message::Content::TextAndImage2DArray }
|
|
277
|
+
|
|
278
|
+
class TextAndImageArray < Telnyx::Internal::Type::BaseModel
|
|
279
|
+
# @!attribute type
|
|
280
|
+
#
|
|
281
|
+
# @return [Symbol, Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message::Content::TextAndImageArray::Type]
|
|
282
|
+
required :type,
|
|
283
|
+
enum: -> { Telnyx::AI::OpenAI::ChatCreateCompletionParams::Message::Content::TextAndImageArray::Type }
|
|
284
|
+
|
|
285
|
+
# @!attribute image_url
|
|
286
|
+
#
|
|
287
|
+
# @return [String, nil]
|
|
288
|
+
optional :image_url, String
|
|
289
|
+
|
|
290
|
+
# @!attribute text
|
|
291
|
+
#
|
|
292
|
+
# @return [String, nil]
|
|
293
|
+
optional :text, String
|
|
294
|
+
|
|
295
|
+
# @!method initialize(type:, image_url: nil, text: nil)
|
|
296
|
+
# @param type [Symbol, Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message::Content::TextAndImageArray::Type]
|
|
297
|
+
# @param image_url [String]
|
|
298
|
+
# @param text [String]
|
|
299
|
+
|
|
300
|
+
# @see Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message::Content::TextAndImageArray#type
|
|
301
|
+
module Type
|
|
302
|
+
extend Telnyx::Internal::Type::Enum
|
|
303
|
+
|
|
304
|
+
TEXT = :text
|
|
305
|
+
IMAGE_URL = :image_url
|
|
306
|
+
|
|
307
|
+
# @!method self.values
|
|
308
|
+
# @return [Array<Symbol>]
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
|
|
312
|
+
# @!method self.variants
|
|
313
|
+
# @return [Array(String, Array<Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message::Content::TextAndImageArray>)]
|
|
314
|
+
|
|
315
|
+
# @type [Telnyx::Internal::Type::Converter]
|
|
316
|
+
TextAndImage2DArray =
|
|
317
|
+
Telnyx::Internal::Type::ArrayOf[-> {
|
|
318
|
+
Telnyx::AI::OpenAI::ChatCreateCompletionParams::Message::Content::TextAndImageArray
|
|
319
|
+
}]
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
# @see Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Message#role
|
|
323
|
+
module Role
|
|
324
|
+
extend Telnyx::Internal::Type::Enum
|
|
325
|
+
|
|
326
|
+
SYSTEM = :system
|
|
327
|
+
USER = :user
|
|
328
|
+
ASSISTANT = :assistant
|
|
329
|
+
TOOL = :tool
|
|
330
|
+
|
|
331
|
+
# @!method self.values
|
|
332
|
+
# @return [Array<Symbol>]
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
class ResponseFormat < Telnyx::Internal::Type::BaseModel
|
|
337
|
+
# @!attribute type
|
|
338
|
+
#
|
|
339
|
+
# @return [Symbol, Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::ResponseFormat::Type]
|
|
340
|
+
required :type, enum: -> { Telnyx::AI::OpenAI::ChatCreateCompletionParams::ResponseFormat::Type }
|
|
341
|
+
|
|
342
|
+
# @!method initialize(type:)
|
|
343
|
+
# Use this is you want to guarantee a JSON output without defining a schema. For
|
|
344
|
+
# control over the schema, use `guided_json`.
|
|
345
|
+
#
|
|
346
|
+
# @param type [Symbol, Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::ResponseFormat::Type]
|
|
347
|
+
|
|
348
|
+
# @see Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::ResponseFormat#type
|
|
349
|
+
module Type
|
|
350
|
+
extend Telnyx::Internal::Type::Enum
|
|
351
|
+
|
|
352
|
+
TEXT = :text
|
|
353
|
+
JSON_OBJECT = :json_object
|
|
354
|
+
|
|
355
|
+
# @!method self.values
|
|
356
|
+
# @return [Array<Symbol>]
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Up to 4 sequences where the API will stop generating further tokens. The
|
|
361
|
+
# returned text will not contain the stop sequence.
|
|
362
|
+
module Stop
|
|
363
|
+
extend Telnyx::Internal::Type::Union
|
|
364
|
+
|
|
365
|
+
variant String
|
|
366
|
+
|
|
367
|
+
variant -> { Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Stop::StringArray }
|
|
368
|
+
|
|
369
|
+
# @!method self.variants
|
|
370
|
+
# @return [Array(String, Array<String>)]
|
|
371
|
+
|
|
372
|
+
# @type [Telnyx::Internal::Type::Converter]
|
|
373
|
+
StringArray = Telnyx::Internal::Type::ArrayOf[String]
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
module ToolChoice
|
|
377
|
+
extend Telnyx::Internal::Type::Enum
|
|
378
|
+
|
|
379
|
+
NONE = :none
|
|
380
|
+
AUTO = :auto
|
|
381
|
+
REQUIRED = :required
|
|
382
|
+
|
|
383
|
+
# @!method self.values
|
|
384
|
+
# @return [Array<Symbol>]
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
module Tool
|
|
388
|
+
extend Telnyx::Internal::Type::Union
|
|
389
|
+
|
|
390
|
+
discriminator :type
|
|
391
|
+
|
|
392
|
+
variant :function, -> { Telnyx::AI::OpenAI::ChatCreateCompletionParams::Tool::Function }
|
|
393
|
+
|
|
394
|
+
variant :retrieval, -> { Telnyx::AI::OpenAI::ChatCreateCompletionParams::Tool::Retrieval }
|
|
395
|
+
|
|
396
|
+
class Function < Telnyx::Internal::Type::BaseModel
|
|
397
|
+
# @!attribute function
|
|
398
|
+
#
|
|
399
|
+
# @return [Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Tool::Function::Function]
|
|
400
|
+
required :function, -> { Telnyx::AI::OpenAI::ChatCreateCompletionParams::Tool::Function::Function }
|
|
401
|
+
|
|
402
|
+
# @!attribute type
|
|
403
|
+
#
|
|
404
|
+
# @return [Symbol, :function]
|
|
405
|
+
required :type, const: :function
|
|
406
|
+
|
|
407
|
+
# @!method initialize(function:, type: :function)
|
|
408
|
+
# @param function [Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Tool::Function::Function]
|
|
409
|
+
# @param type [Symbol, :function]
|
|
410
|
+
|
|
411
|
+
# @see Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Tool::Function#function
|
|
412
|
+
class Function < Telnyx::Internal::Type::BaseModel
|
|
413
|
+
# @!attribute name
|
|
414
|
+
#
|
|
415
|
+
# @return [String]
|
|
416
|
+
required :name, String
|
|
417
|
+
|
|
418
|
+
# @!attribute description
|
|
419
|
+
#
|
|
420
|
+
# @return [String, nil]
|
|
421
|
+
optional :description, String
|
|
422
|
+
|
|
423
|
+
# @!attribute parameters
|
|
424
|
+
#
|
|
425
|
+
# @return [Hash{Symbol=>Object}, nil]
|
|
426
|
+
optional :parameters, Telnyx::Internal::Type::HashOf[Telnyx::Internal::Type::Unknown]
|
|
427
|
+
|
|
428
|
+
# @!method initialize(name:, description: nil, parameters: nil)
|
|
429
|
+
# @param name [String]
|
|
430
|
+
# @param description [String]
|
|
431
|
+
# @param parameters [Hash{Symbol=>Object}]
|
|
432
|
+
end
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
class Retrieval < Telnyx::Internal::Type::BaseModel
|
|
436
|
+
# @!attribute retrieval
|
|
437
|
+
#
|
|
438
|
+
# @return [Telnyx::Models::AI::BucketIDs]
|
|
439
|
+
required :retrieval, -> { Telnyx::AI::BucketIDs }
|
|
440
|
+
|
|
441
|
+
# @!attribute type
|
|
442
|
+
#
|
|
443
|
+
# @return [Symbol, :retrieval]
|
|
444
|
+
required :type, const: :retrieval
|
|
445
|
+
|
|
446
|
+
# @!method initialize(retrieval:, type: :retrieval)
|
|
447
|
+
# @param retrieval [Telnyx::Models::AI::BucketIDs]
|
|
448
|
+
# @param type [Symbol, :retrieval]
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
# @!method self.variants
|
|
452
|
+
# @return [Array(Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Tool::Function, Telnyx::Models::AI::OpenAI::ChatCreateCompletionParams::Tool::Retrieval)]
|
|
453
|
+
end
|
|
454
|
+
end
|
|
455
|
+
end
|
|
456
|
+
end
|
|
457
|
+
end
|
|
458
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Telnyx
|
|
4
|
+
module Models
|
|
5
|
+
module AI
|
|
6
|
+
module OpenAI
|
|
7
|
+
# @type [Telnyx::Internal::Type::Converter]
|
|
8
|
+
ChatCreateCompletionResponse = Telnyx::Internal::Type::HashOf[Telnyx::Internal::Type::Unknown]
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Telnyx
|
|
4
|
+
module Models
|
|
5
|
+
module AI
|
|
6
|
+
# @see Telnyx::Resources::AI::OpenAI#list_models
|
|
7
|
+
class OpenAIListModelsParams < Telnyx::Internal::Type::BaseModel
|
|
8
|
+
extend Telnyx::Internal::Type::RequestParameters::Converter
|
|
9
|
+
include Telnyx::Internal::Type::RequestParameters
|
|
10
|
+
|
|
11
|
+
# @!method initialize(request_options: {})
|
|
12
|
+
# @param request_options [Telnyx::RequestOptions, Hash{Symbol=>Object}]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Telnyx
|
|
4
|
+
module Models
|
|
5
|
+
module AI
|
|
6
|
+
# @see Telnyx::Resources::AI::OpenAI#list_models
|
|
7
|
+
class OpenAIListModelsResponse < Telnyx::Internal::Type::BaseModel
|
|
8
|
+
# @!attribute data
|
|
9
|
+
#
|
|
10
|
+
# @return [Array<Telnyx::Models::AI::OpenAIListModelsResponse::Data>]
|
|
11
|
+
required :data, -> { Telnyx::Internal::Type::ArrayOf[Telnyx::Models::AI::OpenAIListModelsResponse::Data] }
|
|
12
|
+
|
|
13
|
+
# @!attribute object
|
|
14
|
+
#
|
|
15
|
+
# @return [String, nil]
|
|
16
|
+
optional :object, String
|
|
17
|
+
|
|
18
|
+
# @!method initialize(data:, object: nil)
|
|
19
|
+
# @param data [Array<Telnyx::Models::AI::OpenAIListModelsResponse::Data>]
|
|
20
|
+
# @param object [String]
|
|
21
|
+
|
|
22
|
+
class Data < Telnyx::Internal::Type::BaseModel
|
|
23
|
+
# @!attribute id
|
|
24
|
+
#
|
|
25
|
+
# @return [String]
|
|
26
|
+
required :id, String
|
|
27
|
+
|
|
28
|
+
# @!attribute created
|
|
29
|
+
#
|
|
30
|
+
# @return [Integer]
|
|
31
|
+
required :created, Integer
|
|
32
|
+
|
|
33
|
+
# @!attribute owned_by
|
|
34
|
+
#
|
|
35
|
+
# @return [String]
|
|
36
|
+
required :owned_by, String
|
|
37
|
+
|
|
38
|
+
# @!attribute object
|
|
39
|
+
#
|
|
40
|
+
# @return [String, nil]
|
|
41
|
+
optional :object, String
|
|
42
|
+
|
|
43
|
+
# @!method initialize(id:, created:, owned_by:, object: nil)
|
|
44
|
+
# @param id [String]
|
|
45
|
+
# @param created [Integer]
|
|
46
|
+
# @param owned_by [String]
|
|
47
|
+
# @param object [String]
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -5,14 +5,17 @@ module Telnyx
|
|
|
5
5
|
class AI
|
|
6
6
|
# Generate text with LLMs
|
|
7
7
|
class Chat
|
|
8
|
+
# @deprecated
|
|
9
|
+
#
|
|
8
10
|
# Some parameter documentations has been truncated, see
|
|
9
11
|
# {Telnyx::Models::AI::ChatCreateCompletionParams} for more details.
|
|
10
12
|
#
|
|
11
|
-
#
|
|
13
|
+
# **Deprecated**: Use `POST /v2/ai/openai/chat/completions` instead. Chat with a
|
|
14
|
+
# language model. This endpoint is consistent with the
|
|
12
15
|
# [OpenAI Chat Completions API](https://platform.openai.com/docs/api-reference/chat)
|
|
13
16
|
# and may be used with the OpenAI JS or Python SDK.
|
|
14
17
|
#
|
|
15
|
-
# @overload create_completion(messages:, api_key_ref: nil, best_of: nil, early_stopping: nil, enable_thinking: nil, frequency_penalty: nil, guided_choice: nil, guided_json: nil, guided_regex: nil, length_penalty: nil, logprobs: nil, max_tokens: nil, min_p: nil, model: nil, n: nil, presence_penalty: nil, response_format: nil, stream: nil, temperature: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, use_beam_search: nil, request_options: {})
|
|
18
|
+
# @overload create_completion(messages:, api_key_ref: nil, best_of: nil, early_stopping: nil, enable_thinking: nil, frequency_penalty: nil, guided_choice: nil, guided_json: nil, guided_regex: nil, length_penalty: nil, logprobs: nil, max_tokens: nil, min_p: nil, model: nil, n: nil, presence_penalty: nil, response_format: nil, seed: nil, stop: nil, stream: nil, temperature: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, use_beam_search: nil, request_options: {})
|
|
16
19
|
#
|
|
17
20
|
# @param messages [Array<Telnyx::Models::AI::ChatCreateCompletionParams::Message>] A list of the previous chat messages for context.
|
|
18
21
|
#
|
|
@@ -48,6 +51,10 @@ module Telnyx
|
|
|
48
51
|
#
|
|
49
52
|
# @param response_format [Telnyx::Models::AI::ChatCreateCompletionParams::ResponseFormat] Use this is you want to guarantee a JSON output without defining a schema. For c
|
|
50
53
|
#
|
|
54
|
+
# @param seed [Integer] If specified, the system will make a best effort to sample deterministically, su
|
|
55
|
+
#
|
|
56
|
+
# @param stop [String, Array<String>] Up to 4 sequences where the API will stop generating further tokens. The returne
|
|
57
|
+
#
|
|
51
58
|
# @param stream [Boolean] Whether or not to stream data-only server-sent events as they become available.
|
|
52
59
|
#
|
|
53
60
|
# @param temperature [Float] Adjusts the "creativity" of the model. Lower values make the model more determin
|