图五:MediaTek Genio 130 EVK
接着,我们需要将 Gneio 130 EVK 连接上已知的 WIFI AP;透过一连串的 WiFi CLI command 来建立 Gneio 130 EVK 的网路连线,这个 WIFI AP profile 也可储存在 Gneio 130 EVK 的 NVDM 中,之后的开机都将会自动套用 profile 进行 WIFI 连线。
$ wifi init
$ wifi config set ssid 0 SSID
$ wifi config set sec 0 7 6
$ wifi config set psk 0 PASSWORD
$ wifi config set reload
再来,我们透过已实作好的 ChatGPT CLI command 启动 ChatGPT 服务
$ chatgpt_start
完成后,我们便可透过按下 SW2 按钮,并使用自然语言做提问:你好,请自我介绍。
通过 OpenAI API 一连串的处理:audio/transcriptions --> chat/completions --> audio/speech。完成了一次的"对话",以下以封包形式展示:
[249093]<633>[common][I][openAI_chatGPT_task][1289]send audio data complete!
recv data_size:38,
{
"text": "你好,请自我介绍"
}
[249637]<634>[common][I][openAI_chatGPT_task][1294]httpclient_posthttps://api.openai.com/v1/audio/transcriptions success !
req: 你好,请自我介绍
[249639]<635>[common][I][openAI_chatGPT_task][1335]send chat request !
[249645]<636>[common][I][openAI_chatGPT_task][1351]send chat request complete!
recv data_size:757,
{
"id": "chatcmpl-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"object": "chat.completion",
"created": 1724683334,
"model": "gpt-4o-mini-2024-07-18",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "你好!我是聊天机器人助手,旨在回答问题、提供资讯和帮助解决各种需求。不论是学习新知识、寻找建议、撰写文本,还是其他各种话题,我都可以提供帮助。如果你有任何问题或需求,随时告诉我!",
"refusal": null
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 13,
"completion_tokens": 74,
"total_tokens": 87
},
"system_fingerprint": "fp_507c9469a1"
}
[251591]<637>[common][I][openAI_chatGPT_task][1355]httpclient_posthttps://api.openai.com/v1/chat/completions success !
req txt: 你好!我是聊天机器人助手,旨在回答问题、提供资讯和帮助解决各种需求。不论是学习新知识、寻找建议、撰写文本,还是其他各种话题,我都可以提供帮助。如果你有任何问题或需求,随时告诉我!
[251594]<638>[common][I][openAI_chatGPT_task][1397]send text!
[251601]<639>[common][I][openAI_chatGPT_task][1413]send text complete!
mp3_codec_start_play,829
[MP3 Codec]Open codec
[MP3 Codec]: mp3_decode_buffer 0x1067c0c8 (len 41000), mp3_codec_internal_handle 0x1057a1f0 (size 220), handle 0x1057a1f0
[MP3 Codec]mp3_codec_task_main create
[MP3 Codec Demo] first write data 4095.mp3_codec_start_play,848
[MP3 Codec Demo] play +
[MP3 Codec] mp3_codec_play_internal ++
[MP3 Codec] mp3_codec_play_internal --
[MP3 Codec Demo] play -
recv data done:total size:340800, this block:14400
[260847]<649>[common][I][openAI_chatGPT_task][1434]httpclient_posthttps://api.openai.com/v1/audio/speech success !
另一个操作展示:计算952加33再除以2 有小数点吗?小数点是多少?
[9323894]<699>[common][I][openAI_chatGPT_task][1289]send audio data complete!
recv data_size:76,
{
"text": "计算952加33再除以2 有小数点吗?小数点是多少?"
}
[9324831]<700>[common][I][openAI_chatGPT_task][1294]httpclient_posthttps://api.openai.com/v1/audio/transcriptions success !
req: 计算952加33再除以2 有小数点吗?小数点是多少?
[9324833]<701>[common][I][openAI_chatGPT_task][1335]send chat request !
[9324840]<702>[common][I][openAI_chatGPT_task][1351]send chat request complete!
recv data_size:707,
{
"id": "chatcmpl-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"object": "chat.completion",
"created": 1724692409,
"model": "gpt-4o-mini-2024-07-18",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "首先,我们先计算 \\( 952 + 33 \\)。\n\n\\[\n952 + 33 = 985\n\\]\n\n接下来,将这个结果除以 2:\n\n\\[\n\\frac{985}{2} = 492.5\n\\]\n\n因此,计算结果有小数点,且小数点是 **0.5**。",
"refusal": null
},
"logprobs": null,
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 27,
"completion_tokens": 77,
"total_tokens": 104
},
"system_fingerprint": "fp_f3db212e1c"
}
[9326680]<703>[common][I][openAI_chatGPT_task][1355]httpclient_posthttps://api.openai.com/v1/chat/completions success !
req txt: 首先,我们先计算 \\( 952 + 33 \\)。\n\n\\[\n952 + 33 = 985\n\\]\n\n接下来,将这个结果除以 2:\n\n\\[\n\\frac{985}{2} = 492.5\n\\]\n\n因此,计算结果有小数点,且小数点是 **0.5**。
[9326683]<704>[common][I][openAI_chatGPT_task][1397]send text!
[9326690]<705>[common][I][openAI_chatGPT_task][1413]send text complete!
mp3_codec_start_play,829
[MP3 Codec]Open codec
[MP3 Codec]: mp3_decode_buffer 0x1067c0c8 (len 41000), mp3_codec_internal_handle 0x1057a1f0 (size 220), handle 0x1057a1f0
[MP3 Codec]mp3_codec_task_main create
[MP3 Codec Demo] first write data 4095.mp3_codec_start_play,848
[MP3 Codec Demo] play +
[MP3 Codec] mp3_codec_play_internal ++
[MP3 Codec] mp3_codec_play_internal --
[MP3 Codec Demo] play -
recv data done:total size:296640, this block:2880
[9330700]<715>[common][I][openAI_chatGPT_task][1434]httpclient_posthttps://api.openai.com/v1/audio/speech success !
►场景应用图