@@ -33,22 +33,56 @@ using namespace std;
3333
3434// Linux Macos::g++ -std=c++17 -Wall -g AIApi_APPExample.cpp -o AIApi_APPExample.exe -L ../../XEngine_Module/XEngine_AIApi -lXEngine_AIApi
3535
36- void XCALLBACK XEngine_AIApi_CBRecv (XNETHANDLE xhToken, LPCXSTR lpszModelName, LPCXSTR lpszMsgBuffer, int nMsgLen, XPVOID lParam)
36+ void XCALLBACK XEngine_AIApi_CBRecv (XNETHANDLE xhToken, LPCXSTR lpszModelName, LPCXSTR lpszMsgBuffer, int nMsgLen, bool bThink, XPVOID lParam)
3737{
38- printf (" %lld,Name:%s:%d=%s\n " , xhToken, lpszModelName, nMsgLen, lpszMsgBuffer);
38+ if (bThink)
39+ {
40+ printf (" think:%lld,Name:%s:%d=%s\n " , xhToken, lpszModelName, nMsgLen, lpszMsgBuffer);
41+ }
42+ else
43+ {
44+ printf (" chat:%lld,Name:%s:%d=%s\n " , xhToken, lpszModelName, nMsgLen, lpszMsgBuffer);
45+ }
3946}
40- int main ()
47+
48+ int Test_Think ()
4149{
4250 XNETHANDLE xhToken = 0 ;
4351
44- LPCXSTR lpszAPIUrl = _X (" https://api.zhizengzeng.com/v1/chat/completions" );
45- LPCXSTR lpszAPIKey = _X (" sk-zk2e0065dd7c8411828ce612337c2f9d1086841436f63c48" );
46- LPCXSTR lpszAPIModel = _X (" gpt-4o" );
52+ LPCXSTR lpszAPIUrl = _X (" https://ark.cn-beijing.volces.com/api/v3/chat/completions" );
53+ LPCXSTR lpszAPIKey = _X (" 1" );
54+ LPCXSTR lpszAPIModel = _X (" doubao-seed-1-6-thinking-250615" );
55+
56+ if (!AIApi_Chat_Create (&xhToken, lpszAPIUrl, lpszAPIKey, XEngine_AIApi_CBRecv))
57+ {
58+ printf (" AIApi_Chat_Create:%lX\n " , AIApi_GetLastError ());
59+ return 0 ;
60+ }
61+ AIApi_Chat_SetRole (xhToken, _X (" You are a helpful assistant." ));
62+ LPCXSTR lpszMSGBuffer = _X (" 李白是谁?" );
63+ int nMSGLen = strlen (lpszMSGBuffer);
64+ if (!AIApi_Chat_Excute (xhToken, lpszAPIModel, lpszMSGBuffer, nMSGLen, true ))
65+ {
66+ printf (" AIApi_Chat_Excute:%lX\n " , AIApi_GetLastError ());
67+ return 0 ;
68+ }
69+ bool bCompleted = false ;
70+ AIApi_Chat_GetStatus (xhToken, &bCompleted);
71+ AIApi_Chat_Destory (xhToken);
72+ return 1 ;
73+ }
74+ int Test_Chat ()
75+ {
76+ XNETHANDLE xhToken = 0 ;
77+
78+ // LPCXSTR lpszAPIUrl = _X("https://api.zhizengzeng.com/v1/chat/completions");
79+ // LPCXSTR lpszAPIKey = _X("sk-1");
80+ // LPCXSTR lpszAPIModel = _X("gpt-4o");
81+
82+ LPCXSTR lpszAPIUrl = _X (" https://api.hunyuan.cloud.tencent.com/v1/chat/completions" );
83+ LPCXSTR lpszAPIKey = _X (" sk-1" );
84+ LPCXSTR lpszAPIModel = _X (" hunyuan-turbos-latest" );
4785
48- // LPCXSTR lpszAPIUrl = _X("https://api.hunyuan.cloud.tencent.com/v1/chat/completions");
49- // LPCXSTR lpszAPIKey = _X("sk-dXVprOeQSWrodQcTYuHoGytHaifId7QlwaBebeWxfyPUipFk");
50- // LPCXSTR lpszAPIModel = _X("hunyuan-turbos-latest");
51-
5286 if (!AIApi_Chat_Create (&xhToken, lpszAPIUrl, lpszAPIKey, XEngine_AIApi_CBRecv))
5387 {
5488 printf (" AIApi_Chat_Create:%lX\n " , AIApi_GetLastError ());
@@ -86,4 +120,10 @@ int main()
86120 AIApi_Chat_GetStatus (xhToken, &bCompleted);
87121 AIApi_Chat_Destory (xhToken);
88122 return 1 ;
123+ }
124+ int main ()
125+ {
126+ Test_Think ();
127+ Test_Chat ();
128+ return 0 ;
89129}
0 commit comments