Skip to content

Commit fc73bd0

Browse files
committed
chore: regen translate stream
1 parent 8e56a89 commit fc73bd0

File tree

10 files changed

+1218
-0
lines changed

10 files changed

+1218
-0
lines changed

include/uapi/Client.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,11 @@ class Client {
446446
auto query = args;
447447
return c->request("POST", path, query);
448448
}
449+
std::string postTranslateStream(const std::map<std::string, std::string>& args = {}) {
450+
std::string path = "/translate/stream";
451+
auto query = args;
452+
return c->request("POST", path, query);
453+
}
449454
std::string postTranslateText(const std::map<std::string, std::string>& args = {}) {
450455
std::string path = "/translate/text";
451456
auto query = args;

internal/.openapi-generator/FILES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@ include/CppRestOpenAPIClient/model/Post_text_md5_request.h
280280
include/CppRestOpenAPIClient/model/Post_text_md5_verify_200_response.h
281281
include/CppRestOpenAPIClient/model/Post_text_md5_verify_400_response.h
282282
include/CppRestOpenAPIClient/model/Post_text_md5_verify_request.h
283+
include/CppRestOpenAPIClient/model/Post_translate_stream_400_response.h
284+
include/CppRestOpenAPIClient/model/Post_translate_stream_500_response.h
285+
include/CppRestOpenAPIClient/model/Post_translate_stream_request.h
283286
include/CppRestOpenAPIClient/model/Post_translate_text_200_response.h
284287
include/CppRestOpenAPIClient/model/Post_translate_text_400_response.h
285288
include/CppRestOpenAPIClient/model/Post_translate_text_500_response.h
@@ -563,6 +566,9 @@ src/model/Post_text_md5_request.cpp
563566
src/model/Post_text_md5_verify_200_response.cpp
564567
src/model/Post_text_md5_verify_400_response.cpp
565568
src/model/Post_text_md5_verify_request.cpp
569+
src/model/Post_translate_stream_400_response.cpp
570+
src/model/Post_translate_stream_500_response.cpp
571+
src/model/Post_translate_stream_request.cpp
566572
src/model/Post_translate_text_200_response.cpp
567573
src/model/Post_translate_text_400_response.cpp
568574
src/model/Post_translate_text_500_response.cpp

internal/include/CppRestOpenAPIClient/api/TranslateApi.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#include "CppRestOpenAPIClient/model/Post_ai_translate_429_response.h"
3030
#include "CppRestOpenAPIClient/model/Post_ai_translate_500_response.h"
3131
#include "CppRestOpenAPIClient/model/Post_ai_translate_request.h"
32+
#include "CppRestOpenAPIClient/model/Post_translate_stream_400_response.h"
33+
#include "CppRestOpenAPIClient/model/Post_translate_stream_500_response.h"
34+
#include "CppRestOpenAPIClient/model/Post_translate_stream_request.h"
3235
#include "CppRestOpenAPIClient/model/Post_translate_text_200_response.h"
3336
#include "CppRestOpenAPIClient/model/Post_translate_text_400_response.h"
3437
#include "CppRestOpenAPIClient/model/Post_translate_text_500_response.h"
@@ -74,6 +77,16 @@ class TranslateApi
7477
std::shared_ptr<Post_ai_translate_request> postAiTranslateRequest
7578
) const;
7679
/// <summary>
80+
/// 流式翻译(中英互译)
81+
/// </summary>
82+
/// <remarks>
83+
/// 想让翻译结果像打字机一样逐字显示出来?这个流式翻译接口能实现这种效果。 ## 功能概述 不同于传统翻译API一次性返回完整结果,这个接口会实时地、一个字一个字地把翻译内容推给你(就像ChatGPT回复消息那样),非常适合用在聊天应用、直播字幕等需要即时反馈的场景。 ## 它能做什么 - **中英互译**:支持中文和英文之间的双向翻译 - **自动识别**:不确定源语言?设置为 &#x60;auto&#x60; 让我们自动检测 - **逐字返回**:翻译结果会像打字机一样逐字流式返回,用户体验更流畅 - **音频朗读**:部分翻译结果会附带音频链接,方便朗读 ## 支持的语言 目前专注于中英互译,支持以下选项: - &#x60;中文&#x60;(简体/繁体) - &#x60;英文&#x60; - &#x60;auto&#x60;(自动检测)
84+
/// </remarks>
85+
/// <param name="postTranslateStreamRequest">包含翻译参数的JSON对象</param>
86+
pplx::task<utility::string_t> postTranslateStream(
87+
std::shared_ptr<Post_translate_stream_request> postTranslateStreamRequest
88+
) const;
89+
/// <summary>
7790
/// 多语言文本翻译
7891
/// </summary>
7992
/// <remarks>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/**
2+
* UAPI
3+
* UAPI 官方接口文档
4+
*
5+
* The version of the OpenAPI document: 1.0.0
6+
*
7+
* NOTE: This class is auto generated by OpenAPI-Generator 7.17.0.
8+
* https://openapi-generator.tech
9+
* Do not edit the class manually.
10+
*/
11+
12+
/*
13+
* Post_translate_stream_400_response.h
14+
*
15+
*
16+
*/
17+
18+
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Post_translate_stream_400_response_H_
19+
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Post_translate_stream_400_response_H_
20+
21+
#include <stdexcept>
22+
23+
#include "CppRestOpenAPIClient/ModelBase.h"
24+
25+
#include <cpprest/details/basic_types.h>
26+
27+
namespace org {
28+
namespace openapitools {
29+
namespace client {
30+
namespace model {
31+
32+
33+
34+
class Post_translate_stream_400_response
35+
: public ModelBase
36+
{
37+
public:
38+
Post_translate_stream_400_response();
39+
virtual ~Post_translate_stream_400_response();
40+
41+
/////////////////////////////////////////////
42+
/// ModelBase overrides
43+
44+
void validate() override;
45+
46+
web::json::value toJson() const override;
47+
bool fromJson(const web::json::value& json) override;
48+
49+
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
50+
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
51+
52+
53+
/////////////////////////////////////////////
54+
/// Post_translate_stream_400_response members
55+
56+
enum class CodeEnum
57+
{
58+
INVALID_REQUEST,
59+
MISSING_QUERY,
60+
MISSING_TARGET_LANG,
61+
};
62+
/// <summary>
63+
/// 错误码
64+
/// </summary>
65+
66+
CodeEnum toCodeEnum(const utility::string_t& value) const;
67+
const utility::string_t fromCodeEnum(const CodeEnum value) const;
68+
69+
70+
/// <summary>
71+
/// 错误描述
72+
/// </summary>
73+
utility::string_t getError() const;
74+
bool errorIsSet() const;
75+
void unsetError();
76+
void setError(const utility::string_t& value);
77+
78+
/// <summary>
79+
/// 错误码
80+
/// </summary>
81+
CodeEnum getCode() const;
82+
bool codeIsSet() const;
83+
void unsetCode();
84+
void setCode(const CodeEnum value);
85+
86+
87+
protected:
88+
utility::string_t m_Error;
89+
bool m_ErrorIsSet;
90+
91+
CodeEnum m_Code;
92+
bool m_CodeIsSet;
93+
94+
};
95+
96+
97+
}
98+
}
99+
}
100+
}
101+
102+
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Post_translate_stream_400_response_H_ */
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* UAPI
3+
* UAPI 官方接口文档
4+
*
5+
* The version of the OpenAPI document: 1.0.0
6+
*
7+
* NOTE: This class is auto generated by OpenAPI-Generator 7.17.0.
8+
* https://openapi-generator.tech
9+
* Do not edit the class manually.
10+
*/
11+
12+
/*
13+
* Post_translate_stream_500_response.h
14+
*
15+
*
16+
*/
17+
18+
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Post_translate_stream_500_response_H_
19+
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Post_translate_stream_500_response_H_
20+
21+
22+
#include "CppRestOpenAPIClient/ModelBase.h"
23+
24+
#include <cpprest/details/basic_types.h>
25+
26+
namespace org {
27+
namespace openapitools {
28+
namespace client {
29+
namespace model {
30+
31+
32+
33+
class Post_translate_stream_500_response
34+
: public ModelBase
35+
{
36+
public:
37+
Post_translate_stream_500_response();
38+
virtual ~Post_translate_stream_500_response();
39+
40+
/////////////////////////////////////////////
41+
/// ModelBase overrides
42+
43+
void validate() override;
44+
45+
web::json::value toJson() const override;
46+
bool fromJson(const web::json::value& json) override;
47+
48+
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
49+
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
50+
51+
52+
/////////////////////////////////////////////
53+
/// Post_translate_stream_500_response members
54+
55+
56+
/// <summary>
57+
/// 错误描述
58+
/// </summary>
59+
utility::string_t getError() const;
60+
bool errorIsSet() const;
61+
void unsetError();
62+
void setError(const utility::string_t& value);
63+
64+
utility::string_t getCode() const;
65+
bool codeIsSet() const;
66+
void unsetCode();
67+
void setCode(const utility::string_t& value);
68+
69+
70+
protected:
71+
utility::string_t m_Error;
72+
bool m_ErrorIsSet;
73+
74+
utility::string_t m_Code;
75+
bool m_CodeIsSet;
76+
77+
};
78+
79+
80+
}
81+
}
82+
}
83+
}
84+
85+
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Post_translate_stream_500_response_H_ */
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/**
2+
* UAPI
3+
* UAPI 官方接口文档
4+
*
5+
* The version of the OpenAPI document: 1.0.0
6+
*
7+
* NOTE: This class is auto generated by OpenAPI-Generator 7.17.0.
8+
* https://openapi-generator.tech
9+
* Do not edit the class manually.
10+
*/
11+
12+
/*
13+
* Post_translate_stream_request.h
14+
*
15+
*
16+
*/
17+
18+
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Post_translate_stream_request_H_
19+
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Post_translate_stream_request_H_
20+
21+
#include <stdexcept>
22+
23+
#include "CppRestOpenAPIClient/ModelBase.h"
24+
25+
#include <cpprest/details/basic_types.h>
26+
27+
namespace org {
28+
namespace openapitools {
29+
namespace client {
30+
namespace model {
31+
32+
33+
34+
class Post_translate_stream_request
35+
: public ModelBase
36+
{
37+
public:
38+
Post_translate_stream_request();
39+
virtual ~Post_translate_stream_request();
40+
41+
/////////////////////////////////////////////
42+
/// ModelBase overrides
43+
44+
void validate() override;
45+
46+
web::json::value toJson() const override;
47+
bool fromJson(const web::json::value& json) override;
48+
49+
void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override;
50+
bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override;
51+
52+
53+
/////////////////////////////////////////////
54+
/// Post_translate_stream_request members
55+
56+
enum class To_langEnum
57+
{
58+
_,
59+
_2,
60+
};
61+
/// <summary>
62+
/// 目标语言,支持:中文、英文
63+
/// </summary>
64+
enum class From_langEnum
65+
{
66+
_,
67+
_2,
68+
AUTO,
69+
};
70+
/// <summary>
71+
/// 源语言,支持:中文、英文、auto(自动检测)。默认为auto
72+
/// </summary>
73+
74+
To_langEnum toTo_langEnum(const utility::string_t& value) const;
75+
const utility::string_t fromTo_langEnum(const To_langEnum value) const;
76+
77+
78+
From_langEnum toFrom_langEnum(const utility::string_t& value) const;
79+
const utility::string_t fromFrom_langEnum(const From_langEnum value) const;
80+
81+
82+
/// <summary>
83+
/// 待翻译的文本内容
84+
/// </summary>
85+
utility::string_t getQuery() const;
86+
bool queryIsSet() const;
87+
void unsetQuery();
88+
void setQuery(const utility::string_t& value);
89+
90+
/// <summary>
91+
/// 目标语言,支持:中文、英文
92+
/// </summary>
93+
To_langEnum getToLang() const;
94+
bool toLangIsSet() const;
95+
void unsetTo_lang();
96+
void setToLang(const To_langEnum value);
97+
98+
/// <summary>
99+
/// 源语言,支持:中文、英文、auto(自动检测)。默认为auto
100+
/// </summary>
101+
From_langEnum getFromLang() const;
102+
bool fromLangIsSet() const;
103+
void unsetFrom_lang();
104+
void setFromLang(const From_langEnum value);
105+
106+
/// <summary>
107+
/// 语气参数,可选
108+
/// </summary>
109+
utility::string_t getTone() const;
110+
bool toneIsSet() const;
111+
void unsetTone();
112+
void setTone(const utility::string_t& value);
113+
114+
115+
protected:
116+
utility::string_t m_Query;
117+
bool m_QueryIsSet;
118+
119+
To_langEnum m_To_lang;
120+
bool m_To_langIsSet;
121+
122+
From_langEnum m_From_lang;
123+
bool m_From_langIsSet;
124+
125+
utility::string_t m_Tone;
126+
bool m_ToneIsSet;
127+
128+
};
129+
130+
131+
}
132+
}
133+
}
134+
}
135+
136+
#endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_Post_translate_stream_request_H_ */

0 commit comments

Comments
 (0)