tencentcloud-sdk-hunyuan 3.0.711

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c8b0fb22759ac672f0ca3d5590d71bfb81bfb882
4
+ data.tar.gz: af43b8c63df98567cab75b9195850f0497eba2a8
5
+ SHA512:
6
+ metadata.gz: c3c179022f236a775a5dfb895e9c89158c6c267b8aa0ebbea3c3739350a2d2622db69ab7167ad80d5f90348081197250bafaa087fe30962f27cd3afb1eb06fb9
7
+ data.tar.gz: 9bb73419f95f4813cabdeea58a889bd3864dce44940319d614026bbe312e178f7bf298510078d39fe5bf257fbc8711352e1e01ae2932148043d47a58a868c79e
data/lib/VERSION ADDED
@@ -0,0 +1 @@
1
+ 3.0.711
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tencentcloud-sdk-common'
4
+
5
+ require_relative 'v20230901/client'
6
+ require_relative 'v20230901/models'
7
+
8
+ module TencentCloud
9
+ module Hunyuan
10
+ end
11
+ end
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'json'
18
+
19
+ module TencentCloud
20
+ module Hunyuan
21
+ module V20230901
22
+ class Client < TencentCloud::Common::AbstractClient
23
+
24
+ def initialize(credential, region, profile = nil)
25
+ api_version = '2023-09-01'
26
+ api_endpoint = 'hunyuan.tencentcloudapi.com'
27
+ sdk_version = 'HUNYUAN_' + File.read(File.expand_path('../VERSION', __dir__)).strip
28
+ super(credential, region, api_version, api_endpoint, sdk_version, profile)
29
+ end
30
+
31
+
32
+ # 腾讯混元大模型高级版是由腾讯研发的大语言模型,具备强大的中文创作能力,复杂语境下的逻辑推理能力,以及可靠的任务执行能力。本接口为SSE协议。
33
+
34
+ # @param request: Request instance for ChatPro.
35
+ # @type request: :class:`Tencentcloud::hunyuan::V20230901::ChatProRequest`
36
+ # @rtype: :class:`Tencentcloud::hunyuan::V20230901::ChatProResponse`
37
+ def ChatPro(request)
38
+ body = send_request('ChatPro', request.serialize)
39
+ response = JSON.parse(body)
40
+ if response['Response'].key?('Error') == false
41
+ model = ChatProResponse.new
42
+ model.deserialize(response['Response'])
43
+ model
44
+ else
45
+ code = response['Response']['Error']['Code']
46
+ message = response['Response']['Error']['Message']
47
+ reqid = response['Response']['RequestId']
48
+ raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
49
+ end
50
+ rescue TencentCloud::Common::TencentCloudSDKException => e
51
+ raise e
52
+ rescue StandardError => e
53
+ raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
54
+ end
55
+
56
+ # 腾讯混元大模型标准版是由腾讯研发的大语言模型,具备强大的中文创作能力,复杂语境下的逻辑推理能力,以及可靠的任务执行能力。本接口为SSE协议。
57
+
58
+ # @param request: Request instance for ChatStd.
59
+ # @type request: :class:`Tencentcloud::hunyuan::V20230901::ChatStdRequest`
60
+ # @rtype: :class:`Tencentcloud::hunyuan::V20230901::ChatStdResponse`
61
+ def ChatStd(request)
62
+ body = send_request('ChatStd', request.serialize)
63
+ response = JSON.parse(body)
64
+ if response['Response'].key?('Error') == false
65
+ model = ChatStdResponse.new
66
+ model.deserialize(response['Response'])
67
+ model
68
+ else
69
+ code = response['Response']['Error']['Code']
70
+ message = response['Response']['Error']['Message']
71
+ reqid = response['Response']['RequestId']
72
+ raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
73
+ end
74
+ rescue TencentCloud::Common::TencentCloudSDKException => e
75
+ raise e
76
+ rescue StandardError => e
77
+ raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
78
+ end
79
+
80
+ # 该接口用于计算文本对应Token数、字符数。
81
+
82
+ # @param request: Request instance for GetTokenCount.
83
+ # @type request: :class:`Tencentcloud::hunyuan::V20230901::GetTokenCountRequest`
84
+ # @rtype: :class:`Tencentcloud::hunyuan::V20230901::GetTokenCountResponse`
85
+ def GetTokenCount(request)
86
+ body = send_request('GetTokenCount', request.serialize)
87
+ response = JSON.parse(body)
88
+ if response['Response'].key?('Error') == false
89
+ model = GetTokenCountResponse.new
90
+ model.deserialize(response['Response'])
91
+ model
92
+ else
93
+ code = response['Response']['Error']['Code']
94
+ message = response['Response']['Error']['Message']
95
+ reqid = response['Response']['RequestId']
96
+ raise TencentCloud::Common::TencentCloudSDKException.new(code, message, reqid)
97
+ end
98
+ rescue TencentCloud::Common::TencentCloudSDKException => e
99
+ raise e
100
+ rescue StandardError => e
101
+ raise TencentCloud::Common::TencentCloudSDKException.new(nil, e.inspect)
102
+ end
103
+
104
+
105
+ end
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,370 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ module TencentCloud
18
+ module Hunyuan
19
+ module V20230901
20
+ # ChatPro请求参数结构体
21
+ class ChatProRequest < TencentCloud::Common::AbstractModel
22
+ # @param Messages: 聊天上下文信息。
23
+ # 说明:
24
+ # 1.长度最多为40, 按对话时间从旧到新在数组中排列。
25
+ # 2.Message的Role当前可选值:user、assistant,其中,user和assistant需要交替出现(一问一答),最后一个为user提问, 且Content不能为空。
26
+ # 3.Messages中Content总长度不超过16000token,超过则会截断最前面的内容,只保留尾部内容。建议不超过4000token。
27
+ # @type Messages: Array
28
+ # @param TopP: 说明:
29
+ # 1.影响输出文本的多样性,取值越大,生成文本的多样性越强。
30
+ # 2.默认1.0,取值区间为[0.0, 1.0]。
31
+ # 3.非必要不建议使用, 不合理的取值会影响效果。
32
+ # @type TopP: Float
33
+ # @param Temperature: 说明:
34
+ # 1.较高的数值会使输出更加随机,而较低的数值会使其更加集中和确定。
35
+ # 2.默认1.0,取值区间为[0.0,2.0]。
36
+ # 3.非必要不建议使用,不合理的取值会影响效果。
37
+ # @type Temperature: Float
38
+
39
+ attr_accessor :Messages, :TopP, :Temperature
40
+
41
+ def initialize(messages=nil, topp=nil, temperature=nil)
42
+ @Messages = messages
43
+ @TopP = topp
44
+ @Temperature = temperature
45
+ end
46
+
47
+ def deserialize(params)
48
+ unless params['Messages'].nil?
49
+ @Messages = []
50
+ params['Messages'].each do |i|
51
+ message_tmp = Message.new
52
+ message_tmp.deserialize(i)
53
+ @Messages << message_tmp
54
+ end
55
+ end
56
+ @TopP = params['TopP']
57
+ @Temperature = params['Temperature']
58
+ end
59
+ end
60
+
61
+ # ChatPro返回参数结构体
62
+ class ChatProResponse < TencentCloud::Common::AbstractModel
63
+ # @param Created: unix 时间戳,单位为秒。
64
+ # @type Created: Integer
65
+ # @param Usage: token统计信息。
66
+ # 按照总token数量计费。
67
+ # @type Usage: :class:`Tencentcloud::Hunyuan.v20230901.models.Usage`
68
+ # @param Note: 免责声明。
69
+ # @type Note: String
70
+ # @param Id: 本轮对话的id。
71
+ # @type Id: String
72
+ # @param Choices: 回复内容。
73
+ # @type Choices: Array
74
+ # @param ErrorMsg: 错误信息。
75
+ # 如果流式返回中服务处理异常,返回该错误信息。
76
+ # 注意:此字段可能返回 null,表示取不到有效值。
77
+ # @type ErrorMsg: :class:`Tencentcloud::Hunyuan.v20230901.models.ErrorMsg`
78
+ # @param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。本接口为流式响应接口,当请求成功时,RequestId 会被放在 HTTP 响应的 Header "X-TC-RequestId" 中。
79
+ # @type RequestId: String
80
+
81
+ attr_accessor :Created, :Usage, :Note, :Id, :Choices, :ErrorMsg, :RequestId
82
+
83
+ def initialize(created=nil, usage=nil, note=nil, id=nil, choices=nil, errormsg=nil, requestid=nil)
84
+ @Created = created
85
+ @Usage = usage
86
+ @Note = note
87
+ @Id = id
88
+ @Choices = choices
89
+ @ErrorMsg = errormsg
90
+ @RequestId = requestid
91
+ end
92
+
93
+ def deserialize(params)
94
+ @Created = params['Created']
95
+ unless params['Usage'].nil?
96
+ @Usage = Usage.new
97
+ @Usage.deserialize(params['Usage'])
98
+ end
99
+ @Note = params['Note']
100
+ @Id = params['Id']
101
+ unless params['Choices'].nil?
102
+ @Choices = []
103
+ params['Choices'].each do |i|
104
+ choice_tmp = Choice.new
105
+ choice_tmp.deserialize(i)
106
+ @Choices << choice_tmp
107
+ end
108
+ end
109
+ unless params['ErrorMsg'].nil?
110
+ @ErrorMsg = ErrorMsg.new
111
+ @ErrorMsg.deserialize(params['ErrorMsg'])
112
+ end
113
+ @RequestId = params['RequestId']
114
+ end
115
+ end
116
+
117
+ # ChatStd请求参数结构体
118
+ class ChatStdRequest < TencentCloud::Common::AbstractModel
119
+ # @param Messages: 聊天上下文信息。
120
+ # 说明:
121
+ # 1.长度最多为40, 按对话时间从旧到新在数组中排列。
122
+ # 2.Message的Role当前可选值:user、assistant,其中,user和assistant需要交替出现(一问一答),最后一个为user提问, 且Content不能为空。
123
+ # 3.Messages中Content总长度不超过16000token,超过则会截断最前面的内容,只保留尾部内容。建议不超过4000token。
124
+ # @type Messages: Array
125
+ # @param TopP: 说明:
126
+ # 1.影响输出文本的多样性,取值越大,生成文本的多样性越强。
127
+ # 2.默认1.0,取值区间为[0.0, 1.0]。
128
+ # 3.非必要不建议使用, 不合理的取值会影响效果。
129
+ # @type TopP: Float
130
+ # @param Temperature: 说明:
131
+ # 1.较高的数值会使输出更加随机,而较低的数值会使其更加集中和确定。
132
+ # 2.默认1.0,取值区间为[0.0,2.0]。
133
+ # 3.非必要不建议使用,不合理的取值会影响效果。
134
+ # @type Temperature: Float
135
+
136
+ attr_accessor :Messages, :TopP, :Temperature
137
+
138
+ def initialize(messages=nil, topp=nil, temperature=nil)
139
+ @Messages = messages
140
+ @TopP = topp
141
+ @Temperature = temperature
142
+ end
143
+
144
+ def deserialize(params)
145
+ unless params['Messages'].nil?
146
+ @Messages = []
147
+ params['Messages'].each do |i|
148
+ message_tmp = Message.new
149
+ message_tmp.deserialize(i)
150
+ @Messages << message_tmp
151
+ end
152
+ end
153
+ @TopP = params['TopP']
154
+ @Temperature = params['Temperature']
155
+ end
156
+ end
157
+
158
+ # ChatStd返回参数结构体
159
+ class ChatStdResponse < TencentCloud::Common::AbstractModel
160
+ # @param Created: unix 时间戳,单位为秒。
161
+ # @type Created: Integer
162
+ # @param Usage: token统计信息。
163
+ # 按照总token数量计费。
164
+ # @type Usage: :class:`Tencentcloud::Hunyuan.v20230901.models.Usage`
165
+ # @param Note: 免责声明。
166
+ # @type Note: String
167
+ # @param Id: 本轮对话的id。
168
+ # @type Id: String
169
+ # @param Choices: 回复内容。
170
+ # @type Choices: Array
171
+ # @param ErrorMsg: 错误信息。
172
+ # 如果流式返回中服务处理异常,返回该错误信息。
173
+ # 注意:此字段可能返回 null,表示取不到有效值。
174
+ # @type ErrorMsg: :class:`Tencentcloud::Hunyuan.v20230901.models.ErrorMsg`
175
+ # @param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。本接口为流式响应接口,当请求成功时,RequestId 会被放在 HTTP 响应的 Header "X-TC-RequestId" 中。
176
+ # @type RequestId: String
177
+
178
+ attr_accessor :Created, :Usage, :Note, :Id, :Choices, :ErrorMsg, :RequestId
179
+
180
+ def initialize(created=nil, usage=nil, note=nil, id=nil, choices=nil, errormsg=nil, requestid=nil)
181
+ @Created = created
182
+ @Usage = usage
183
+ @Note = note
184
+ @Id = id
185
+ @Choices = choices
186
+ @ErrorMsg = errormsg
187
+ @RequestId = requestid
188
+ end
189
+
190
+ def deserialize(params)
191
+ @Created = params['Created']
192
+ unless params['Usage'].nil?
193
+ @Usage = Usage.new
194
+ @Usage.deserialize(params['Usage'])
195
+ end
196
+ @Note = params['Note']
197
+ @Id = params['Id']
198
+ unless params['Choices'].nil?
199
+ @Choices = []
200
+ params['Choices'].each do |i|
201
+ choice_tmp = Choice.new
202
+ choice_tmp.deserialize(i)
203
+ @Choices << choice_tmp
204
+ end
205
+ end
206
+ unless params['ErrorMsg'].nil?
207
+ @ErrorMsg = ErrorMsg.new
208
+ @ErrorMsg.deserialize(params['ErrorMsg'])
209
+ end
210
+ @RequestId = params['RequestId']
211
+ end
212
+ end
213
+
214
+ # 返回的回复, 支持多个
215
+ class Choice < TencentCloud::Common::AbstractModel
216
+ # @param FinishReason: 流式结束标志位,为 stop 则表示尾包。
217
+ # @type FinishReason: String
218
+ # @param Delta: 返回值。
219
+ # @type Delta: :class:`Tencentcloud::Hunyuan.v20230901.models.Delta`
220
+
221
+ attr_accessor :FinishReason, :Delta
222
+
223
+ def initialize(finishreason=nil, delta=nil)
224
+ @FinishReason = finishreason
225
+ @Delta = delta
226
+ end
227
+
228
+ def deserialize(params)
229
+ @FinishReason = params['FinishReason']
230
+ unless params['Delta'].nil?
231
+ @Delta = Delta.new
232
+ @Delta.deserialize(params['Delta'])
233
+ end
234
+ end
235
+ end
236
+
237
+ # 返回的内容(流式返回)
238
+ class Delta < TencentCloud::Common::AbstractModel
239
+ # @param Role: 角色名称。
240
+ # @type Role: String
241
+ # @param Content: 内容详情。
242
+ # @type Content: String
243
+
244
+ attr_accessor :Role, :Content
245
+
246
+ def initialize(role=nil, content=nil)
247
+ @Role = role
248
+ @Content = content
249
+ end
250
+
251
+ def deserialize(params)
252
+ @Role = params['Role']
253
+ @Content = params['Content']
254
+ end
255
+ end
256
+
257
+ # 运行时异常信息。
258
+ class ErrorMsg < TencentCloud::Common::AbstractModel
259
+ # @param Msg: 错误提示信息。
260
+ # @type Msg: String
261
+ # @param Code: 错误码。
262
+ # 4000 服务内部异常。
263
+ # 4001 请求模型超时。
264
+ # @type Code: Integer
265
+
266
+ attr_accessor :Msg, :Code
267
+
268
+ def initialize(msg=nil, code=nil)
269
+ @Msg = msg
270
+ @Code = code
271
+ end
272
+
273
+ def deserialize(params)
274
+ @Msg = params['Msg']
275
+ @Code = params['Code']
276
+ end
277
+ end
278
+
279
+ # GetTokenCount请求参数结构体
280
+ class GetTokenCountRequest < TencentCloud::Common::AbstractModel
281
+ # @param Prompt: 输入文本
282
+ # @type Prompt: String
283
+
284
+ attr_accessor :Prompt
285
+
286
+ def initialize(prompt=nil)
287
+ @Prompt = prompt
288
+ end
289
+
290
+ def deserialize(params)
291
+ @Prompt = params['Prompt']
292
+ end
293
+ end
294
+
295
+ # GetTokenCount返回参数结构体
296
+ class GetTokenCountResponse < TencentCloud::Common::AbstractModel
297
+ # @param TokenCount: token计数
298
+ # @type TokenCount: Integer
299
+ # @param CharacterCount: 字符计数
300
+ # @type CharacterCount: Integer
301
+ # @param Tokens: 切分后的列表
302
+ # @type Tokens: Array
303
+ # @param RequestId: 唯一请求 ID,每次请求都会返回。定位问题时需要提供该次请求的 RequestId。
304
+ # @type RequestId: String
305
+
306
+ attr_accessor :TokenCount, :CharacterCount, :Tokens, :RequestId
307
+
308
+ def initialize(tokencount=nil, charactercount=nil, tokens=nil, requestid=nil)
309
+ @TokenCount = tokencount
310
+ @CharacterCount = charactercount
311
+ @Tokens = tokens
312
+ @RequestId = requestid
313
+ end
314
+
315
+ def deserialize(params)
316
+ @TokenCount = params['TokenCount']
317
+ @CharacterCount = params['CharacterCount']
318
+ @Tokens = params['Tokens']
319
+ @RequestId = params['RequestId']
320
+ end
321
+ end
322
+
323
+ # 会话内容, 按对话时间序排列,长度最多为40
324
+ class Message < TencentCloud::Common::AbstractModel
325
+ # @param Role: 角色
326
+ # @type Role: String
327
+ # @param Content: 消息的内容
328
+ # @type Content: String
329
+
330
+ attr_accessor :Role, :Content
331
+
332
+ def initialize(role=nil, content=nil)
333
+ @Role = role
334
+ @Content = content
335
+ end
336
+
337
+ def deserialize(params)
338
+ @Role = params['Role']
339
+ @Content = params['Content']
340
+ end
341
+ end
342
+
343
+ # token 数量
344
+ class Usage < TencentCloud::Common::AbstractModel
345
+ # @param PromptTokens: 输入 token 数量。
346
+ # @type PromptTokens: Integer
347
+ # @param CompletionTokens: 输出 token 数量。
348
+ # @type CompletionTokens: Integer
349
+ # @param TotalTokens: 总 token 数量。
350
+ # @type TotalTokens: Integer
351
+
352
+ attr_accessor :PromptTokens, :CompletionTokens, :TotalTokens
353
+
354
+ def initialize(prompttokens=nil, completiontokens=nil, totaltokens=nil)
355
+ @PromptTokens = prompttokens
356
+ @CompletionTokens = completiontokens
357
+ @TotalTokens = totaltokens
358
+ end
359
+
360
+ def deserialize(params)
361
+ @PromptTokens = params['PromptTokens']
362
+ @CompletionTokens = params['CompletionTokens']
363
+ @TotalTokens = params['TotalTokens']
364
+ end
365
+ end
366
+
367
+ end
368
+ end
369
+ end
370
+
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tencentcloud-sdk-hunyuan
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.711
5
+ platform: ruby
6
+ authors:
7
+ - Tencent Cloud
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-11-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tencentcloud-sdk-common
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ description: Tencent Cloud Ruby SDK is the official software development kit, which
28
+ allows Ruby developers to write software that makes use of Tencent Cloud service
29
+ HUNYUAN.
30
+ email:
31
+ - tencentcloudapi@tencent.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - lib/tencentcloud-sdk-hunyuan.rb
37
+ - lib/v20230901/client.rb
38
+ - lib/v20230901/models.rb
39
+ - lib/VERSION
40
+ homepage: https://github.com/TencentCloud/tencentcloud-sdk-ruby
41
+ licenses:
42
+ - Apache-2.0
43
+ metadata:
44
+ source_code_uri: https://github.com/TencentCloud/tencentcloud-sdk-ruby/tencentcloud-sdk-hunyuan
45
+ changelog_uri: https://github.com/TencentCloud/tencentcloud-sdk-ruby/blob/master/CHANGELOG.md
46
+ post_install_message:
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.0.14
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Tencent Cloud SDK for Ruby - HUNYUAN
66
+ test_files: []