contactcenterai-20240603/Sources/AlibabacloudContactCenterAI20240603/Client.swift (577 lines of code) (raw):
import Foundation
import Tea
import TeaUtils
import AlibabacloudOpenApi
import AlibabaCloudOpenApiUtil
import AlibabacloudEndpointUtil
open class Client : AlibabacloudOpenApi.Client {
public override init(_ config: AlibabacloudOpenApi.Config) throws {
try super.init(config)
self._endpointRule = ""
try checkConfig(config as! AlibabacloudOpenApi.Config)
self._endpoint = try getEndpoint("contactcenterai", self._regionId ?? "", self._endpointRule ?? "", self._network ?? "", self._suffix ?? "", self._endpointMap ?? [:], self._endpoint ?? "")
}
public func getEndpoint(_ productId: String, _ regionId: String, _ endpointRule: String, _ network: String, _ suffix: String, _ endpointMap: [String: String], _ endpoint: String) throws -> String {
if (!TeaUtils.Client.empty(endpoint)) {
return endpoint as! String
}
if (!TeaUtils.Client.isUnset(endpointMap) && !TeaUtils.Client.empty(endpointMap[regionId as! String])) {
return endpointMap[regionId as! String] ?? ""
}
return try AlibabacloudEndpointUtil.Client.getEndpointRules(productId, regionId, endpointRule, network, suffix)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func analyzeAudioSyncWithOptions(_ workspaceId: String, _ appId: String, _ request: AnalyzeAudioSyncRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> AnalyzeAudioSyncResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.categoryTags)) {
body["categoryTags"] = request.categoryTags ?? [];
}
if (!TeaUtils.Client.isUnset(request.customPrompt)) {
body["customPrompt"] = request.customPrompt ?? "";
}
if (!TeaUtils.Client.isUnset(request.fields)) {
body["fields"] = request.fields ?? [];
}
if (!TeaUtils.Client.isUnset(request.modelCode)) {
body["modelCode"] = request.modelCode ?? "";
}
if (!TeaUtils.Client.isUnset(request.responseFormatType)) {
body["responseFormatType"] = request.responseFormatType ?? "";
}
if (!TeaUtils.Client.isUnset(request.resultTypes)) {
body["resultTypes"] = request.resultTypes ?? [];
}
if (!TeaUtils.Client.isUnset(request.serviceInspection)) {
body["serviceInspection"] = request.serviceInspection!;
}
if (!TeaUtils.Client.isUnset(request.stream)) {
body["stream"] = request.stream!;
}
if (!TeaUtils.Client.isUnset(request.templateIds)) {
body["templateIds"] = request.templateIds ?? [];
}
if (!TeaUtils.Client.isUnset(request.transcription)) {
body["transcription"] = request.transcription!;
}
if (!TeaUtils.Client.isUnset(request.variables)) {
body["variables"] = request.variables ?? [];
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "AnalyzeAudioSync",
"version": "2024-06-03",
"protocol": "HTTPS",
"pathname": "/" + (AlibabaCloudOpenApiUtil.Client.getEncodeParam(workspaceId)) + "/ccai/app/" + (AlibabaCloudOpenApiUtil.Client.getEncodeParam(appId)) + "/analyzeAudioSync",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(AnalyzeAudioSyncResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func analyzeAudioSync(_ workspaceId: String, _ appId: String, _ request: AnalyzeAudioSyncRequest) async throws -> AnalyzeAudioSyncResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await analyzeAudioSyncWithOptions(workspaceId as! String, appId as! String, request as! AnalyzeAudioSyncRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func analyzeConversationWithOptions(_ workspaceId: String, _ appId: String, _ request: AnalyzeConversationRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> AnalyzeConversationResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.categoryTags)) {
body["categoryTags"] = request.categoryTags ?? [];
}
if (!TeaUtils.Client.isUnset(request.customPrompt)) {
body["customPrompt"] = request.customPrompt ?? "";
}
if (!TeaUtils.Client.isUnset(request.dialogue)) {
body["dialogue"] = request.dialogue!;
}
if (!TeaUtils.Client.isUnset(request.examples)) {
body["examples"] = request.examples ?? [];
}
if (!TeaUtils.Client.isUnset(request.fields)) {
body["fields"] = request.fields ?? [];
}
if (!TeaUtils.Client.isUnset(request.modelCode)) {
body["modelCode"] = request.modelCode ?? "";
}
if (!TeaUtils.Client.isUnset(request.responseFormatType)) {
body["responseFormatType"] = request.responseFormatType ?? "";
}
if (!TeaUtils.Client.isUnset(request.resultTypes)) {
body["resultTypes"] = request.resultTypes ?? [];
}
if (!TeaUtils.Client.isUnset(request.sceneName)) {
body["sceneName"] = request.sceneName ?? "";
}
if (!TeaUtils.Client.isUnset(request.serviceInspection)) {
body["serviceInspection"] = request.serviceInspection!;
}
if (!TeaUtils.Client.isUnset(request.sourceCallerUid)) {
body["sourceCallerUid"] = request.sourceCallerUid ?? "";
}
if (!TeaUtils.Client.isUnset(request.stream)) {
body["stream"] = request.stream!;
}
if (!TeaUtils.Client.isUnset(request.timeConstraintList)) {
body["timeConstraintList"] = request.timeConstraintList ?? [];
}
if (!TeaUtils.Client.isUnset(request.userProfiles)) {
body["userProfiles"] = request.userProfiles ?? [];
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "AnalyzeConversation",
"version": "2024-06-03",
"protocol": "HTTPS",
"pathname": "/" + (AlibabaCloudOpenApiUtil.Client.getEncodeParam(workspaceId)) + "/ccai/app/" + (AlibabaCloudOpenApiUtil.Client.getEncodeParam(appId)) + "/analyze_conversation",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(AnalyzeConversationResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func analyzeConversation(_ workspaceId: String, _ appId: String, _ request: AnalyzeConversationRequest) async throws -> AnalyzeConversationResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await analyzeConversationWithOptions(workspaceId as! String, appId as! String, request as! AnalyzeConversationRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func analyzeImageWithOptions(_ workspaceId: String, _ appId: String, _ request: AnalyzeImageRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> AnalyzeImageResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.imageUrls)) {
body["imageUrls"] = request.imageUrls ?? [];
}
if (!TeaUtils.Client.isUnset(request.responseFormatType)) {
body["responseFormatType"] = request.responseFormatType ?? "";
}
if (!TeaUtils.Client.isUnset(request.resultTypes)) {
body["resultTypes"] = request.resultTypes ?? [];
}
if (!TeaUtils.Client.isUnset(request.stream)) {
body["stream"] = request.stream!;
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "AnalyzeImage",
"version": "2024-06-03",
"protocol": "HTTPS",
"pathname": "/" + (AlibabaCloudOpenApiUtil.Client.getEncodeParam(workspaceId)) + "/ccai/app/" + (AlibabaCloudOpenApiUtil.Client.getEncodeParam(appId)) + "/analyzeImage",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(AnalyzeImageResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func analyzeImage(_ workspaceId: String, _ appId: String, _ request: AnalyzeImageRequest) async throws -> AnalyzeImageResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await analyzeImageWithOptions(workspaceId as! String, appId as! String, request as! AnalyzeImageRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func createTaskWithOptions(_ workspaceId: String, _ appId: String, _ request: CreateTaskRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> CreateTaskResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.categoryTags)) {
body["categoryTags"] = request.categoryTags ?? [];
}
if (!TeaUtils.Client.isUnset(request.customPrompt)) {
body["customPrompt"] = request.customPrompt ?? "";
}
if (!TeaUtils.Client.isUnset(request.dialogue)) {
body["dialogue"] = request.dialogue!;
}
if (!TeaUtils.Client.isUnset(request.examples)) {
body["examples"] = request.examples!;
}
if (!TeaUtils.Client.isUnset(request.fields)) {
body["fields"] = request.fields ?? [];
}
if (!TeaUtils.Client.isUnset(request.modelCode)) {
body["modelCode"] = request.modelCode ?? "";
}
if (!TeaUtils.Client.isUnset(request.responseFormatType)) {
body["responseFormatType"] = request.responseFormatType ?? "";
}
if (!TeaUtils.Client.isUnset(request.resultTypes)) {
body["resultTypes"] = request.resultTypes ?? [];
}
if (!TeaUtils.Client.isUnset(request.serviceInspection)) {
body["serviceInspection"] = request.serviceInspection!;
}
if (!TeaUtils.Client.isUnset(request.taskType)) {
body["taskType"] = request.taskType ?? "";
}
if (!TeaUtils.Client.isUnset(request.templateIds)) {
body["templateIds"] = request.templateIds ?? [];
}
if (!TeaUtils.Client.isUnset(request.transcription)) {
body["transcription"] = request.transcription!;
}
if (!TeaUtils.Client.isUnset(request.variables)) {
body["variables"] = request.variables ?? [];
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "CreateTask",
"version": "2024-06-03",
"protocol": "HTTPS",
"pathname": "/" + (AlibabaCloudOpenApiUtil.Client.getEncodeParam(workspaceId)) + "/ccai/app/" + (AlibabaCloudOpenApiUtil.Client.getEncodeParam(appId)) + "/createTask",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(CreateTaskResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func createTask(_ workspaceId: String, _ appId: String, _ request: CreateTaskRequest) async throws -> CreateTaskResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await createTaskWithOptions(workspaceId as! String, appId as! String, request as! CreateTaskRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func createVocabWithOptions(_ request: CreateVocabRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> CreateVocabResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.audioModelCode)) {
body["audioModelCode"] = request.audioModelCode ?? "";
}
if (!TeaUtils.Client.isUnset(request.description_)) {
body["description"] = request.description_ ?? "";
}
if (!TeaUtils.Client.isUnset(request.name)) {
body["name"] = request.name ?? "";
}
if (!TeaUtils.Client.isUnset(request.wordWeightList)) {
body["wordWeightList"] = request.wordWeightList ?? [];
}
if (!TeaUtils.Client.isUnset(request.workspaceId)) {
body["workspaceId"] = request.workspaceId ?? "";
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "CreateVocab",
"version": "2024-06-03",
"protocol": "HTTPS",
"pathname": "/vocab/createVocab",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(CreateVocabResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func createVocab(_ request: CreateVocabRequest) async throws -> CreateVocabResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await createVocabWithOptions(request as! CreateVocabRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func deleteVocabWithOptions(_ request: DeleteVocabRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> DeleteVocabResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.vocabularyId)) {
body["vocabularyId"] = request.vocabularyId ?? "";
}
if (!TeaUtils.Client.isUnset(request.workspaceId)) {
body["workspaceId"] = request.workspaceId ?? "";
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "DeleteVocab",
"version": "2024-06-03",
"protocol": "HTTPS",
"pathname": "/vocab/deleteVocab",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(DeleteVocabResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func deleteVocab(_ request: DeleteVocabRequest) async throws -> DeleteVocabResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await deleteVocabWithOptions(request as! DeleteVocabRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func getTaskResultWithOptions(_ tmpReq: GetTaskResultRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> GetTaskResultResponse {
try TeaUtils.Client.validateModel(tmpReq)
var request: GetTaskResultShrinkRequest = GetTaskResultShrinkRequest([:])
AlibabaCloudOpenApiUtil.Client.convert(tmpReq, request)
if (!TeaUtils.Client.isUnset(tmpReq.requiredFieldList)) {
request.requiredFieldListShrink = AlibabaCloudOpenApiUtil.Client.arrayToStringWithSpecifiedStyle(tmpReq.requiredFieldList, "requiredFieldList", "simple")
}
var query: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.requiredFieldListShrink)) {
query["requiredFieldList"] = request.requiredFieldListShrink ?? "";
}
if (!TeaUtils.Client.isUnset(request.taskId)) {
query["taskId"] = request.taskId ?? "";
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"query": AlibabaCloudOpenApiUtil.Client.query(query)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "GetTaskResult",
"version": "2024-06-03",
"protocol": "HTTPS",
"pathname": "/ccai/app/getTaskResult",
"method": "GET",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(GetTaskResultResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func getTaskResult(_ request: GetTaskResultRequest) async throws -> GetTaskResultResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await getTaskResultWithOptions(request as! GetTaskResultRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func getVocabWithOptions(_ request: GetVocabRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> GetVocabResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.vocabularyId)) {
body["vocabularyId"] = request.vocabularyId ?? "";
}
if (!TeaUtils.Client.isUnset(request.workspaceId)) {
body["workspaceId"] = request.workspaceId ?? "";
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "GetVocab",
"version": "2024-06-03",
"protocol": "HTTPS",
"pathname": "/vocab/getVocab",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(GetVocabResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func getVocab(_ request: GetVocabRequest) async throws -> GetVocabResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await getVocabWithOptions(request as! GetVocabRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func listVocabWithOptions(_ request: ListVocabRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> ListVocabResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.workspaceId)) {
body["workspaceId"] = request.workspaceId ?? "";
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "ListVocab",
"version": "2024-06-03",
"protocol": "HTTPS",
"pathname": "/vocab/listVocab",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(ListVocabResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func listVocab(_ request: ListVocabRequest) async throws -> ListVocabResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await listVocabWithOptions(request as! ListVocabRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func runCompletionWithOptions(_ workspaceId: String, _ appId: String, _ request: RunCompletionRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> RunCompletionResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.dialogue)) {
body["Dialogue"] = request.dialogue!;
}
if (!TeaUtils.Client.isUnset(request.fields)) {
body["Fields"] = request.fields ?? [];
}
if (!TeaUtils.Client.isUnset(request.modelCode)) {
body["ModelCode"] = request.modelCode ?? "";
}
if (!TeaUtils.Client.isUnset(request.serviceInspection)) {
body["ServiceInspection"] = request.serviceInspection!;
}
if (!TeaUtils.Client.isUnset(request.stream)) {
body["Stream"] = request.stream!;
}
if (!TeaUtils.Client.isUnset(request.templateIds)) {
body["TemplateIds"] = request.templateIds ?? [];
}
if (!TeaUtils.Client.isUnset(request.responseFormatType)) {
body["responseFormatType"] = request.responseFormatType ?? "";
}
if (!TeaUtils.Client.isUnset(request.variables)) {
body["variables"] = request.variables ?? [];
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "RunCompletion",
"version": "2024-06-03",
"protocol": "HTTPS",
"pathname": "/" + (AlibabaCloudOpenApiUtil.Client.getEncodeParam(workspaceId)) + "/ccai/app/" + (AlibabaCloudOpenApiUtil.Client.getEncodeParam(appId)) + "/completion",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(RunCompletionResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func runCompletion(_ workspaceId: String, _ appId: String, _ request: RunCompletionRequest) async throws -> RunCompletionResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await runCompletionWithOptions(workspaceId as! String, appId as! String, request as! RunCompletionRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func runCompletionMessageWithOptions(_ workspaceId: String, _ appId: String, _ request: RunCompletionMessageRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> RunCompletionMessageResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.messages)) {
body["Messages"] = request.messages ?? [];
}
if (!TeaUtils.Client.isUnset(request.modelCode)) {
body["ModelCode"] = request.modelCode ?? "";
}
if (!TeaUtils.Client.isUnset(request.stream)) {
body["Stream"] = request.stream!;
}
if (!TeaUtils.Client.isUnset(request.responseFormatType)) {
body["responseFormatType"] = request.responseFormatType ?? "";
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "RunCompletionMessage",
"version": "2024-06-03",
"protocol": "HTTPS",
"pathname": "/" + (AlibabaCloudOpenApiUtil.Client.getEncodeParam(workspaceId)) + "/ccai/app/" + (AlibabaCloudOpenApiUtil.Client.getEncodeParam(appId)) + "/completion_message",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(RunCompletionMessageResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func runCompletionMessage(_ workspaceId: String, _ appId: String, _ request: RunCompletionMessageRequest) async throws -> RunCompletionMessageResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await runCompletionMessageWithOptions(workspaceId as! String, appId as! String, request as! RunCompletionMessageRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func updateVocabWithOptions(_ request: UpdateVocabRequest, _ headers: [String: String], _ runtime: TeaUtils.RuntimeOptions) async throws -> UpdateVocabResponse {
try TeaUtils.Client.validateModel(request)
var body: [String: Any] = [:]
if (!TeaUtils.Client.isUnset(request.description_)) {
body["description"] = request.description_ ?? "";
}
if (!TeaUtils.Client.isUnset(request.name)) {
body["name"] = request.name ?? "";
}
if (!TeaUtils.Client.isUnset(request.vocabularyId)) {
body["vocabularyId"] = request.vocabularyId ?? "";
}
if (!TeaUtils.Client.isUnset(request.wordWeightList)) {
body["wordWeightList"] = request.wordWeightList ?? [];
}
if (!TeaUtils.Client.isUnset(request.workspaceId)) {
body["workspaceId"] = request.workspaceId ?? "";
}
var req: AlibabacloudOpenApi.OpenApiRequest = AlibabacloudOpenApi.OpenApiRequest([
"headers": headers as! [String: String],
"body": AlibabaCloudOpenApiUtil.Client.parseToMap(body)
])
var params: AlibabacloudOpenApi.Params = AlibabacloudOpenApi.Params([
"action": "UpdateVocab",
"version": "2024-06-03",
"protocol": "HTTPS",
"pathname": "/vocab/updateVocab",
"method": "POST",
"authType": "AK",
"style": "ROA",
"reqBodyType": "json",
"bodyType": "json"
])
var tmp: [String: Any] = try await callApi(params as! AlibabacloudOpenApi.Params, req as! AlibabacloudOpenApi.OpenApiRequest, runtime as! TeaUtils.RuntimeOptions)
return Tea.TeaConverter.fromMap(UpdateVocabResponse(), tmp)
}
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public func updateVocab(_ request: UpdateVocabRequest) async throws -> UpdateVocabResponse {
var runtime: TeaUtils.RuntimeOptions = TeaUtils.RuntimeOptions([:])
var headers: [String: String] = [:]
return try await updateVocabWithOptions(request as! UpdateVocabRequest, headers as! [String: String], runtime as! TeaUtils.RuntimeOptions)
}
}