{"id":122571,"date":"2026-11-05T06:01:10","date_gmt":"2026-11-04T22:01:10","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/122571.html"},"modified":"2026-11-05T06:01:10","modified_gmt":"2026-11-04T22:01:10","slug":"%e3%80%8ac-%e9%a1%b9%e7%9b%ae%ef%bc%9a%e6%89%8b%e5%86%99%e5%a4%a7%e6%a8%a1%e5%9e%8b%e6%8e%a5%e5%85%a5-sdk%e3%80%8bdeepseek%e6%8e%a5%e5%8f%a3%e8%ae%be%e8%ae%a1%ef%bc%88%e4%b8%8b%ef%bc%89%ef%bc%9a","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/122571.html","title":{"rendered":"\u300aC++ \u9879\u76ee\uff1a\u624b\u5199\u5927\u6a21\u578b\u63a5\u5165 SDK\u300bDeepSeek\u63a5\u53e3\u8bbe\u8ba1\uff08\u4e0b\uff09\uff1a\u6d41\u5f0f\u54cd\u5e94\u5b9e\u73b0\u548c\u6d4b\u8bd5"},"content":{"rendered":"<p style=\"text-align:center\">\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"91\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104220101-6aebab1d8cfd7.png\" width=\"100\" \/><\/p>\n<p style=\"text-align:center\">&#x1f525;<span style=\"color:#fe2c24\">\u5c0f\u53f6-duck<\/span>&#xff1a;\u4e2a\u4eba\u4e3b\u9875<\/p>\n<p style=\"text-align:center\">\u00a0\u2744\ufe0f<span style=\"color:#4da8ee\">\u4e2a\u4eba\u4e13\u680f<\/span>&#xff1a;\u300aData-Structure-Learning\u300b\u300aC&#043;&#043;\u5165\u95e8\u5230\u8fdb\u9636&amp;\u81ea\u6211\u5b66\u4e60\u8fc7\u7a0b\u8bb0\u5f55\u300b \u300aLinux\u7cfb\u7edf\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b\u300aLinux\u7f51\u7edc\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b \u300aQt \u65b9\u5bf8\u6781\u5883\u300b\u00a0\u300aMySQL\u300b<\/p>\n<p style=\"text-align:center\">\u2728<span style=\"color:#ffd900\">\u672a\u62e9\u4e4b\u8def&#xff0c;\u4e0d\u987b\u56de\u5934 \u5df2\u62e9\u4e4b\u8def&#xff0c;\u7eb5\u662f\u8346\u68d8\u904d\u91ce&#xff0c;\u4ea6\u4f5c\u82b1\u6d77\u9068\u6e38<\/span><\/p>\n<hr \/>\n<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"%E5%89%8D%E8%A8%80-toc\" style=\"margin-left:0px\">\u524d\u8a00<\/p>\n<p id=\"%E4%B8%80%E3%80%81DeepSeek%20%E6%B5%81%E5%BC%8F%E5%93%8D%E5%BA%94%E6%8E%A5%E5%8F%A3%E5%AE%9E%E7%8E%B0-toc\" style=\"margin-left:0px\">\u4e00\u3001DeepSeek \u6d41\u5f0f\u54cd\u5e94\u63a5\u53e3\u5b9e\u73b0<\/p>\n<p id=\"%C2%A0%201.1%C2%A0%E6%8E%A5%E5%8F%A3%E5%AE%9A%E4%B9%89%E4%B8%8E%E8%81%8C%E8%B4%A3%E8%BE%B9%E7%95%8C-toc\" style=\"margin-left:40px\">\u00a0 1.1\u00a0\u63a5\u53e3\u5b9a\u4e49\u4e0e\u804c\u8d23\u8fb9\u754c<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.1.1%C2%A0%E6%96%B9%E6%B3%95%E7%AD%BE%E5%90%8D-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.1.1\u00a0\u65b9\u6cd5\u7b7e\u540d<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.1.2%C2%A0%E5%9B%9E%E8%B0%83%E5%A5%91%E7%BA%A6-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.1.2\u00a0\u56de\u8c03\u5951\u7ea6<\/p>\n<p id=\"%C2%A0%201.2%C2%A0%E5%AE%8C%E6%95%B4%E5%AE%9E%E7%8E%B0%E6%B5%81%E7%A8%8B%E4%B8%8E%E4%BB%A3%E7%A0%81%E9%80%90%E6%AD%A5%E8%A7%A3%E6%9E%90-toc\" style=\"margin-left:40px\">\u00a0 1.2\u00a0\u5b8c\u6574\u5b9e\u73b0\u6d41\u7a0b\u4e0e\u4ee3\u7801\u9010\u6b65\u89e3\u6790<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.2.1%C2%A0%E6%A8%A1%E5%9E%8B%E5%8F%AF%E7%94%A8%E6%80%A7%E6%A0%A1%E9%AA%8C-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.2.1\u00a0\u6a21\u578b\u53ef\u7528\u6027\u6821\u9a8c<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.2.2%C2%A0%E6%9E%84%E9%80%A0%E5%B9%B6%E8%8E%B7%E5%8F%96%E8%AF%B7%E6%B1%82%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.2.2\u00a0\u6784\u9020\u5e76\u83b7\u53d6\u8bf7\u6c42\u53c2\u6570<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.2.3%C2%A0%E7%BB%84%E8%A3%85%20messages%20%E5%AF%B9%E8%AF%9D%E6%95%B0%E7%BB%84-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.2.3\u00a0\u7ec4\u88c5 messages \u5bf9\u8bdd\u6570\u7ec4<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.2.4%C2%A0%E6%9E%84%E9%80%A0%E8%AF%B7%E6%B1%82%E4%BD%93%EF%BC%8C%E5%BC%80%E5%90%AF%E6%B5%81%E5%BC%8F%E5%BC%80%E5%85%B3-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.2.4\u00a0\u6784\u9020\u8bf7\u6c42\u4f53&#xff0c;\u5f00\u542f\u6d41\u5f0f\u5f00\u5173<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.2.5%C2%A0JSON%20%E5%BA%8F%E5%88%97%E5%8C%96%20%2B%20%E6%9E%84%E9%80%A0%20httplib%20%E5%AE%A2%E6%88%B7%E7%AB%AF%E4%B8%8E%E8%AF%B7%E6%B1%82%E5%A4%B4-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.2.5\u00a0JSON \u5e8f\u5217\u5316 &#043; \u6784\u9020 httplib \u5ba2\u6237\u7aef\u4e0e\u8bf7\u6c42\u5934<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.2.6%C2%A0%E5%AE%9A%E4%B9%89%E5%85%A8%E5%B1%80%E7%BC%93%E5%AD%98%E4%B8%8E%E7%8A%B6%E6%80%81%E6%A0%87%E8%AE%B0-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.2.6\u00a0\u5b9a\u4e49\u5168\u5c40\u7f13\u5b58\u4e0e\u72b6\u6001\u6807\u8bb0<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.2.7%C2%A0%E6%9E%84%E5%BB%BA%20httplib%3A%3ARequest%20%E8%AF%B7%E6%B1%82%E5%AF%B9%E8%B1%A1-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.2.7\u00a0\u6784\u5efa httplib::Request \u8bf7\u6c42\u5bf9\u8c61<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.2.8%C2%A0response_handler%EF%BC%9A%E5%93%8D%E5%BA%94%E5%A4%B4%E6%A0%A1%E9%AA%8C%E5%9B%9E%E8%B0%83-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.2.8\u00a0response_handler&#xff1a;\u54cd\u5e94\u5934\u6821\u9a8c\u56de\u8c03<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.2.9%C2%A0content_receiver%EF%BC%9ASSE%20%E5%88%86%E7%89%87%E8%A7%A3%E6%9E%90%E6%A0%B8%E5%BF%83%E5%9B%9E%E8%B0%83-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.2.9\u00a0content_receiver&#xff1a;SSE \u5206\u7247\u89e3\u6790\u6838\u5fc3\u56de\u8c03<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.2.10%C2%A0client.send%20%E5%8F%91%E8%B5%B7%E8%AF%B7%E6%B1%82%20%2B%20%E7%BB%93%E6%9E%9C%E5%88%A4%E6%96%AD-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.2.10\u00a0client.send \u53d1\u8d77\u8bf7\u6c42 &#043; \u7ed3\u679c\u5224\u65ad<\/p>\n<p id=\"%C2%A0%20%C2%A0%20%E8%A1%A5%E5%85%85%20client.send%20%E5%8E%9F%E7%90%86%E5%88%86%E6%9E%90-toc\" style=\"margin-left:120px\">\u00a0 \u00a0 \u8865\u5145 client.send \u539f\u7406\u5206\u6790<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.2.11%C2%A0%E6%B5%81%E5%BC%8F%E5%93%8D%E5%BA%94%E6%8E%A5%E5%8F%A3%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81%EF%BC%88%E9%99%84%E6%B3%A8%E9%87%8A%E5%88%86%E6%9E%90%EF%BC%89-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.2.11\u00a0\u6d41\u5f0f\u54cd\u5e94\u63a5\u53e3\u5b8c\u6574\u4ee3\u7801&#xff08;\u9644\u6ce8\u91ca\u5206\u6790&#xff09;<\/p>\n<p id=\"%C2%A0%201.3%20%E8%A1%A5%E5%85%85%EF%BC%9A%E7%BC%96%E8%AF%91%E9%97%AE%E9%A2%98%E5%AE%9A%E4%BD%8D%E4%B8%8E%E4%BF%AE%E5%A4%8D-toc\" style=\"margin-left:40px\">\u00a0 1.3 \u8865\u5145&#xff1a;\u7f16\u8bd1\u95ee\u9898\u5b9a\u4f4d\u4e0e\u4fee\u590d<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.3.1%C2%A0%E9%94%99%E8%AF%AF%E7%8E%B0%E8%B1%A1-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.3.1\u00a0\u9519\u8bef\u73b0\u8c61<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.3.2%C2%A0%E6%A0%B9%E5%9B%A0%E5%88%86%E6%9E%90-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.3.2\u00a0\u6839\u56e0\u5206\u6790<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.3.3%C2%A0%E4%BF%AE%E5%A4%8D%E6%96%B9%E6%A1%88-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.3.3\u00a0\u4fee\u590d\u65b9\u6848<\/p>\n<p id=\"%C2%A0%20%C2%A0%201.3.4%C2%A0%E5%B0%8F%E7%BB%93-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 1.3.4\u00a0\u5c0f\u7ed3<\/p>\n<p id=\"%E4%BA%8C%E3%80%81%E6%B5%81%E5%BC%8F%E5%93%8D%E5%BA%94%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95-toc\" style=\"margin-left:0px\">\u4e8c\u3001\u6d41\u5f0f\u54cd\u5e94\u5355\u5143\u6d4b\u8bd5<\/p>\n<p id=\"%C2%A0%202.1%C2%A0%E5%88%9D%E5%A7%8B%E5%8C%96%E4%B8%8E%E9%85%8D%E7%BD%AE-toc\" style=\"margin-left:40px\">\u00a0 2.1\u00a0\u521d\u59cb\u5316\u4e0e\u914d\u7f6e<\/p>\n<p id=\"%C2%A0%202.2%C2%A0%E5%85%A5%E5%8F%A3%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:40px\">\u00a0 2.2\u00a0\u5165\u53e3\u51fd\u6570<\/p>\n<p id=\"%C2%A0%202.3%20%E8%BF%90%E8%A1%8C%E7%BB%93%E6%9E%9C%E5%B1%95%E7%A4%BA-toc\" style=\"margin-left:40px\">\u00a0 2.3 \u8fd0\u884c\u7ed3\u679c\u5c55\u793a<\/p>\n<p id=\"%C2%A0%202.4%C2%A0%E5%BC%95%E5%87%BA%E7%96%91%E9%97%AE-toc\" style=\"margin-left:40px\">\u00a0 2.4\u00a0\u5f15\u51fa\u7591\u95ee<\/p>\n<p id=\"%C2%A0%20%C2%A0%202.4.1%C2%A0%E5%85%88%E8%A7%A3%E9%87%8A%EF%BC%9A%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E2%80%9C%E8%B4%B4%E5%BF%83%E2%80%9D%EF%BC%8C%E5%A4%A7%E6%A6%82%E7%8E%87%E5%8F%91%E9%80%81%E5%AE%8C%E6%95%B4%E7%9A%84%20SSE-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 2.4.1\u00a0\u5148\u89e3\u91ca&#xff1a;\u670d\u52a1\u5668\u7684\u201c\u8d34\u5fc3\u201d&#xff0c;\u5927\u6982\u7387\u53d1\u9001\u5b8c\u6574\u7684 SSE<\/p>\n<p id=\"%C2%A0%20%C2%A0%202.4.2%C2%A0%E7%8E%B0%E5%AE%9E%E7%9A%84%E2%80%9C%E6%AE%8B%E9%85%B7%E2%80%9D%EF%BC%9A%E9%98%B2%E4%BA%BA%E4%B9%8B%E5%BF%83%E4%B8%8D%E5%8F%AF%E6%97%A0-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 2.4.2\u00a0\u73b0\u5b9e\u7684\u201c\u6b8b\u9177\u201d&#xff1a;\u9632\u4eba\u4e4b\u5fc3\u4e0d\u53ef\u65e0<\/p>\n<p id=\"%C2%A0%20%C2%A0%202.4.3%C2%A0%E7%BB%93%E8%AE%BA%EF%BC%9A%E6%97%A5%E5%BF%97%E9%87%8C%E7%9C%8B%E4%B8%8D%E5%88%B0%E5%8D%8A%E5%8C%85%20%E2%89%A0%20%E4%B8%8D%E9%9C%80%E8%A6%81%20buffer%20%2B%20while%20%E5%85%9C%E5%BA%95-toc\" style=\"margin-left:80px\">\u00a0 \u00a0 2.4.3\u00a0\u7ed3\u8bba&#xff1a;\u65e5\u5fd7\u91cc\u770b\u4e0d\u5230\u534a\u5305 \u2260 \u4e0d\u9700\u8981 buffer &#043; while \u515c\u5e95<\/p>\n<p id=\"%E6%80%BB%E7%BB%93%EF%BC%9A-toc\" style=\"margin-left:80px\">\u603b\u7ed3&#xff1a;<\/p>\n<p id=\"%E7%BB%93%E6%9D%9F%E8%AF%AD-toc\" style=\"margin-left:0px\">\u7ed3\u675f\u8bed<\/p>\n<hr id=\"hr-toc\" \/>\n<h2 id=\"%E5%89%8D%E8%A8%80\">\u524d\u8a00<\/h2>\n<p>\u00a0 \u00a0 \u00a0 \u524d\u9762\u7ae0\u8282\u6211\u4eec\u5df2\u7ecf\u5b8c\u6210\u4e86 DeepSeek \u975e\u6d41\u5f0f\u63a5\u53e3\u7684\u5c01\u88c5\u3001\u8c03\u8bd5\u4e0e\u5355\u5143\u6d4b\u8bd5&#xff0c;\u7406\u89e3\u4e86\u5982\u4f55\u901a\u8fc7 httplib \u53d1\u8d77 HTTP \u8bf7\u6c42\u3001\u89e3\u6790 JSON \u8fd4\u56de\u7ed3\u679c\u3002\u4f46\u5927\u6a21\u578b\u5bf9\u8bdd\u4ea7\u54c1\u6700\u5e38\u7528\u3001\u4f53\u9a8c\u66f4\u597d\u7684\u6d41\u5f0f\u8f93\u51fa\u80fd\u529b&#xff0c;\u4f9d\u8d56 SSE \u534f\u8bae\u5b9e\u73b0&#xff0c;\u8fd9\u4e5f\u662f\u6211\u4eec\u672c\u7ae0\u8981\u653b\u514b\u7684\u6838\u5fc3\u5185\u5bb9\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u6d41\u5f0f\u63a5\u53e3\u7684\u5b9e\u73b0\u8fdc\u6bd4\u4e00\u6b21\u6027\u8fd4\u56de\u7684\u5168\u91cf\u54cd\u5e94\u590d\u6742&#xff0c;\u5b83\u4e0d\u518d\u662f\u4e00\u6b21\u8bf7\u6c42\u3001\u4e00\u6b21\u5e94\u7b54\u7684\u7b80\u5355\u6a21\u5f0f&#xff0c;\u800c\u662f\u4f9d\u9760\u5206\u6bb5\u56de\u8c03\u6301\u7eed\u63a5\u6536\u670d\u52a1\u7aef\u63a8\u9001\u7684\u6570\u636e\u3002\u8fd9\u91cc\u5b58\u5728\u4e24\u5c42\u5bb9\u6613\u6df7\u6dc6\u7684\u6570\u636e\u8fb9\u754c&#xff1a;HTTP Chunk \u5206\u7247\u8fb9\u754c\u548c SSE \u4e8b\u4ef6\u8fb9\u754c&#xff0c;\u534a\u5305\u89e3\u6790\u3001\u6570\u636e\u7f13\u5b58\u3001\u4e8b\u4ef6\u8fc7\u6ee4\u90fd\u662f\u5f00\u53d1\u4e2d\u6781\u6613\u8e29\u5751\u7684\u5730\u65b9\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u672c\u7ae0\u5c06\u4ece\u63a5\u53e3\u804c\u8d23\u5b9a\u4e49\u5165\u624b&#xff0c;\u4e00\u6b65\u6b65\u62c6\u89e3 DeepSeek \u6d41\u5f0f\u63a5\u53e3\u7684\u5b8c\u6574\u5b9e\u73b0\u6d41\u7a0b&#xff1a;\u4ece\u53c2\u6570\u7ec4\u88c5\u3001\u8bf7\u6c42\u6784\u5efa&#xff0c;\u5230\u54cd\u5e94\u5934\u6821\u9a8c\u3001content_receiver\u5206\u7247\u89e3\u6790\u56de\u8c03\u7684\u6838\u5fc3\u7f16\u7801&#xff1b;\u540c\u65f6\u7ed3\u5408\u6211\u4eec\u5b9e\u9645\u8dd1\u901a\u7684\u6d4b\u8bd5\u65e5\u5fd7&#xff0c;\u89e3\u7b54\u4e00\u4e2a\u5f88\u5173\u952e\u7684\u7591\u95ee&#xff1a;\u6d4b\u8bd5\u65f6\u6bcf\u6b21\u6536\u5230\u7684 Chunk \u91cc SSE \u4e8b\u4ef6\u90fd\u662f\u5b8c\u6574\u7684&#xff0c;\u4e3a\u4ec0\u4e48\u4ee3\u7801\u4ecd\u7136\u5fc5\u987b\u505a Buffer \u7f13\u5b58\u4e0e\u5faa\u73af\u5207\u5206\u7684\u9632\u5fa1\u6027\u89e3\u6790\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u9664\u6b64\u4e4b\u5916&#xff0c;\u6211\u4eec\u4e5f\u4f1a\u8bb0\u5f55\u5f00\u53d1\u9014\u4e2d\u9047\u5230\u7684\u7f16\u8bd1\u62a5\u9519\u95ee\u9898&#xff0c;\u68b3\u7406\u5bf9\u5e94\u7684\u5b9a\u4f4d\u601d\u8def\u4e0e\u4fee\u590d\u65b9\u6848&#xff0c;\u6700\u540e\u501f\u52a9 GTest \u5b8c\u6210\u6d41\u5f0f\u63a5\u53e3\u7684\u5355\u5143\u6d4b\u8bd5&#xff0c;\u9a8c\u8bc1\u6574\u5957\u6d41\u5f0f SDK \u94fe\u8def\u7684\u53ef\u7528\u6027\u3002\u8bfb\u5b8c\u672c\u7ae0&#xff0c;\u4f60\u5c06\u638c\u63e1\u5728 C&#043;&#043; \u4e2d\u57fa\u4e8e httplib \u5b9e\u73b0 SSE \u6d41\u5f0f\u5927\u6a21\u578b\u8c03\u7528\u7684\u5b8c\u6574\u5de5\u7a0b\u5199\u6cd5&#xff0c;\u7406\u89e3\u6d41\u5f0f\u89e3\u6790\u80cc\u540e\u7684\u534f\u8bae\u7ec6\u8282\u4e0e\u9632\u5fa1\u6027\u7f16\u7801\u601d\u60f3\u3002<\/p>\n<h2 id=\"%E4%B8%80%E3%80%81DeepSeek%20%E6%B5%81%E5%BC%8F%E5%93%8D%E5%BA%94%E6%8E%A5%E5%8F%A3%E5%AE%9E%E7%8E%B0\">\u4e00\u3001DeepSeek \u6d41\u5f0f\u54cd\u5e94\u63a5\u53e3\u5b9e\u73b0<\/h2>\n<p>\u00a0 \u00a0 \u00a0 \u5728\u524d\u4e00\u7ae0\u6211\u4eec\u5403\u900f\u4e86 HTTP Chunk\u3001SSE \u4e8b\u4ef6\u5757\u3001httplib \u6d41\u5f0f\u56de\u8c03\u7684\u5e95\u5c42\u89c4\u5219\u4e0e\u5404\u7c7b\u8fb9\u754c\u5f02\u5e38\u573a\u666f&#xff0c;\u672c\u7ae0\u5c31\u843d\u5730\u7f16\u7801&#xff0c;\u5b9e\u73b0sendMessageStream\u6d41\u5f0f\u589e\u91cf\u63a5\u53e3&#xff0c;\u5b8c\u6210\u5927\u6a21\u578b\u6253\u5b57\u673a\u9010\u5b57\u8f93\u51fa\u6548\u679c\u3002<\/p>\n<h3 id=\"%C2%A0%201.1%C2%A0%E6%8E%A5%E5%8F%A3%E5%AE%9A%E4%B9%89%E4%B8%8E%E8%81%8C%E8%B4%A3%E8%BE%B9%E7%95%8C\">\u00a0 1.1\u00a0\u63a5\u53e3\u5b9a\u4e49\u4e0e\u804c\u8d23\u8fb9\u754c<\/h3>\n<h4 id=\"%C2%A0%20%C2%A0%201.1.1%C2%A0%E6%96%B9%E6%B3%95%E7%AD%BE%E5%90%8D\">\u00a0 \u00a0 1.1.1\u00a0\u65b9\u6cd5\u7b7e\u540d<\/h4>\n<p>namespace ai_chat_sdk {<br \/>\nclass DeepSeekProvider {<br \/>\npublic:<br \/>\n    \/**<br \/>\n     * &#064;brief \u53d1\u9001\u6d88\u606f\u5e76\u63a5\u6536\u6d41\u5f0f\u589e\u91cf\u54cd\u5e94<br \/>\n     * &#064;param messages \u5386\u53f2\u5bf9\u8bdd\u6d88\u606f\u5217\u8868<br \/>\n     * &#064;param requestParam \u8bf7\u6c42\u53c2\u6570\u6620\u5c04&#xff08;temperature\u3001max_tokens\u7b49&#xff09;<br \/>\n     * &#064;param callback \u589e\u91cf\u6570\u636e\u56de\u8c03\u51fd\u6570&#xff0c;\u7531\u8c03\u7528\u65b9\u5b9e\u73b0\u4e1a\u52a1\u903b\u8f91<br \/>\n     * &#064;return std::optional&lt;std::string&gt; \u5b8c\u6574\u7684\u54cd\u5e94\u6587\u672c&#xff08;\u6240\u6709\u589e\u91cf\u62fc\u63a5\u7ed3\u679c&#xff09;<br \/>\n     *\/<br \/>\n    std::optional&lt;std::string&gt; sendMessageStream(<br \/>\n        const std::vector&lt;Message&gt;&amp; messages,<br \/>\n        const std::map&lt;std::string, std::string&gt;&amp; requestParam,<br \/>\n        std::function&lt;void(const std::string &amp;response, bool isEnd)&gt; callback<br \/>\n    );<br \/>\n};<br \/>\n}<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u8fd9\u4e2a\u63a5\u53e3\u4f5c\u4e3a\u4e0a\u5c42\u5bf9\u5916\u8c03\u7528\u5165\u53e3&#xff0c;\u8fd4\u56de\u503c\u662f\u62fc\u63a5\u5b8c\u6210\u540e\u7684\u5b8c\u6574\u56de\u7b54\u5185\u5bb9&#xff1b;\u6838\u5fc3\u4ea4\u4e92\u4f9d\u9760\u4f20\u5165\u7684\u56de\u8c03\u51fd\u6570\u5411\u5916\u63a8\u9001\u5206\u7247\u6570\u636e\u3002<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%201.1.2%C2%A0%E5%9B%9E%E8%B0%83%E5%A5%91%E7%BA%A6\">\u00a0 \u00a0 1.1.2\u00a0\u56de\u8c03\u5951\u7ea6<\/h4>\n<p>\u00a0 \u00a0 \u00a0\u56de\u8c03\u51fd\u6570 std::function&lt;void(const std::string &amp;response, bool isEnd)&gt; \u662f\u6d41\u5f0f SDK \u89e3\u8026\u7684\u5173\u952e&#xff0c;\u7ea6\u5b9a\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\u7b2c\u4e00\u4e2a\u5165\u53c2&#xff1a;\u6a21\u578b\u8fd4\u56de\u7684\u589e\u91cf\u6587\u672c\u7247\u6bb5&#xff0c;\u4ec5\u643a\u5e26\u672c\u6b21\u65b0\u751f\u6210\u7684\u5185\u5bb9&#xff0c;\u4e0d\u662f\u5b8c\u6574\u56de\u590d&#xff1b;<\/li>\n<li>\u7b2c\u4e8c\u4e2a\u5165\u53c2&#xff1a;\u6d41\u7ed3\u675f\u6807\u8bb0\u3002true\u4ee3\u8868\u6240\u6709\u589e\u91cf\u6570\u636e\u63a8\u9001\u5b8c\u6bd5&#xff0c;\u6d41\u6b63\u5e38\u7ed3\u675f&#xff1b;false\u4ee3\u8868\u8fd8\u6709\u540e\u7eed\u5206\u7247&#xff1b;<\/li>\n<li>\u804c\u8d23\u5212\u5206&#xff1a;SDK \u53ea\u8d1f\u8d23\u5b8c\u6210 HTTP \u8bf7\u6c42\u3001SSE \u534f\u8bae\u89e3\u6790\u3001\u63d0\u53d6\u589e\u91cf\u6587\u672c\u5e76\u89e6\u53d1\u56de\u8c03&#xff1b;\u6253\u5370\u3001\u754c\u9762\u6e32\u67d3\u3001\u6301\u4e45\u5316\u5b58\u50a8\u8fd9\u7c7b\u4e1a\u52a1\u903b\u8f91\u5168\u90e8\u4ea4\u7ed9\u4e0a\u5c42\u8c03\u7528\u8005\u5b9e\u73b0&#xff0c;\u5e95\u5c42 Provider \u4e0d\u8026\u5408\u4e1a\u52a1\u3002<\/li>\n<\/ul>\n<h3 id=\"%C2%A0%201.2%C2%A0%E5%AE%8C%E6%95%B4%E5%AE%9E%E7%8E%B0%E6%B5%81%E7%A8%8B%E4%B8%8E%E4%BB%A3%E7%A0%81%E9%80%90%E6%AD%A5%E8%A7%A3%E6%9E%90\">\u00a0 1.2\u00a0\u5b8c\u6574\u5b9e\u73b0\u6d41\u7a0b\u4e0e\u4ee3\u7801\u9010\u6b65\u89e3\u6790<\/h3>\n<h4 id=\"%C2%A0%20%C2%A0%201.2.1%C2%A0%E6%A8%A1%E5%9E%8B%E5%8F%AF%E7%94%A8%E6%80%A7%E6%A0%A1%E9%AA%8C\">\u00a0 \u00a0 1.2.1\u00a0\u6a21\u578b\u53ef\u7528\u6027\u6821\u9a8c<\/h4>\n<p>if (!IsAvailable())<br \/>\n{<br \/>\n    ERR(&#034;DeepSeekProvider sendMessageStream model not available&#034;);<br \/>\n    return std::nullopt;<br \/>\n}<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u7b2c\u4e00\u6b65\u505a\u57fa\u7840\u72b6\u6001\u68c0\u67e5&#xff0c;\u5224\u65ad\u5f53\u524d Provider \u662f\u5426\u5df2\u7ecf\u5b8c\u6210\u521d\u59cb\u5316\u3001\u914d\u7f6e\u597dapi-key\u4e0ebaseUrl&#xff0c;\u672a\u5c31\u7eea\u76f4\u63a5\u8fd4\u56de&#xff0c;\u63d0\u524d\u62e6\u622a\u975e\u6cd5\u8c03\u7528\u3002<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%201.2.2%C2%A0%E6%9E%84%E9%80%A0%E5%B9%B6%E8%8E%B7%E5%8F%96%E8%AF%B7%E6%B1%82%E5%8F%82%E6%95%B0\">\u00a0 \u00a0 1.2.2\u00a0\u6784\u9020\u5e76\u83b7\u53d6\u8bf7\u6c42\u53c2\u6570<\/h4>\n<p>\u00a0 \u00a0 \u00a0 \u6211\u4eec\u628a\u53c2\u6570\u5206\u4e3a\u4e24\u7c7b&#xff1a;\u4e00\u7c7b\u662f\u56fa\u5b9a\u5728\u57fa\u7c7b\u7684\u8fde\u63a5\u914d\u7f6e&#xff0c;\u53e6\u4e00\u7c7b\u662f\u6bcf\u6b21\u8bf7\u6c42\u53ef\u53d8\u7684\u8bf7\u6c42\u53c2\u6570&#xff0c;\u653e\u5728requestParam\u4e2d\u4f20\u5165\u3002<\/p>\n<p>\/\/ 2.1 \u8bbe\u7f6e\u53c2\u6570\u9ed8\u8ba4\u503c<br \/>\ndouble temperature &#061; 0.7;<br \/>\nint max_tokens &#061; 2048;<br \/>\nstd::string thinking_type &#061; &#034;disabled&#034;;<br \/>\nstd::string reasoning_effort &#061; &#034;high&#034;;<br \/>\nstd::string model;<\/p>\n<p>\/\/ 2.2 \u4ece\u5165\u53c2map\u8986\u76d6\u9ed8\u8ba4\u914d\u7f6e<br \/>\nauto it &#061; requestParam.find(&#034;temperature&#034;);<br \/>\nif (it !&#061; requestParam.end())<br \/>\n{<br \/>\n    temperature &#061; std::stod(it-&gt;second);<br \/>\n}<br \/>\nit &#061; requestParam.find(&#034;max_tokens&#034;);<br \/>\nif (it !&#061; requestParam.end())<br \/>\n{<br \/>\n    max_tokens &#061; std::stoi(it-&gt;second);<br \/>\n}<br \/>\nit &#061; requestParam.find(&#034;thinking_type&#034;);<br \/>\nif (it !&#061; requestParam.end())<br \/>\n{<br \/>\n    thinking_type &#061; it-&gt;second;<br \/>\n}<br \/>\nit &#061; requestParam.find(&#034;reasoning_effort&#034;);<br \/>\nif (it !&#061; requestParam.end())<br \/>\n{<br \/>\n    reasoning_effort &#061; it-&gt;second;<br \/>\n}<\/p>\n<p>\/\/ model \u6a21\u578b\u540d\u79f0\u4e3a\u5fc5\u586b\u9879&#xff0c;\u8c03\u7528\u65b9\u5fc5\u987b\u4f20\u5165<br \/>\nit &#061; requestParam.find(&#034;model&#034;);<br \/>\nif (it !&#061; requestParam.end())<br \/>\n{<br \/>\n    model &#061; it-&gt;second;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n    ERR(&#034;model name not found in requestParams, must config it&#034;);<br \/>\n    return std::nullopt;<br \/>\n}<br \/>\nJson::Value Type;<br \/>\nType[&#034;type&#034;] &#061; thinking_type; <\/p>\n<p>\u00a0 \u00a0 \u00a0 \u53c2\u6570\u8bbe\u8ba1\u903b\u8f91&#xff1a;temperature\u3001max_tokens\u7b49\u63d0\u4f9b\u9ed8\u8ba4\u503c&#xff0c;\u8c03\u7528\u65b9\u6309\u9700\u8986\u76d6&#xff1b;\u800cmodel\u662f\u6bcf\u6b21\u5bf9\u8bdd\u8bf7\u6c42\u5fc5\u987b\u6307\u5b9a&#xff0c;\u4e0d\u63d0\u4f9b\u9ed8\u8ba4\u503c&#xff0c;\u7f3a\u5931\u76f4\u63a5\u62a5\u9519\u8fd4\u56de\u3002<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%201.2.3%C2%A0%E7%BB%84%E8%A3%85%20messages%20%E5%AF%B9%E8%AF%9D%E6%95%B0%E7%BB%84\">\u00a0 \u00a0 1.2.3\u00a0\u7ec4\u88c5 messages \u5bf9\u8bdd\u6570\u7ec4<\/h4>\n<p>\u00a0 \u00a0 \u00a0 \u5faa\u73af\u904d\u5386\u4f20\u5165\u7684\u5386\u53f2\u6d88\u606f\u5217\u8868&#xff0c;\u6309\u7167 DeepSeek \u63a5\u53e3\u6587\u6863\u8981\u6c42&#xff0c;\u7ec4\u88c5role\u548ccontent\u5b57\u6bb5&#xff0c;\u6784\u9020 JSON \u6570\u7ec4&#xff0c;\u643a\u5e26\u4e0a\u4e0b\u6587\u5b9e\u73b0\u591a\u8f6e\u5bf9\u8bdd\u3002<\/p>\n<p>Json::Value messageArray &#061; Json::arrayValue;<br \/>\nfor (auto&amp; message : messages)<br \/>\n{<br \/>\n    Json::Value messageObject;<br \/>\n    messageObject[&#034;role&#034;] &#061; message._role;<br \/>\n    messageObject[&#034;content&#034;] &#061; message._content;<br \/>\n    messageArray.append(messageObject);<br \/>\n}<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%201.2.4%C2%A0%E6%9E%84%E9%80%A0%E8%AF%B7%E6%B1%82%E4%BD%93%EF%BC%8C%E5%BC%80%E5%90%AF%E6%B5%81%E5%BC%8F%E5%BC%80%E5%85%B3\">\u00a0 \u00a0 1.2.4\u00a0\u6784\u9020\u8bf7\u6c42\u4f53&#xff0c;\u5f00\u542f\u6d41\u5f0f\u5f00\u5173<\/h4>\n<p>\u00a0 \u00a0 \u00a0 \u91cd\u70b9&#xff1a;stream:true\u662f\u5f00\u542f\u589e\u91cf\u6d41\u5f0f\u8fd4\u56de\u7684\u6838\u5fc3\u6807\u8bc6&#xff0c;\u4e0d\u914d\u7f6e\u8fd9\u4e2a\u5b57\u6bb5&#xff0c;\u63a5\u53e3\u4f1a\u76f4\u63a5\u8fd4\u56de\u4e00\u6b21\u6027\u5168\u91cf\u5e94\u7b54&#xff0c;\u4e0d\u4f1a\u8d70 SSE \u6d41\u5f0f\u63a8\u9001\u3002<\/p>\n<p>Json::Value requestBody;<br \/>\nrequestBody[&#034;model&#034;] &#061; model;<br \/>\nrequestBody[&#034;messages&#034;] &#061; messageArray;<br \/>\nrequestBody[&#034;temperature&#034;] &#061; temperature;<br \/>\nrequestBody[&#034;max_tokens&#034;] &#061; max_tokens;<br \/>\nrequestBody[&#034;thinking&#034;] &#061; thinking_type;<br \/>\nrequestBody[&#034;reasoning_effort&#034;] &#061; reasoning_effort;<br \/>\nrequestBody[&#034;stream&#034;] &#061; true;<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%201.2.5%C2%A0JSON%20%E5%BA%8F%E5%88%97%E5%8C%96%20%2B%20%E6%9E%84%E9%80%A0%20httplib%20%E5%AE%A2%E6%88%B7%E7%AB%AF%E4%B8%8E%E8%AF%B7%E6%B1%82%E5%A4%B4\">\u00a0 \u00a0 1.2.5\u00a0JSON \u5e8f\u5217\u5316 &#043; \u6784\u9020 httplib \u5ba2\u6237\u7aef\u4e0e\u8bf7\u6c42\u5934<\/h4>\n<p>\u00a0 \u00a0 \u00a0 \u5e8f\u5217\u5316 JSON \u7ed3\u6784\u4f53\u5f97\u5230\u5b57\u7b26\u4e32&#xff0c;\u540c\u65f6\u914d\u7f6e\u6d41\u5f0f\u8bf7\u6c42\u5fc5\u987b\u7684 HTTP \u8bf7\u6c42\u5934&#xff1a;Accept: text\/event-stream\u544a\u8bc9\u670d\u52a1\u7aef\u5ba2\u6237\u7aef\u53ef\u4ee5\u63a5\u6536 SSE \u4e8b\u4ef6\u6d41\u3002<\/p>\n<p>Json::StreamWriterBuilder writerbuilder;<br \/>\nstd::string requestBodyStr &#061; Json::writeString(factory(writerbuilder), requestBody);<\/p>\n<p>httplib::Client client(_baseUrl);<br \/>\nclient.set_connection_timeout(20, 0); \/\/ \u8fde\u63a5\u8d85\u65f6\u65f6\u95f420\u79d2<br \/>\nclient.set_read_timeout(300, 0); \/\/ \u4f5c\u4e3a\u6d41\u5f0f\u54cd\u5e94&#xff0c;\u8bfb\u53d6\u65f6\u95f4\u76f8\u5bf9\u8f83\u957f&#xff0c;\u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4\u4e3a300\u79d2<\/p>\n<p>httplib::Headers headers &#061; {<br \/>\n    {&#034;Accept&#034;, &#034;text\/event-stream&#034;},<br \/>\n    {&#034;Content-Type&#034;, &#034;application\/json&#034;},<br \/>\n    {&#034;Authorization&#034;, &#034;Bearer &#034; &#043; _apikey}<br \/>\n};<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%201.2.6%C2%A0%E5%AE%9A%E4%B9%89%E5%85%A8%E5%B1%80%E7%BC%93%E5%AD%98%E4%B8%8E%E7%8A%B6%E6%80%81%E6%A0%87%E8%AE%B0\">\u00a0 \u00a0 1.2.6\u00a0\u5b9a\u4e49\u5168\u5c40\u7f13\u5b58\u4e0e\u72b6\u6001\u6807\u8bb0<\/h4>\n<p>\u00a0 \u00a0 \u00a0 \u8fd9\u4e00\u7ec4\u53d8\u91cf\u7528\u6765\u89e3\u51b3\u4e0a\u7bc7\u6587\u7ae0\u91cd\u70b9\u8bb2\u89e3\u7684\u534a\u5305\u3001\u7c98\u5305\u95ee\u9898&#xff0c;\u662f SSE \u89e3\u6790\u7684\u72b6\u6001\u5bb9\u5668&#xff1a;<\/p>\n<p>std::string buffer;       \/\/ \u7f13\u5b58\u672a\u5904\u7406\u5b8c\u7684\u5206\u7247\u6570\u636e&#xff0c;\u62fc\u63a5\u534a\u5305<br \/>\nstd::string fullResponse; \/\/ \u7d2f\u52a0\u6240\u6709\u589e\u91cf&#xff0c;\u6700\u7ec8\u4f5c\u4e3a\u51fd\u6570\u8fd4\u56de\u503c<br \/>\nbool streamEnd &#061; false;   \/\/ \u6d41\u7ed3\u675f\u6807\u8bb0<br \/>\nbool isError &#061; false;     \/\/ \u5168\u5c40\u9519\u8bef\u6807\u8bb0<br \/>\nstd::string errorMsg;     \/\/ \u7528\u4e8e\u5b58\u50a8\u9519\u8bef\u63cf\u8ff0\u4fe1\u606f<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%201.2.7%C2%A0%E6%9E%84%E5%BB%BA%20httplib%3A%3ARequest%20%E8%AF%B7%E6%B1%82%E5%AF%B9%E8%B1%A1\">\u00a0 \u00a0 1.2.7\u00a0\u6784\u5efa httplib::Request \u8bf7\u6c42\u5bf9\u8c61<\/h4>\n<p>httplib::Request request;<br \/>\nrequest.method &#061; &#034;POST&#034;;<br \/>\nrequest.path &#061; &#034;\/v1\/chat\/completions&#034;;<br \/>\nrequest.headers &#061; headers;<br \/>\nrequest.body &#061; requestBodyStr;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u8fd9\u4e00\u6b65\u53ea\u662f\u628a\u9759\u6001\u7684\u8bf7\u6c42\u4fe1\u606f\u586b\u5145\u5b8c\u6bd5&#xff0c;\u8fd8\u6ca1\u6709\u53d1\u8d77\u7f51\u7edc\u8bf7\u6c42\u3002\u586b\u5145\u5b8c\u57fa\u7840\u6210\u5458\u4e4b\u540e&#xff0c;\u6211\u4eec\u7d27\u63a5\u7740\u7ed9\u8fd9\u4e2a request \u5bf9\u8c61\u6302\u8f7dresponse_handler\u548ccontent_receiver\u4e24\u4e2a\u6d41\u5f0f\u56de\u8c03&#xff0c;\u8fd9\u4e5f\u662f\u6d41\u5f0f\u8bf7\u6c42\u548c\u666e\u901a\u5168\u91cf\u8bf7\u6c42\u6700\u5927\u7684\u533a\u522b\u3002<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%201.2.8%C2%A0response_handler%EF%BC%9A%E5%93%8D%E5%BA%94%E5%A4%B4%E6%A0%A1%E9%AA%8C%E5%9B%9E%E8%B0%83\">\u00a0 \u00a0 1.2.8\u00a0response_handler&#xff1a;\u54cd\u5e94\u5934\u6821\u9a8c\u56de\u8c03<\/h4>\n<p>\u00a0 \u00a0 \u00a0 \u8fd9\u4e2a\u56de\u8c03\u53ea\u4f1a\u5728\u6536\u5230 HTTP \u54cd\u5e94\u5934\u90e8\u65f6\u6267\u884c\u4e00\u6b21&#xff0c;\u7528\u6765\u6821\u9a8c\u72b6\u6001\u7801&#xff0c;\u6355\u83b7\u8fde\u63a5\u5efa\u7acb\u4e4b\u540e\u7684 HTTP \u5c42\u9762\u9519\u8bef\u3002<\/p>\n<p>request.response_handler &#061; [&amp;](const httplib::Response &amp;res) -&gt; bool<br \/>\n{<br \/>\n    if (res.status !&#061; 200)<br \/>\n    {<br \/>\n        isError &#061; true;<br \/>\n        ERR(&#034;DeepSeekProvider sendMessageStream status not 200, status: {}, body: {}&#034;, res.status, res.body);<br \/>\n        return false;<br \/>\n    }<br \/>\n    return true;<br \/>\n};<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u8fd4\u56defalse\u4ee3\u8868\u7ec8\u6b62\u672c\u6b21\u8bf7\u6c42&#xff0c;\u4e0d\u518d\u63a5\u6536\u540e\u7eed chunk \u6570\u636e&#xff1b;\u8fd4\u56detrue\u4ee3\u8868\u6b63\u5e38\u63a5\u6536\u6d41\u5f0f body \u5206\u7247&#xff0c;\u8fdb\u5165content_receiver\u3002<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%201.2.9%C2%A0content_receiver%EF%BC%9ASSE%20%E5%88%86%E7%89%87%E8%A7%A3%E6%9E%90%E6%A0%B8%E5%BF%83%E5%9B%9E%E8%B0%83\">\u00a0 \u00a0 1.2.9\u00a0content_receiver&#xff1a;SSE \u5206\u7247\u89e3\u6790\u6838\u5fc3\u56de\u8c03<\/h4>\n<p>\u00a0 \u00a0 \u00a0 \u8be5\u56de\u8c03\u4f1a\u5728\u6bcf\u6536\u5230\u4e00\u4e2a\u5b8c\u6574\u00a0HTTP Chunk \u65f6\u8fdb\u884c\u89e6\u53d1&#xff0c;\u6211\u4eec\u5728\u8fd9\u91cc\u5b8c\u6210 SSE \u4e8b\u4ef6\u7684\u7f13\u5b58\u3001\u5207\u5206\u3001\u89e3\u6790&#xff0c;\u4e5f\u662f\u5904\u7406\u534a\u5305\u7c98\u5305\u7684\u6838\u5fc3\u4f4d\u7f6e\u3002<\/p>\n<p>request.content_receiver &#061; [&amp;](const char *data, size_t data_length,<br \/>\n    uint64_t offset, uint64_t total_length) -&gt; bool<br \/>\n{<br \/>\n    if (isError)<br \/>\n    {<br \/>\n        return false;<br \/>\n    }<br \/>\n    \/\/ 1. \u5148\u628a\u65b0\u6536\u5230\u7684\u6570\u636e\u8ffd\u52a0\u5230\u7f13\u51b2\u533a&#xff0c;\u89e3\u51b3\u534a\u5305\u95ee\u9898<br \/>\n    buffer.append(data, data_length);<\/p>\n<p>    \/\/ 2. \u5faa\u73af\u5207\u5272\u5b8c\u6574SSE\u4e8b\u4ef6\u5757&#xff0c;\u5206\u9694\u7b26\u662f \\\\n\\\\n<br \/>\n    size_t pos;<br \/>\n    while ((pos &#061; buffer.find(&#034;\\\\n\\\\n&#034;)) !&#061; std::string::npos)<br \/>\n    {<br \/>\n        std::string event &#061; buffer.substr(0, pos);<br \/>\n        buffer.erase(0, pos &#043; 2);<\/p>\n<p>        \/\/ 3. \u9010\u884c\u89e3\u6790\u5355\u6761SSE\u4e8b\u4ef6&#xff0c;\u8fc7\u6ee4\u6ce8\u91ca\u884c\u3001\u7a7a\u884c<br \/>\n        std::istringstream eventStream(event);<br \/>\n        std::string line;<br \/>\n        std::string modeldata;<br \/>\n        while (std::getline(eventStream, line))<br \/>\n        {<br \/>\n            \/\/ \u8df3\u8fc7\u7a7a\u884c\u3001SSE\u6ce8\u91ca\u5fc3\u8df3\u884c&#xff08;\u4ee5:\u5f00\u5934&#xff09;<br \/>\n            if (line.empty() || line[0] &#061;&#061; &#039;:&#039;)<br \/>\n            {<br \/>\n                continue;<br \/>\n            }<br \/>\n            \/\/ \u63d0\u53d6data: \u540e\u9762\u7684JSON\u5b57\u7b26\u4e32<br \/>\n            if (line.compare(0, 6, &#034;data: &#034;) &#061;&#061; 0)<br \/>\n            {<br \/>\n                modeldata &#061; line.substr(6);<br \/>\n            }<br \/>\n        }<\/p>\n<p>        \/\/ 4. \u5224\u65ad\u6d41\u7ed3\u675f\u6807\u8bb0 [DONE]<br \/>\n        if (modeldata &#061;&#061; &#034;[DONE]&#034;)<br \/>\n        {<br \/>\n            streamEnd &#061; true;<br \/>\n            callback(&#034;&#034;, true);<br \/>\n            return true;<br \/>\n        }<\/p>\n<p>        \/\/ 5. \u53cd\u5e8f\u5217\u5316data\u540e\u7684json&#xff0c;\u63d0\u53d6delta\u589e\u91cf\u5185\u5bb9<br \/>\n        Json::Value modeldataJson;<br \/>\n        Json::CharReaderBuilder readerbuilder;<br \/>\n        std::istringstream modeldataStream(modeldata);<br \/>\n        bool ret &#061; Json::parseFromStream(readerbuilder, modeldataStream, &amp;modeldataJson, &amp;errorMsg);<br \/>\n        if (!ret)<br \/>\n        {<br \/>\n            WARN(&#034;DeepSeekProvider sendMessageStream parseFromStream error, errorMsg: {}&#034;, errorMsg);<br \/>\n            \/\/ \u5355\u6761\u4e8b\u4ef6\u89e3\u6790\u5931\u8d25\u4e0d\u963b\u65ad\u6574\u4e2a\u6d41&#xff0c;\u7ee7\u7eed\u5904\u7406\u4e0b\u4e00\u4e2a\u4e8b\u4ef6<br \/>\n            continue;<br \/>\n        }<\/p>\n<p>        \/\/ 6. \u53d6\u51fachoices[0].delta.content\u589e\u91cf\u6587\u672c<br \/>\n        if (modeldataJson.isMember(&#034;choices&#034;) &amp;&amp; modeldataJson[&#034;choices&#034;].isArray() &amp;&amp; !modeldataJson[&#034;choices&#034;].empty())<br \/>\n        {<br \/>\n            auto&amp; firstChoice &#061; modeldataJson[&#034;choices&#034;][0];<br \/>\n            if (firstChoice.isMember(&#034;delta&#034;) &amp;&amp; firstChoice[&#034;delta&#034;].isMember(&#034;content&#034;))<br \/>\n            {<br \/>\n                std::string datacontent &#061; firstChoice[&#034;delta&#034;][&#034;content&#034;].asString();<br \/>\n                fullResponse &#043;&#061; datacontent;<br \/>\n                \/\/ \u5411\u5916\u63a8\u9001\u589e\u91cf\u5206\u7247&#xff0c;\u7ed3\u675f\u6807\u8bb0false<br \/>\n                callback(datacontent, false);<br \/>\n            }<br \/>\n        }<br \/>\n    }<br \/>\n    return true;<br \/>\n};<\/p>\n<p>\u6838\u5fc3\u8bbe\u8ba1\u8981\u70b9&#xff1a;<\/p>\n<li>\u7f13\u51b2\u533a\u6301\u7eed\u8ffd\u52a0\u6570\u636e&#xff0c;\u4fdd\u8bc1\u8de8 Chunk \u7684 SSE \u4e8b\u4ef6\u53ef\u4ee5\u62fc\u63a5\u5b8c\u6574&#xff1b;<\/li>\n<li>\u7528\\\\n\\\\n\u5207\u5206\u72ec\u7acb SSE \u4e8b\u4ef6&#xff0c;\u5904\u7406\u7c98\u5305&#xff08;\u4e00\u4e2a Chunk \u5305\u542b\u591a\u6761 SSE \u4e8b\u4ef6&#xff09;&#xff1b;<\/li>\n<li>\u8fc7\u6ee4\u5fc3\u8df3\u6ce8\u91ca\u884c&#xff0c;\u8bc6\u522b[DONE]\u7ed3\u675f\u6807\u8bc6&#xff1b;<\/li>\n<li>\u5355\u6761 JSON \u89e3\u6790\u5f02\u5e38\u53ea\u544a\u8b66\u3001\u4e0d\u4e2d\u65ad\u6574\u6761\u6d41&#xff0c;\u63d0\u5347\u9c81\u68d2\u6027\u3002<\/li>\n<p style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104220101-6aebab1da2709.png\" \/><\/p>\n<h4 id=\"%C2%A0%20%C2%A0%201.2.10%C2%A0client.send%20%E5%8F%91%E8%B5%B7%E8%AF%B7%E6%B1%82%20%2B%20%E7%BB%93%E6%9E%9C%E5%88%A4%E6%96%AD\">\u00a0 \u00a0 1.2.10\u00a0client.send \u53d1\u8d77\u8bf7\u6c42 &#043; \u7ed3\u679c\u5224\u65ad<\/h4>\n<p>auto result &#061; client.send(request);<br \/>\n\/\/ send\u8fd4\u56de\u503c\u53ea\u4ee3\u8868\u8bf7\u6c42\u662f\u5426\u6210\u529f\u53d1\u51fa\u53bb&#xff0c;\u53ea\u68c0\u67e5\u8fde\u63a5\u9636\u6bb5\u9519\u8bef<br \/>\nif (!result)<br \/>\n{<br \/>\n    ERR(&#034;DeepSeekProvider sendMessageStream send request ERROR: {}&#034;, httplib::to_string(result.error()));<br \/>\n    return &#034;&#034;;<br \/>\n}<\/p>\n<p>\/\/ \u515c\u5e95&#xff1a;\u670d\u52a1\u7aef\u5f02\u5e38\u65ad\u5f00&#xff0c;\u6ca1\u6709\u8fd4\u56de[DONE]\u7ed3\u675f\u6807\u8bb0<br \/>\nif (!streamEnd)<br \/>\n{<br \/>\n    WARN(&#034;DeepSeekProvider stream end used without [DONE] marker&#034;);<br \/>\n    callback(&#034;\\\\n\\\\n[\u7cfb\u7edf\u63d0\u793a: \u8fde\u63a5\u610f\u5916\u4e2d\u65ad&#xff0c;\u8bf7\u91cd\u8bd5]&#034;, true);<br \/>\n}<br \/>\nreturn fullResponse;<\/p>\n<h5 id=\"%C2%A0%20%C2%A0%20%E8%A1%A5%E5%85%85%20client.send%20%E5%8E%9F%E7%90%86%E5%88%86%E6%9E%90\">\u00a0 \u00a0 \u8865\u5145 client.send \u539f\u7406\u5206\u6790<\/h5>\n<p>\u00a0 \u00a0 \u00a0 cpp-httplib \u7684 send \u5b58\u5728\u4e24\u79cd\u5de5\u4f5c\u6a21\u5f0f&#xff0c;\u533a\u5206\u7684\u6838\u5fc3\u6761\u4ef6\u5c31\u662f\u662f\u5426\u6302\u8f7d\u4e86 content_receiver \u6d41\u5f0f\u63a5\u6536\u56de\u8c03&#xff1a;<\/p>\n<li>\u666e\u901a\u963b\u585e\u6a21\u5f0f&#xff08;\u65e0 content_receiver&#xff09; send \u4f1a\u963b\u585e\u76f4\u5230\u670d\u52a1\u7aef\u628a\u5168\u90e8\u54cd\u5e94\u62a5\u6587\u4f20\u8f93\u5b8c\u6bd5&#xff0c;\u8fd4\u56de\u7684 result \u91cc\u9762\u643a\u5e26\u5b8c\u6574\u54cd\u5e94\u4f53\u3001\u72b6\u6001\u7801&#xff1b;\u8fd4\u56de\u7ed3\u679c\u4ee3\u8868\u6574\u6b21\u8bf7\u6c42\u4ea4\u4e92\u662f\u5426\u5168\u90e8\u5b8c\u6210&#xff0c;\u9002\u5408\u666e\u901a\u975e\u6d41\u5f0f\u63a5\u53e3\u8c03\u7528\u3002<\/li>\n<li>\u6d41\u5f0f\u975e\u963b\u585e\u63a5\u6536\u6a21\u5f0f&#xff08;\u6302\u8f7d content_receiver&#xff0c;\u4e5f\u5c31\u662f\u6211\u4eec\u5f53\u524d SSE \u573a\u666f&#xff09;<\/li>\n<p>\u00a0 \u00a0 \u00a0 \u6ce8\u610f&#xff1a;\u8fd9\u91cc\u8bf4\u7684\u975e\u963b\u585e\u4e0d\u662f\u6307\u5957\u63a5\u5b57\u975e\u963b\u585e IO&#xff0c;\u662f\u6307send\u51fd\u6570\u4e0d\u4f1a\u7b49\u5f85\u5168\u90e8\u6570\u636e\u8fd4\u56de\u624d\u8fd4\u56de\u3002<\/p>\n<ul>\n<li>send \u51fd\u6570\u7684\u8fd4\u56de\u503c result \u4ec5\u8d1f\u8d23\u6821\u9a8c\u8fde\u63a5\u524d\u7f6e\u9636\u6bb5\u7684\u9519\u8bef&#xff1a;DNS \u89e3\u6790\u5931\u8d25\u3001TCP \u8fde\u63a5\u5efa\u7acb\u5931\u8d25\u3001\u8fde\u63a5\u8d85\u65f6\u8fd9\u7c7b\u8fd8\u6ca1\u548c\u670d\u52a1\u7aef\u6b63\u5e38\u63e1\u624b\u7684\u95ee\u9898\u3002<\/li>\n<li>TCP \u8fde\u63a5\u6210\u529f\u3001\u8bf7\u6c42\u62a5\u6587\u6210\u529f\u53d1\u51fa\u53bb\u4e4b\u540e&#xff0c;send \u5c31\u4f1a\u8fd4\u56de&#xff1b;\u540e\u7eed\u5206\u7247\u7684\u6570\u636e\u3001HTTP \u72b6\u6001\u7801\u3001SSE \u7684 data \u6d41&#xff0c;\u5168\u90e8\u4ea4\u7ed9 response_handler \u548c content_receiver \u56de\u8c03\u53bb\u5904\u7406\u3002<\/li>\n<li>HTTP 401\u3001404\u3001429\u3001500 \u8fd9\u7c7b\u72b6\u6001\u7801&#xff0c;\u5c5e\u4e8e\u8fde\u63a5\u5efa\u7acb\u4e4b\u540e\u7684\u4e1a\u52a1\u5c42\u9519\u8bef&#xff0c;\u4e0d\u4f1a\u7531 send \u7684\u8fd4\u56de\u503c\u6355\u83b7&#xff0c;\u9700\u8981\u5728 response_handler \u91cc\u9762\u5224\u65ad res.status\u3002<\/li>\n<\/ul>\n<p>\u4e24\u5c42\u9519\u8bef\u8fb9\u754c\u5c0f\u7ed3&#xff1a;<\/p>\n<ul>\n<li>send \u8fd4\u56de\u503c&#xff1a;\u8fde\u63a5\u5efa\u7acb\u524d \/ \u5efa\u7acb\u9636\u6bb5\u7684\u5e95\u5c42\u7f51\u7edc\u9519\u8bef&#xff08;DNS\u3001TCP \u8fde\u63a5\u5931\u8d25&#xff09;<\/li>\n<li>response_handler&#xff1a;\u8fde\u63a5\u6210\u529f\u4e4b\u540e\u7684 HTTP \u72b6\u6001\u7801\u3001\u9274\u6743\u3001\u9650\u6d41\u7b49\u4e1a\u52a1\u9519\u8bef<\/li>\n<li>streamEnd \u6807\u8bb0\u515c\u5e95&#xff1a;\u8fde\u63a5\u6210\u529f&#xff0c;\u4f46 SSE \u6d41\u4e2d\u9014\u5f02\u5e38\u65ad\u5f00&#xff0c;\u6ca1\u6709\u6536\u5230 DONE \u7ed3\u675f\u5305<\/li>\n<\/ul>\n<h4 id=\"%C2%A0%20%C2%A0%201.2.11%C2%A0%E6%B5%81%E5%BC%8F%E5%93%8D%E5%BA%94%E6%8E%A5%E5%8F%A3%E5%AE%8C%E6%95%B4%E4%BB%A3%E7%A0%81%EF%BC%88%E9%99%84%E6%B3%A8%E9%87%8A%E5%88%86%E6%9E%90%EF%BC%89\">\u00a0 \u00a0 1.2.11\u00a0\u6d41\u5f0f\u54cd\u5e94\u63a5\u53e3\u5b8c\u6574\u4ee3\u7801&#xff08;\u9644\u6ce8\u91ca\u5206\u6790&#xff09;<\/h4>\n<p>\/\/ \u53d1\u9001\u6d88\u606f&#xff1a;\u589e\u91cf\u8c03\u7528&#xff0c;\u5b9e\u65f6\u8fd4\u56de\u54cd\u5e94<br \/>\nstd::optional&lt;std::string&gt; DeepSeekProvider::sendMessageStream(const std::vector&lt;Message&gt; &amp;messages,<br \/>\n                                                               const std::unordered_map&lt;std::string, std::string&gt; &amp;requestParams,<br \/>\n                                                               std::function&lt;void(const std::string &amp;response, bool isEnd)&gt; callback)<br \/>\n{<br \/>\n    \/\/ 1\u3001\u68c0\u67e5\u6a21\u578b\u662f\u5426\u6709\u6548<br \/>\n    if (!IsAvailable())<br \/>\n    {<br \/>\n        ERR(&#034;DeepSeekProvider sendMessageStream model not available&#034;);<br \/>\n        return std::nullopt;<br \/>\n    }<\/p>\n<p>    \/\/ 2\u3001\u6784\u9020\u5e76\u83b7\u53d6\u8bf7\u6c42\u53c2\u6570<br \/>\n    \/\/ 2.1 \u6784\u9020\u9ed8\u8ba4\u8bf7\u6c42\u53c2\u6570&#xff1a;\u5982\u679crequestParams\u4e2d\u6ca1\u6709\u6307\u5b9atemperature\u3001maxTokens\u3001thinking_type\u3001reasoning_effort&#xff0c;\u5219\u4f7f\u7528\u9ed8\u8ba4\u503c<br \/>\n    double temperature &#061; 0.7;<br \/>\n    int max_tokens &#061; 2048;<br \/>\n    std::string thinking_type &#061; &#034;disabled&#034;;<br \/>\n    std::string reasoning_effort &#061; &#034;high&#034;;<br \/>\n    std::string model; \/\/ \u8bf7\u6c42\u53c2\u6570model\u65e0\u6cd5\u9ed8\u8ba4\u503c&#xff0c;\u5fc5\u987b\u7528\u6237\u624b\u52a8\u914d\u7f6e<br \/>\n    \/\/ 2.2 \u4ecerequestParams\u4e2d\u83b7\u53d6temperature\u3001maxTokens\u3001thinking_type\u3001reasoning_effort\u53c2\u6570&#xff1a;\u5982\u679crequestParams\u4e2d\u6307\u5b9a\u4e86&#xff0c;\u5219\u4f7f\u7528\u6307\u5b9a\u503c<br \/>\n    \/\/ \u6ce8\u610f&#xff1a;\u8bf7\u6c42\u53c2\u6570model\u5728\u4e0d\u540c\u7684\u6a21\u578b\u4e2d\u662f\u5fc5\u586b\u9879&#xff0c;\u4f46\u662f\u8fd9\u4e2a\u53c2\u6570\u7531\u4e8e\u6a21\u578b\u7248\u672c\u7684\u66f4\u65b0&#xff0c;\u53ef\u80fd\u4f1a\u6709\u4e0d\u540c\u7684\u5b57\u6bb5\u540d\u79f0&#xff0c;\u6240\u4ee5\u5c31\u4e0d\u80fd\u4f7f\u7528\u9ed8\u8ba4\u503c\u4e86&#xff0c;\u9700\u8981\u7528\u6237\u81ea\u884c\u6307\u5b9a\u6b63\u786e\u7684model<br \/>\n    auto it &#061; requestParams.find(&#034;temperature&#034;);<br \/>\n    if (it !&#061; requestParams.end())<br \/>\n    {<br \/>\n        temperature &#061; std::stod(it-&gt;second);<br \/>\n    }<br \/>\n    it &#061; requestParams.find(&#034;max_tokens&#034;);<br \/>\n    if (it !&#061; requestParams.end())<br \/>\n    {<br \/>\n        max_tokens &#061; std::stoi(it-&gt;second);<br \/>\n    }<br \/>\n    it &#061; requestParams.find(&#034;thinking_type&#034;);<br \/>\n    if (it !&#061; requestParams.end())<br \/>\n    {<br \/>\n        thinking_type &#061; it-&gt;second;<br \/>\n    }<br \/>\n    it &#061; requestParams.find(&#034;reasoning_effort&#034;);<br \/>\n    if (it !&#061; requestParams.end())<br \/>\n    {<br \/>\n        reasoning_effort &#061; it-&gt;second;<br \/>\n    }<br \/>\n    \/\/ \u8bf7\u6c42\u53c2\u6570model\u5fc5\u987b\u7528\u6237\u624b\u52a8\u914d\u7f6e&#xff0c;\u5982\u679c\u6ca1\u6709\u914d\u7f6e\u5219\u76f4\u63a5\u8fd4\u56de\u7a7a\u503cnullopt\u62a5\u9519\u544a\u8bc9\u7528\u6237<br \/>\n    it &#061; requestParams.find(&#034;model&#034;);<br \/>\n    if (it !&#061; requestParams.end())<br \/>\n    {<br \/>\n        model &#061; it-&gt;second;<br \/>\n    }<br \/>\n    else<br \/>\n    {<br \/>\n        ERR(&#034;model name not found in requestParams, must config it&#034;);<br \/>\n        return std::nullopt;<br \/>\n    }<br \/>\n    Json::Value Type;<br \/>\n    Type[&#034;type&#034;] &#061; thinking_type;<\/p>\n<p>    \/\/ 2.3 \u6784\u9020\u5e76\u83b7\u53d6\u5386\u53f2\u6d88\u606f&#xff1a;\u83b7\u53d6\u8bf7\u6c42\u4f53\u4e2d\u7684 messages \u8fd9\u4e2aJson\u6570\u7ec4<br \/>\n    Json::Value messageArray(Json::arrayValue);<br \/>\n    for (auto &amp;message : messages)<br \/>\n    {<br \/>\n        Json::Value messageObject;<br \/>\n        \/\/ \u8fd9\u91cc\u7684\u5b57\u6bb5\u540d\u79f0\u5fc5\u987b\u4e0edeepseek-flash\u6a21\u578b\u7684\u63a5\u53e3\u6587\u6863\u4e2d\u8981\u6c42\u7684\u4e00\u81f4<br \/>\n        messageObject[&#034;role&#034;] &#061; message._role;<br \/>\n        messageObject[&#034;content&#034;] &#061; message._content;<br \/>\n        messageArray.append(messageObject);<br \/>\n    }<\/p>\n<p>    \/\/ 3\u3001\u6784\u9020\u8bf7\u6c42\u4f53<br \/>\n    \/\/  \u548c\u5386\u53f2\u6d88\u606f\u6784\u9020\u4e00\u6837&#xff0c;\u8bf7\u6c42\u4f53\u7684\u5b57\u6bb5\u540d\u79f0\u5fc5\u987b\u4e0edeepseek-flash\u6a21\u578b\u7684\u63a5\u53e3\u6587\u6863\u4e2d\u8981\u6c42\u7684\u4e00\u81f4<br \/>\n    Json::Value requestBody;<br \/>\n    requestBody[&#034;model&#034;] &#061; model;<br \/>\n    requestBody[&#034;messages&#034;] &#061; messageArray;<br \/>\n    requestBody[&#034;temperature&#034;] &#061; temperature;<br \/>\n    requestBody[&#034;max_tokens&#034;] &#061; max_tokens;<br \/>\n    requestBody[&#034;thinking&#034;] &#061; Type;<br \/>\n    requestBody[&#034;reasoning_effort&#034;] &#061; reasoning_effort;<br \/>\n    \/\/ \u5173\u952e&#xff1a;\u6d41\u5f0f\u54cd\u5e94\u9700\u8981\u8bbe\u7f6estream\u4e3atrue&#xff08;\u5426\u5219\u662f\u5168\u91cf\u54cd\u5e94\u4f1a\u8fd4\u56de\u5b8c\u6574\u7684\u54cd\u5e94\u4f53&#xff0c;\u800c\u4e0d\u662f\u589e\u91cf\u54cd\u5e94&#xff09;<br \/>\n    requestBody[&#034;stream&#034;] &#061; true;<\/p>\n<p>    \/\/ 4\u3001\u5bf9requestBody\u8fdb\u884c\u5e8f\u5217\u5316<br \/>\n    Json::StreamWriterBuilder writerbuilder;<br \/>\n    std::string requestBodyStr &#061; Json::writeString(writerbuilder, requestBody);<br \/>\n    INFO(&#034;DeepSeekProvider sendMessage requestBody: {}&#034;, requestBodyStr);<\/p>\n<p>    \/\/ 5\u3001\u4f7f\u7528cpp-httplib\u6784\u5efaHTTP\u5ba2\u6237\u7aef<br \/>\n    \/\/ 5.1\u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4<br \/>\n    httplib::Client client(_baseUrl);<br \/>\n    client.set_connection_timeout(20, 0); \/\/ \u8fde\u63a5\u8d85\u65f6\u65f6\u95f420\u79d2<br \/>\n    client.set_read_timeout(300, 0);      \/\/ \u4f5c\u4e3a\u6d41\u5f0f\u54cd\u5e94&#xff0c;\u8bfb\u53d6\u65f6\u95f4\u76f8\u5bf9\u8f83\u957f&#xff0c;\u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4\u4e3a300\u79d2<br \/>\n    \/\/ 5.2 \u6784\u5efa\u8bf7\u6c42\u5934&#xff08;\u5173\u952e&#xff1a;\u76f8\u8f83\u4e8e\u975e\u6d41\u5f0f\u54cd\u5e94&#xff0c;\u6d41\u5f0f\u54cd\u5e94\u9700\u8981\u8bbe\u7f6eAccept\u4e3atext\/event-stream&#xff09;<br \/>\n    httplib::Headers headers &#061; {<br \/>\n        {&#034;Accept&#034;, &#034;text\/event-stream&#034;},<br \/>\n        {&#034;Content-Type&#034;, &#034;application\/json&#034;},<br \/>\n        {&#034;Authorization&#034;, &#034;Bearer &#034; &#043; _apikey}};<\/p>\n<p>    \/\/ \u5230\u8fd9\u91cc\u6211\u4eec\u80fd\u50cf\u5168\u91cf\u54cd\u5e94\u90a3\u6837&#xff0c;\u76f4\u63a5\u5c06\u5e8f\u5217\u5316\u540e\u7684\u8bf7\u6c42POST\u5230\u6a21\u578b\u7684\u63a5\u53e3\u5417&#xff1f;\u4e0d\u80fd<br \/>\n    \/\/ \u56e0\u4e3a\u6d41\u5f0f\u54cd\u5e94\u662f\u589e\u91cf\u8fd4\u56de&#xff0c;\u6211\u4eec\u4f5c\u4e3a\u7528\u6237\u9700\u8981\u81ea\u5df1\u53bb\u9010\u884c\u89e3\u6790\u6bcf\u4e00\u4e2a\u54cd\u5e94\u4f53&#xff0c;\u90a3\u6211\u4eec\u5982\u4f55\u89e3\u6790&#xff1f;\u5728\u54ea\u89e3\u6790&#xff1f;<br \/>\n    \/\/ \u7b54\u6848&#xff1a;\u6211\u4eec\u9700\u8981\u5148\u521b\u5efa\u4e00\u4e2aRequest\u5bf9\u8c61&#xff0c;\u5e76\u4e14\u8bbe\u7f6e\u4e00\u4e0b\u76f8\u5173\u53c2\u6570&#xff0c;<br \/>\n    \/\/ \u800c\u5176\u4e2d response_handler \u4ee5\u53ca content_receiver \u8fd9\u4e24\u4e2a\u53c2\u6570\u5c31\u662f\u7528\u6765\u5904\u7406\u54cd\u5e94\u7684\u56de\u8c03\u51fd\u6570&#xff0c;\u6211\u4eec\u9700\u8981\u81ea\u5df1\u624b\u52a8\u5b9e\u73b0\u8fd9\u4e24\u4e2a\u51fd\u6570&#xff0c;\u5728\u5176\u4e2d\u89e3\u6790\u54cd\u5e94\u4f53\u3002<br \/>\n    \/\/ \u5728\u6784\u5efa\u8bf7\u6c42\u5bf9\u8c61\u4e4b\u524d&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5148\u8bbe\u7f6e\u4e00\u4e9b\u6d41\u5f0f\u5904\u7406\u53d8\u91cf&#xff0c;\u7528\u4e8e\u5904\u7406\u56de\u8c03\u8fc7\u7a0b\u4e2d\u7684\u76f8\u5173\u903b\u8f91\u3002<\/p>\n<p>    std::string buffer;       \/\/ \u7528\u4e8e\u5b58\u50a8\u6bcf\u6b21\u8bfb\u53d6\u5230\u7684Chunk\u6570\u636e\u5757\u4e2d\u7684\u5185\u5bb9<br \/>\n    std::string fullResponce; \/\/ \u7528\u4e8e\u7d2f\u79ef\u5b58\u50a8\u83b7\u53d6\u5230\u7684\u5b8c\u6574\u7684\u54cd\u5e94\u4f53<br \/>\n    bool streamEnd &#061; false;   \/\/ \u7528\u4e8e\u6807\u8bb0\u6d41\u5f0f\u54cd\u5e94\u662f\u5426\u7ed3\u675f<br \/>\n    bool isError &#061; false;     \/\/ \u7528\u4e8e\u6807\u8bb0\u662f\u5426\u53d1\u751f\u9519\u8bef<br \/>\n    std::string errorMsg;     \/\/ \u7528\u4e8e\u5b58\u50a8\u9519\u8bef\u63cf\u8ff0\u4fe1\u606f<\/p>\n<p>    \/\/ 6\u3001\u6784\u5efa\u8bf7\u6c42\u5bf9\u8c61<br \/>\n    httplib::Request request;<br \/>\n    request.method &#061; &#034;POST&#034;;<br \/>\n    request.path &#061; &#034;\/v1\/chat\/completions&#034;;<br \/>\n    request.headers &#061; headers;<br \/>\n    request.body &#061; requestBodyStr;<\/p>\n<p>    \/\/ 6.1 \u6784\u5efa\u54cd\u5e94\u5904\u7406\u5668\u56de\u8c03\u51fd\u6570&#xff1a;response_handler<br \/>\n    \/\/ \u5173\u952e&#xff1a;response_handler \u51fd\u6570\u4f1a\u5728\u6536\u5230\u54cd\u5e94\u5934\u65f6\u88ab\u8c03\u7528&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5728\u5176\u4e2d\u5224\u65ad\u54cd\u5e94\u662f\u5426\u6b63\u5e38&#xff08;\u8be5\u56de\u8c03\u51fd\u6570\u53ea\u8c03\u7528\u4e00\u6b21&#xff09;&#xff0c;<br \/>\n    \/\/ \u5982\u679c\u54cd\u5e94\u5f02\u5e38&#xff0c;\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u8fd4\u56defalse&#xff0c;\u7ed3\u675f\u8bf7\u6c42\u3002<br \/>\n    \/\/ \u5982\u679c\u54cd\u5e94\u6b63\u5e38&#xff0c;\u6211\u4eec\u53ef\u4ee5\u8fd4\u56detrue&#xff0c;\u7ee7\u7eed\u5904\u7406\u54cd\u5e94\u4f53\u3002<br \/>\n    request.response_handler &#061; [&amp;](const httplib::Response &amp;res) -&gt; bool<br \/>\n    {<br \/>\n        \/\/ \u5982\u679c\u54cd\u5e94\u72b6\u6001\u7801\u4e0d\u662f200&#xff0c;\u8bf4\u660e\u54cd\u5e94\u5f02\u5e38&#xff0c;\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u8fd4\u56defalse&#xff0c;\u7ed3\u675f\u8bf7\u6c42\u3002<br \/>\n        if (res.status !&#061; 200)<br \/>\n        {<br \/>\n            isError &#061; true;<br \/>\n            ERR(&#034;DeepSeekProvider sendMessageStream status not 200, status: {}, body: {}&#034;, res.status, res.body);<br \/>\n            return false;<br \/>\n        }<br \/>\n        return true; \/\/ \u5982\u679c\u54cd\u5e94\u72b6\u6001\u7801\u662f200&#xff0c;\u8bf4\u660e\u54cd\u5e94\u6b63\u5e38&#xff0c;\u6211\u4eec\u53ef\u4ee5\u8fd4\u56detrue&#xff0c;\u7ee7\u7eed\u5904\u7406\u54cd\u5e94\u4f53\u3002<br \/>\n    };<\/p>\n<p>    \/\/ 6.2 \u6784\u5efa\u6570\u636e\u63a5\u6536\u5904\u7406\u5668\u56de\u8c03\u51fd\u6570&#xff1a;content_receiver<br \/>\n    \/\/ \u5173\u952e&#xff1a;content_receiver \u51fd\u6570\u4f1a\u5728\u6536\u5230\u5b8c\u6574Chunk\u6570\u636e\u5757\u65f6\u88ab\u8c03\u7528&#xff0c;\u6211\u4eec\u53ef\u4ee5\u5728\u5176\u4e2d\u89e3\u6790\u54cd\u5e94\u4f53&#xff08;\u8be5\u56de\u8c03\u51fd\u6570\u4f1a\u88ab\u591a\u6b21\u8c03\u7528&#xff09;&#xff0c;<br \/>\n    \/\/ \u5982\u679c\u89e3\u6790\u8fc7\u7a0b\u4e2d\u53d1\u751f\u4e25\u91cd\u9519\u8bef&#xff0c;\u6211\u4eec\u53ef\u4ee5\u76f4\u63a5\u8fd4\u56defalse&#xff0c;\u7ed3\u675f\u8bf7\u6c42\u3002<br \/>\n    \/\/ \u5982\u679c\u89e3\u6790\u8fc7\u7a0b\u6b63\u5e38&#xff0c;\u6211\u4eec\u53ef\u4ee5\u8fd4\u56detrue&#xff0c;\u7ee7\u7eed\u5904\u7406\u4e0b\u4e00\u4e2a\u6570\u636e\u5757\u3002<br \/>\n    request.content_receiver &#061; [&amp;](const char *data, size_t data_length,<br \/>\n                                   uint64_t offset, uint64_t total_length) -&gt; bool<br \/>\n    {<br \/>\n        \/\/ 1\u3001\u9a8c\u8bc1\u524d\u9762\u7684\u54cd\u5e94\u5934\u662f\u5426\u51fa\u9519&#xff0c;\u51fa\u9519\u4e86&#xff0c;\u76f4\u63a5\u8fd4\u56defalse\u7ed3\u675f\u8bf7\u6c42&#xff0c;\u4e0d\u9700\u8981\u518d\u63a5\u6536\u6570\u636e<br \/>\n        if (isError)<br \/>\n        {<br \/>\n            return false;<br \/>\n        }<\/p>\n<p>        \/\/ 2\u3001\u8ffd\u52a0\u5f53\u524d\u6240\u6709\u7684\u4e8b\u4ef6\u5757\u5230\u7f13\u51b2\u533a&#xff0c;\u4fdd\u8bc1\u6bcf\u6b21\u5904\u7406\u7684\u4e8b\u4ef6\u5757\u90fd\u662f\u5b8c\u6574\u7684<br \/>\n        buffer.append(data, data_length);<br \/>\n        INFO(&#034;DeepSeekProvider sendMessageStream data: {}&#034;, buffer);<\/p>\n<p>        \/\/ 3\u3001\u89e3\u6790\u7f13\u51b2\u533a\u4e2d\u7684\u4e8b\u4ef6\u5757&#xff0c;\u5224\u65ad\u662f\u5426\u4e3a\u5b8c\u6574\u7684 SSE \u4e8b\u4ef6\u5757<br \/>\n        size_t pos;<br \/>\n        while ((pos &#061; buffer.find(&#034;\\\\n\\\\n&#034;)) !&#061; std::string::npos)<br \/>\n        {<br \/>\n            \/\/ 3.1 \u622a\u53d6\u5f53\u524d\u627e\u5230\u7684\u4e8b\u4ef6\u5757<br \/>\n            std::string event &#061; buffer.substr(0, pos);<br \/>\n            buffer.erase(0, pos &#043; 2); \/\/ \u79fb\u9664\u5df2\u5904\u7406\u7684\u4e8b\u4ef6\u5757&#xff0c;\u907f\u514d\u540e\u7eed\u89e3\u6790\u65f6\u91cd\u590d\u5904\u7406<\/p>\n<p>            \/\/ 3.2 \u5173\u952e\u5904\u7406&#xff1a;\u89e3\u6790\u5f53\u524d\u4e8b\u4ef6\u5757\u4e2d\u7684\u6bcf\u4e00\u884c<br \/>\n            \/\/ \u6ce8\u610f&#xff1a;\u4e0d\u80fd\u76f4\u63a5\u5bf9event\u8fdb\u884c\u89e3\u6790&#xff0c;\u5e76\u4e14\u5229\u7528event\u5224\u65ad\u662f\u5426\u4e3a\u7a7a\u884c\u6216\u8005\u4ee5&#034;:&#034;\u5f00\u5934\u7684\u6ce8\u91ca\u884c&#xff0c;<br \/>\n            \/\/ \u56e0\u4e3a\u5f53\u524d\u7684\u4e8b\u4ef6\u5757\u4e2d\u53ef\u80fd\u4e0d\u4ec5\u4ec5\u53ea\u6709\u7a7a\u884c\u6216\u8005\u4ee5&#034;:&#034;\u5f00\u5934\u7684\u6ce8\u91ca\u884c&#xff0c;\u53ef\u80fd\u8fde\u5e26\u7740\u540e\u7eed\u90e8\u5206\u7684&#034;data: &#034;\u884c\u4e00\u8d77\u53d1\u9001\u8fc7\u6765\u4e86<br \/>\n            \/\/ \u5982\u679c\u76f4\u63a5\u5bf9event\u8fdb\u884c\u89e3\u6790&#xff0c;\u5e76\u4e14\u5224\u65ad\u7b2c\u4e00\u4e2a\u5b57\u7b26&#039;:&#039;&#xff0c;\u5c31\u4f1a\u8bef\u5224\u4e3a\u53ea\u6709\u6ce8\u91ca\u884c\u800c\u8fdb\u884ccontinue&#xff0c;<br \/>\n            \/\/ \u5c31\u4f1a\u5bfc\u81f4\u540e\u7eed\u7684&#034;data: &#034;\u884c\u8fde\u540c\u6ce8\u91ca\u884c\u4e00\u8d77\u88ab\u5220\u9664\u4e86&#xff0c;\u4ece\u800c\u5bfc\u81f4data\u6570\u636e\u90e8\u5206\u4e22\u5931<br \/>\n            \/\/ \u6240\u4ee5\u6211\u4eec\u9700\u8981\u501f\u52a9\u8f93\u5165\u6d41\u901a\u8fc7std::getline()\u51fd\u6570\u9010\u884c\u89e3\u6790\u5f53\u524d\u4e8b\u4ef6\u5757&#xff0c;\u8fd9\u6837\u5c31\u80fd\u786e\u4fdd\u6bcf\u4e2a\u4e8b\u4ef6\u884c\u90fd\u662f\u72ec\u7acb\u7684&#xff0c;\u4e0d\u4f1a\u88ab\u9519\u8bef\u89e3\u6790<br \/>\n            std::istringstream eventStream(event);<br \/>\n            std::string line;<br \/>\n            std::string modeldata;<br \/>\n            while (std::getline(eventStream, line))<br \/>\n            {<br \/>\n                \/\/ \u8fc7\u6ee4\u7a7a\u884c\u548c\u6ce8\u91ca\u884c<br \/>\n                if (line.empty() || line[0] &#061;&#061; &#039;:&#039;)<br \/>\n                {<br \/>\n                    continue;<br \/>\n                }<br \/>\n                \/\/ \u5224\u65ad\u662f\u5426\u4e3adata\u884c&#xff0c;\u63d0\u53d6data\u6570\u636e\u90e8\u5206<br \/>\n                if (line.compare(0, 6, &#034;data: &#034;) &#061;&#061; 0)<br \/>\n                {<br \/>\n                    \/\/ \u76f4\u63a5\u4ece\u7b2c6\u4e2a\u5b57\u7b26\u622a\u53d6\u5230\u6700\u540e\u5373\u53ef&#xff0c;line\u4e3a\u4e00\u884c\u7684\u6570\u636e&#xff0c;\u4e0d\u4f1a\u5c06data\u6362\u884c\u7b26\u4e4b\u540e\u7684\u65e0\u6548\u6570\u636e\u5305\u542b\u8fdb\u6765<br \/>\n                    modeldata &#061; line.substr(6);<br \/>\n                    BUG(&#034;DeepSeekProvider sendMessageStream eventType: {}&#034;, modeldata);<br \/>\n                }<br \/>\n            }<\/p>\n<p>            \/\/ \u68c0\u6d4b\u662f\u5426\u4e3a\u7ed3\u675f\u6807\u8bb0<br \/>\n            if (modeldata &#061;&#061; &#034;[DONE]&#034;)<br \/>\n            {<br \/>\n                streamEnd &#061; true;<br \/>\n                callback(&#034;&#034;, true);<br \/>\n                return true;<br \/>\n            }<br \/>\n            \/\/ 3.3 \u89e3\u6790\u5f53\u524d\u4e8b\u4ef6\u5757\u4e2d\u7684Json\u5b57\u7b26\u4e32 &#8212; \u53cd\u5e8f\u5217\u5316<br \/>\n            Json::Value modeldataJson;<br \/>\n            Json::CharReaderBuilder readerbuilder;<br \/>\n            std::istringstream modeldataStream(modeldata);<br \/>\n            bool ret &#061; Json::parseFromStream(readerbuilder, modeldataStream, &amp;modeldataJson, &amp;errorMsg);<br \/>\n            if (!ret)<br \/>\n            {<br \/>\n                WARN(&#034;DeepSeekProvider sendMessageStream parseFromStream error, errorMsg: {}&#034;, errorMsg);<br \/>\n                \/\/ \u89e3\u6790\u5931\u8d25&#xff0c;\u53ea\u80fd\u8bf4\u5f53\u524d\u4e8b\u4ef6\u5757\u4e2d\u5305\u542b\u4e86\u65e0\u6548\u7684Json\u6570\u636e&#xff0c;\u76f4\u63a5\u8df3\u51fa\u5f53\u524d\u4e8b\u4ef6\u5757\u7684\u6570\u636e\u89e3\u6790&#xff0c;\u7ee7\u7eed\u5904\u7406\u4e0b\u4e00\u4e2a\u4e8b\u4ef6\u5757<br \/>\n                \/\/ \u4e0d\u80fd\u76f4\u63a5\u8fd4\u56defalse&#xff0c;\u5426\u5219\u5c31\u4f1a\u5bfc\u81f4\u540e\u7eed\u7684\u4e8b\u4ef6\u5757\u90fd\u65e0\u6cd5\u89e3\u6790&#xff0c;\u4ece\u800c\u5bfc\u81f4\u8bf7\u6c42\u5931\u8d25<br \/>\n                continue;<br \/>\n            }<\/p>\n<p>            \/\/ \u4ecemodeldataJson\u4e2d\u63d0\u53d6\u54cd\u5e94\u5185\u5bb9\u4e2dcontent\u5b57\u6bb5<br \/>\n            \/\/ \u6a21\u578b\u8fd4\u56de\u7684\u54cd\u5e94\u4e2d\u7684choices\u5b57\u6bb5\u662f\u4e00\u4e2aJson\u6570\u7ec4&#xff0c;\u6570\u7ec4\u4e2d\u6bcf\u4e00\u4e2a\u5143\u7d20\u5305\u542bdelta\u5b57\u6bb5&#xff0c;delta\u5b57\u6bb5\u4e2d\u5305\u542bcontent\u5b57\u6bb5&#xff0c;content\u5b57\u6bb5\u5c31\u662f\u6a21\u578b\u751f\u6210\u7684\u56de\u590d<br \/>\n            \/\/ \u5148\u68c0\u67e5 choices \u662f\u5426\u5b58\u5728\u4e14\u662f\u6570\u7ec4\u4e14\u4e0d\u4e3a\u7a7a &#8212; \u4fdd\u8bc1\u6211\u4eec\u80fd\u83b7\u53d6\u5230\u6709\u6570\u636e\u7684choices\u5b57\u6bb5<br \/>\n            if (modeldataJson.isMember(&#034;choices&#034;) &amp;&amp; modeldataJson[&#034;choices&#034;].isArray() &amp;&amp; !modeldataJson[&#034;choices&#034;].empty())<br \/>\n            {<br \/>\n                Json::Value firstChoice &#061; modeldataJson[&#034;choices&#034;][0];<br \/>\n                \/\/ \u518d\u68c0\u67e5choices\u6570\u7ec4\u4e2d\u662f\u5426\u5b58\u5728delta\u5b57\u6bb5\u4e14delta\u5b57\u6bb5\u4e2d\u662f\u5426\u5b58\u5728content<br \/>\n                if (firstChoice.isMember(&#034;delta&#034;) &amp;&amp; firstChoice[&#034;delta&#034;].isMember(&#034;content&#034;))<br \/>\n                {<br \/>\n                    std::string datacontent &#061; firstChoice[&#034;delta&#034;][&#034;content&#034;].asString();<br \/>\n                    \/\/ \u5c06\u83b7\u53d6\u5230\u7684\u6a21\u578b\u56de\u590d\u7684datacontent\u8ffd\u52a0\u5230fullResponce<br \/>\n                    fullResponce &#043;&#061; datacontent;<\/p>\n<p>                    \/\/ \u6700\u540e\u5c06\u672c\u6b21\u5f53\u524d\u89e3\u6790\u5f97\u5230\u7684\u4e8b\u4ef6\u5757\u4e2d\u7684content\u5185\u5bb9\u4f20\u7ed9\u8c03\u7528sendMessageStream\u7684\u7528\u6237\u67e5\u770b &#8212; \u56de\u8c03\u5904\u7406<br \/>\n                    callback(datacontent, streamEnd);<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n        \/\/ \u5230\u8fd9&#xff0c;\u8bf4\u660e\u5f53\u524d\u6570\u636e\u5757chunk\u4e2d\u7684\u6240\u6709\u4e8b\u4ef6\u5757\u5df2\u7ecf\u5904\u7406\u5b8c&#xff0c;\u7ee7\u7eed\u7b49\u5f85\u540e\u7eed\u6570\u636e\u5757\u7684\u5230\u6765<br \/>\n        return true;<br \/>\n    };<br \/>\n    \/\/ \u5199\u5230\u8fd9\u4e00\u5b9a\u8981\u6ce8\u610f&#xff1a;\u4e0a\u9762\u6211\u4eec\u6240\u5199\u7684\u5904\u7406\u8fc7\u7a0b\u53ea\u662f\u9488\u5bf9Resquest\u5bf9\u8c61\u8bbe\u7f6e\u53c2\u6570&#xff0c;\u6211\u4eec\u8fd8\u6ca1\u6709\u53d1\u9001\u8bf7\u6c42&#xff0c;<br \/>\n    \/\/ \u4ee5\u6211\u4eec\u9700\u8981\u8c03\u7528client.send(request)\u53d1\u9001\u8bf7\u6c42&#xff0c;\u624d\u80fd\u83b7\u53d6\u5230\u670d\u52a1\u5668\u7684\u54cd\u5e94<\/p>\n<p>    \/\/ 7\u3001\u53d1\u9001\u8bf7\u6c42&#xff0c;\u83b7\u53d6\u670d\u52a1\u5668\u54cd\u5e94<br \/>\n    auto result &#061; client.send(request);<br \/>\n    \/\/ \u5173\u952e\u70b9&#xff1a;Post\u7684\u8fd4\u56de\u503c\u548csend\u7684\u8fd4\u56de\u503c\u867d\u7136\u90fd\u662fhttplib::Result\u7c7b\u578b&#xff0c;\u4f46\u662f\u542b\u4e49\u5b8c\u5168\u4e0d\u4e00\u6837<br \/>\n    \/\/ send\u7684\u8fd4\u56de\u503c\u9488\u5bf9\u7684\u662f\u8bf7\u6c42\u53d1\u9001\u9636\u6bb5&#xff0c;\u800cPost\u7684\u8fd4\u56de\u503c\u9488\u5bf9\u7684\u662f\u54cd\u5e94\u63a5\u6536\u9636\u6bb5<\/p>\n<p>    \/\/ \u6240\u4ee5&#xff0c;\u6211\u4eec\u5e76\u4e0d\u662f\u62ff\u7740send\u7684\u8fd4\u56de\u503c\u83b7\u53d6\u670d\u52a1\u5668\u54cd\u5e94&#xff0c;\u6211\u4eec\u4e5f\u4e0d\u9700\u8981\u5728\u8fd9\u91cc\u83b7\u53d6&#xff0c;\u4e3a\u4ec0\u4e48&#xff1f;<br \/>\n    \/\/ \u56e0\u4e3a\u670d\u52a1\u5668\u5728\u4e00\u6b21\u6b21\u53d1\u9001\u6570\u636e\u5757\u7684\u65f6\u5019&#xff0c;\u4f1a\u8c03\u7528\u4e0a\u9762\u6211\u4eec\u6240\u5199\u7684content_receiver\u56de\u8c03\u51fd\u6570&#xff0c;<br \/>\n    \/\/ \u800c\u5728\u56de\u8c03\u51fd\u6570\u4e2d&#xff0c;\u6211\u4eec\u5df2\u7ecf\u5c06\u6bcf\u6b21\u63a5\u6536\u5230\u7684\u6570\u636e\u5757\u4e2d\u7684content\u5185\u5bb9\u62fc\u63a5\u8d77\u6765&#xff0c;\u5b8c\u6210\u4e86\u54cd\u5e94\u5185\u5bb9\u7684\u83b7\u53d6<br \/>\n    \/\/ \u6240\u4ee5&#xff0c;send\u7684\u8fd4\u56de\u503c\u53ea\u662f\u7528\u6765\u5224\u65ad\u6211\u4eec\u7684\u8bf7\u6c42\u53d1\u9001\u662f\u5426\u662f\u6210\u529f\u7684&#xff0c;\u4e5f\u5c31\u662f\u8bf4\u5982\u679c\u662f\u6210\u529f&#xff0c;\u6211\u4eec\u81ea\u7136\u4e5f\u5c31\u83b7\u53d6\u5230\u4e86\u54cd\u5e94\u5185\u5bb9<\/p>\n<p>    \/\/ 7.1 \u5224\u65ad\u8bf7\u6c42\u53d1\u9001\u662f\u5426\u6210\u529f<br \/>\n    if (!result)<br \/>\n    {<br \/>\n        \/\/ \u53d1\u9001\u8bf7\u6c42\u5931\u8d25&#xff0c;\u53ef\u80fd\u51fa\u73b0\u7f51\u7edc\u95ee\u9898&#xff0c;\u6bd4\u5982DNS\u89e3\u6790\u5931\u8d25&#xff0c;\u8fde\u63a5\u8d85\u65f6\u7b49\u7b49<br \/>\n        ERR(&#034;DeepSeekProvider sendMessageStream send request error: {}&#034;, httplib::to_string(result.error()));<br \/>\n        \/\/ ERR(&#034;DeepSeekProvider sendMessageStream send request error: {}&#034;, static_cast&lt;int&gt;(result.error()));<br \/>\n        \/\/ \u8fd9\u4e2a\u5199\u6cd5\u4e5f\u53ef\u4ee5&#xff0c;\u4e0a\u9762\u662f\u76f4\u63a5\u4f7f\u7528httplib\u4e2d\u5b9e\u73b0\u7684to_string\u51fd\u6570\u76f4\u63a5\u5c06Error\u679a\u4e3e\u503c\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32<br \/>\n        \/\/ \u8fd9\u4e2a\u5199\u6cd5\u662f\u901a\u8fc7\u663e\u5f0f\u8f6c\u6362\u6210int\u7c7b\u578b<br \/>\n        \/\/ ERR(&#034;DeepSeekProvider sendMessageStream send request error: {}&#034;, result.error()); \/\/error<br \/>\n        \/\/ error()\u8fd4\u56de\u7c7b\u578b\u662fError&#xff0c;\u662f\u4e00\u4e2aenum class&#xff0c;enum class \u4e0d\u540c\u4e8e\u666e\u901a\u7684enum&#xff0c;enum\u53ef\u4ee5\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362&#xff0c;\u800cenum class\u4e0d\u80fd<br \/>\n        return std::nullopt;<br \/>\n    }<\/p>\n<p>    \/\/ \u7279\u6b8a\u60c5\u51b5&#xff1a;streamEnd\u4e3afalse&#xff0c;\u4e5f\u5c31\u662f\u8bf4\u6211\u4eec\u83b7\u53d6\u5b8c\u54cd\u5e94\u5185\u5bb9&#xff0c;\u4f46\u662f\u6ca1\u6709\u6536\u5230[DONE]\u7ed3\u675f\u6807\u8bb0<br \/>\n    \/\/ \u8fd9\u79cd\u60c5\u51b5\u53ef\u80fd\u662f\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u4e86\u4e00\u4e9b\u95ee\u9898&#xff0c;\u4f46\u662f\u6211\u4eec\u5df2\u7ecf\u83b7\u53d6\u5230\u4e86\u54cd\u5e94\u5185\u5bb9&#xff0c;\u6240\u4ee5\u6211\u4eec\u53ea\u80fd\u8b66\u544a\u4e00\u4e0b\u7528\u6237&#xff0c;\u544a\u8bc9\u7528\u6237\u53ef\u80fd\u4f1a\u5b58\u5728\u4e00\u4e9b\u95ee\u9898<br \/>\n    \/\/ \u6ce8\u610f&#xff1a;\u5f53\u6211\u4eec\u7ed9\u7528\u6237\u4e00\u4e2a\u8b66\u544a\u540e&#xff0c;\u5fc5\u987b\u518d\u6b21\u8fdb\u884c\u56de\u8c03\u5904\u7406&#xff0c;\u624b\u52a8\u5c06\u7b2c\u4e8c\u4e2a\u53c2\u6570\u8bbe\u7f6e\u6210true&#xff0c;\u5426\u5219\u4e0a\u9762\u7528\u6237\u5c42\u7684\u5faa\u73af\u4f1a\u7ee7\u7eed\u8fd0\u884c&#xff0c;\u5bfc\u81f4\u65e0\u9650\u7b49\u5f85<br \/>\n    if (!streamEnd)<br \/>\n    {<br \/>\n        WARN(&#034;DeepSeekProvider stream ended without [DONE] marker&#034;);<br \/>\n        \/\/ \u624b\u52a8\u5c06\u7b2c\u4e8c\u4e2a\u53c2\u6570\u8bbe\u7f6e\u6210true&#xff0c;\u544a\u8bc9\u7528\u6237\u6211\u4eec\u5df2\u7ecf\u83b7\u53d6\u5230\u4e86\u54cd\u5e94\u5185\u5bb9&#xff0c;\u4f46\u662f\u6ca1\u6709\u6536\u5230[DONE]\u7ed3\u675f\u6807\u8bb0<br \/>\n        callback(&#034;\\\\n\\\\n[\u7cfb\u7edf\u63d0\u793a: \u8fde\u63a5\u610f\u5916\u4e2d\u65ad&#xff0c;\u8bf7\u91cd\u8bd5]&#034;, true);<br \/>\n    }<\/p>\n<p>    return fullResponce;<br \/>\n} <\/p>\n<h3 id=\"%C2%A0%201.3%20%E8%A1%A5%E5%85%85%EF%BC%9A%E7%BC%96%E8%AF%91%E9%97%AE%E9%A2%98%E5%AE%9A%E4%BD%8D%E4%B8%8E%E4%BF%AE%E5%A4%8D\">\u00a0 1.3 \u8865\u5145&#xff1a;\u7f16\u8bd1\u95ee\u9898\u5b9a\u4f4d\u4e0e\u4fee\u590d<\/h3>\n<h4 id=\"%C2%A0%20%C2%A0%201.3.1%C2%A0%E9%94%99%E8%AF%AF%E7%8E%B0%E8%B1%A1\">\u00a0 \u00a0 1.3.1\u00a0\u9519\u8bef\u73b0\u8c61<\/h4>\n<p style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104220103-6aebab1f1ceba.png\" \/><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u7f16\u8bd1\u62a5\u9519&#xff1a;spdlog \u65e5\u5fd7\u683c\u5f0f\u5316\u5b8f\u65e0\u6cd5\u76f4\u63a5\u683c\u5f0f\u5316 httplib::Error \u7c7b\u578b\u53c2\u6570&#xff0c;\u63d0\u793a\u7c7b\u578b\u4e0d\u5339\u914d\u3001\u683c\u5f0f\u5316\u5931\u8d25\u3002 \u00a0 \u00a0 \u00a0 \u89e6\u53d1\u4ee3\u7801&#xff08;\u539f\u59cb\u62a5\u9519\u5199\u6cd5&#xff09;&#xff1a;<\/p>\n<p>ERR(&#034;DeepSeekProvider sendMessageStream send request ERROR: {}&#034;, result.error());<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%201.3.2%C2%A0%E6%A0%B9%E5%9B%A0%E5%88%86%E6%9E%90\">\u00a0 \u00a0 1.3.2\u00a0\u6839\u56e0\u5206\u6790<\/h4>\n<p>\u00a0 \u00a0 \u00a0 result.error() \u8fd4\u56de\u7684 httplib::Error \u662f C&#043;&#043;11 \u5f3a\u7c7b\u578b\u679a\u4e3e enum class&#xff0c;\u8fd9\u662f\u62a5\u9519\u7684\u6838\u5fc3\u6839\u6e90&#xff1a;<\/p>\n<li>\u666e\u901aenum\u662f\u65e0\u4f5c\u7528\u57df\u679a\u4e3e&#xff0c;\u4f1a\u9690\u5f0f\u8f6c\u4e3a\u6574\u578b&#xff1b;\u4f46enum class&#xff08;\u5f3a\u7c7b\u578b\u679a\u4e3e&#xff09;\u9ed8\u8ba4\u7981\u6b62\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362&#xff0c;\u7f16\u8bd1\u5668\u4e0d\u5141\u8bb8\u5b83\u81ea\u52a8\u8f6c\u4e3a int\u3001\u5b57\u7b26\u4e32\u7b49\u7c7b\u578b\u3002<\/li>\n<li>spdlog \u7684\u683c\u5f0f\u5316\u5e93\u6ca1\u6709\u5bf9httplib::Error\u8fd9\u4e2a\u5f3a\u679a\u4e3e\u505a\u81ea\u52a8\u7279\u5316\u9002\u914d&#xff0c;\u65e0\u6cd5\u8bc6\u522b\u8be5\u679a\u4e3e\u7c7b\u578b&#xff0c;\u76f4\u63a5\u4f20\u5165\u4f1a\u89e6\u53d1\u7f16\u8bd1\u5931\u8d25\u3002<\/li>\n<li>\u867d\u7136 cpp-httplib \u5e93\u5185\u90e8\u5df2\u7ecf\u63d0\u4f9b\u4e86\u914d\u5957\u7684 httplib::to_string(Error err) \u8f6c\u6362\u51fd\u6570&#xff0c;\u4e5f\u91cd\u8f7d\u4e86operator&lt;&lt;&#xff0c;\u4f46 spdlog \u683c\u5f0f\u5316\u903b\u8f91\u4e0d\u4f1a\u81ea\u52a8\u8c03\u7528\u8fd9\u4e24\u4e2a\u63a5\u53e3&#xff0c;\u5fc5\u987b\u7531\u5f00\u53d1\u8005\u663e\u5f0f\u8c03\u7528\u3002<\/li>\n<p>\u00a0 \u00a0 \u00a0 \u62d3\u5c55\u7406\u89e3&#xff1a;static_cast&lt;int&gt;(err) \u4e5f\u53ef\u4ee5\u663e\u5f0f\u628a enum class\u00a0\u7c7b\u578b\u8f6c\u4e3a\u5e95\u5c42\u6574\u6570\u3002 \u00a0 \u00a0 \u00a0 static_cast \u7684\u542b\u4e49\u4e0d\u662f \u201c\u4fdd\u8bc1\u8f6c\u6362\u4e00\u5b9a\u6b63\u786e\u201d&#xff0c;\u800c\u662f\u6807\u8bb0\u8fd9\u91cc\u662f\u7a0b\u5e8f\u5458\u4e3b\u52a8\u627f\u62c5\u7c7b\u578b\u8f6c\u6362\u98ce\u9669\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u7f16\u8bd1\u5668\u653e\u5f00\u8f6c\u6362\u6743\u9650\u7684\u5e95\u5c42\u903b\u8f91&#xff1a;enum class \u5728\u5185\u5b58\u5e95\u5c42\u672c\u8d28\u5c31\u662f\u6574\u578b\u5b58\u50a8&#xff1b;\u6807\u51c6\u53ea\u662f\u7981\u6b62\u9690\u5f0f\u8f6c\u6362&#xff0c;\u5e76\u6ca1\u6709\u7981\u6b62\u6211\u4eec\u4e3b\u52a8\u663e\u5f0f\u8f6c\u6362\u3002 \u00a0 \u00a0 \u00a0 \u4e24\u79cd\u4fee\u590d\u65b9\u6848\u5bf9\u6bd4&#xff1a;<\/p>\n<ul>\n<li>httplib::to_string(result.error())&#xff1a;\u4f18\u5148\u63a8\u8350&#xff0c;\u76f4\u63a5\u62ff\u5230\u53ef\u8bfb\u6027\u5f3a\u7684\u9519\u8bef\u6587\u672c&#xff08;\u6bd4\u5982ConnectionFailed&#xff09;&#xff0c;\u65e5\u5fd7\u4fbf\u4e8e\u6392\u67e5\u95ee\u9898\u3002<\/li>\n<li>static_cast&lt;int&gt;(result.error())&#xff1a;\u4ec5\u62ff\u5230\u539f\u59cb\u679a\u4e3e\u6570\u5b57\u7801&#xff0c;\u53ef\u8bfb\u6027\u5dee&#xff0c;\u53ea\u9002\u5408\u53ea\u9700\u8981\u9519\u8bef\u7f16\u53f7\u7684\u573a\u666f\u3002<\/li>\n<\/ul>\n<h4 id=\"%C2%A0%20%C2%A0%201.3.3%C2%A0%E4%BF%AE%E5%A4%8D%E6%96%B9%E6%A1%88\">\u00a0 \u00a0 1.3.3\u00a0\u4fee\u590d\u65b9\u6848<\/h4>\n<p>\/\/ \u4fee\u590d\u524d&#xff1a;\u7f16\u8bd1\u5931\u8d25<br \/>\nERR(&#034;DeepSeekProvider sendMessageStream send request ERROR: {}&#034;, result.error());<\/p>\n<p>\/\/ \u65b9\u68481\u3010\u63a8\u8350\u3011&#xff1a;\u8c03\u7528httplib\u81ea\u5e26to_string&#xff0c;\u8f6c\u4e3a\u53ef\u8bfb\u5b57\u7b26\u4e32<br \/>\nERR(&#034;DeepSeekProvider sendMessageStream send request ERROR: {}&#034;, httplib::to_string(result.error()));<\/p>\n<p>\/\/ \u65b9\u68482&#xff1a;static_cast\u663e\u5f0f\u8f6c\u4e3aint&#xff08;\u4ec5\u8f93\u51fa\u9519\u8bef\u7801&#xff09;<br \/>\n\/\/ ERR(&#034;DeepSeekProvider sendMessageStream send request ERROR: {}&#034;, static_cast&lt;int&gt;(result.error()));<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%201.3.4%C2%A0%E5%B0%8F%E7%BB%93\">\u00a0 \u00a0 1.3.4\u00a0\u5c0f\u7ed3<\/h4>\n<ul>\n<li>\u62a5\u9519\u672c\u8d28&#xff1a;\u5f3a\u7c7b\u578b\u679a\u4e3e enum class \u7981\u6b62\u9690\u5f0f\u8f6c\u6362 &#043; spdlog \u6ca1\u6709\u5185\u7f6e\u8be5\u7c7b\u578b\u683c\u5f0f\u5316\u652f\u6301<\/li>\n<li>\u4e0d\u8981\u76f4\u63a5\u88f8\u4f20 enum class \u7ed9 spdlog \u683c\u5f0f\u5316\u5b8f&#xff0c;\u5fc5\u987b\u624b\u52a8\u505a\u7c7b\u578b\u8f6c\u6362<\/li>\n<li>\u5de5\u7a0b\u4e0a\u4f18\u5148\u4f7f\u7528\u5e93\u81ea\u5e26\u7684to_string&#xff0c;\u65e5\u5fd7\u53ef\u8bfb\u6027\u66f4\u5f3a&#xff0c;\u65b9\u4fbf\u5b9a\u4f4d\u7f51\u7edc\u7c7b\u9519\u8bef&#xff1b;static_cast&lt;int&gt;\u4ec5\u4f5c\u4e3a\u5907\u9009\u65b9\u6848<\/li>\n<\/ul>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104220103-6aebab1fbd9fa.png\" \/> <img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104220106-6aebab2216459.png\" \/><\/p>\n<h2 id=\"%E4%BA%8C%E3%80%81%E6%B5%81%E5%BC%8F%E5%93%8D%E5%BA%94%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95\">\u4e8c\u3001\u6d41\u5f0f\u54cd\u5e94\u5355\u5143\u6d4b\u8bd5<\/h2>\n<h3 id=\"%C2%A0%202.1%C2%A0%E5%88%9D%E5%A7%8B%E5%8C%96%E4%B8%8E%E9%85%8D%E7%BD%AE\">\u00a0 2.1\u00a0\u521d\u59cb\u5316\u4e0e\u914d\u7f6e<\/h3>\n<p>#include &#034;..\/SDK\/include\/DeepSeekProvider.h&#034;<br \/>\n#include &lt;gtest\/gtest.h&gt;<br \/>\n#include &lt;spdlog\/common.h&gt;<\/p>\n<p>using namespace ai_chat_sdk;<\/p>\n<p>TEST(DeepSeekProviderTest, sendMessage)<br \/>\n{<br \/>\n    \/\/ 1\u3001\u521b\u5efaDeepSeekProvider\u5bf9\u8c61<br \/>\n    std::shared_ptr&lt;LLMProvider&gt; deepseekProvider &#061; std::make_shared&lt;DeepSeekProvider&gt;();<br \/>\n    \/\/ 1.1 \u68c0\u67e5DeepSeekProvider\u662f\u5426\u521d\u59cb\u5316\u6210\u529f<br \/>\n    ASSERT_TRUE(deepseekProvider !&#061; nullptr);<\/p>\n<p>    \/\/ 2\u3001\u6784\u5efa\u6a21\u578b\u914d\u7f6e<br \/>\n    std::unordered_map&lt;std::string, std::string&gt; modelConfig;<br \/>\n    modelConfig[&#034;api_key&#034;] &#061; getenv(&#034;deepseek_apikey&#034;) ? getenv(&#034;deepseek_apikey&#034;) : &#034;&#034;;<br \/>\n    modelConfig[&#034;base_url&#034;] &#061; &#034;https:\/\/api.deepseek.com&#034;;<\/p>\n<p>    \/\/ 3\u3001\u521d\u59cb\u5316DeepSeekProvider<br \/>\n    deepseekProvider-&gt;initModel(modelConfig);<br \/>\n    \/\/ 3.1 \u68c0\u67e5\u6a21\u578b\u662f\u5426\u6709\u6548<br \/>\n    ASSERT_TRUE(deepseekProvider-&gt;IsAvailable());<\/p>\n<p>    \/\/ 4\u3001\u6784\u5efa\u8bf7\u6c42\u53c2\u6570\u914d\u7f6e(\u4e0d\u5199\u5219\u4f7f\u7528\u9ed8\u8ba4\u503c)<br \/>\n    std::unordered_map&lt;std::string, std::string&gt; requestConfig;<br \/>\n    requestConfig[&#034;model&#034;] &#061; &#034;deepseek-flash&#034;;<br \/>\n    requestConfig[&#034;temperature&#034;] &#061; &#034;0.7&#034;;<br \/>\n    requestConfig[&#034;max_tokens&#034;] &#061; &#034;2048&#034;;<br \/>\n    requestConfig[&#034;thinking_type&#034;] &#061; &#034;disabled&#034;;<br \/>\n    requestConfig[&#034;reasoning_effort&#034;] &#061; &#034;high&#034;;<\/p>\n<p>    \/\/ 5\u3001\u6784\u5efa\u6d88\u606f\u5217\u8868<br \/>\n    \/\/ \u9ed8\u8ba4\u5f62\u5f0f<br \/>\n    std::vector&lt;Message&gt; messages;<br \/>\n    \/\/ \/\/ messages.push_back({&#034;user&#034;, &#034;\u4f60\u597d, \u8bf7\u7b80\u5355\u4ecb\u7ecd\u4e00\u4e0b\u4f60\u81ea\u5df1&#034;});<\/p>\n<p>    \/\/ \/\/ \u5e26\u4e0a\u89d2\u8272\u8bbe\u5b9a<br \/>\n    \/\/ messages.push_back({&#034;system&#034;, &#034;\u4f60\u662f\u4e00\u4e2a\u6709\u7740\u5341\u5e74\u7ecf\u9a8c\u7684C&#043;&#043;\u5f00\u53d1\u5de5\u7a0b\u5e08\u4ee5\u53caAI\u5f00\u53d1\u5de5\u7a0b\u5e08&#034;});<br \/>\n    \/\/ messages.push_back({&#034;user&#034;, &#034;\u57fa\u4e8e\u5927\u6a21\u578bapi\u7684\u6d41\u5f0f\u54cd\u5e94, \u7b80\u5355\u8bb2\u89e3\u4e00\u4e0bSSE\u4e8b\u4ef6\u662f\u4ec0\u4e48?&#034;});<\/p>\n<p>    \/\/ \u5e26\u4e0a\u5386\u53f2\u4fe1\u606f<br \/>\n    \/\/ \u7b2c\u4e00\u8f6e\u7528\u6237\u63d0\u95ee<br \/>\n    messages.push_back({&#034;user&#034;, &#034;\u6211\u53eb\u5f20\u4e09&#xff0c;\u4f60\u662f\u8c01&#xff1f;&#034;});<br \/>\n    \/\/ \u586b\u5165\u4e0a\u4e00\u8f6e\u5927\u6a21\u578b\u8fd4\u56de\u7684assistant\u56de\u7b54&#xff0c;\u5f62\u6210\u5386\u53f2\u4e0a\u4e0b\u6587<br \/>\n    messages.push_back({&#034;assistant&#034;, &#034;\u4f60\u597d\u5f20\u4e09&#xff01;\u6211\u662f\u4e00\u4e2a\u4eba\u5de5\u667a\u80fd\u52a9\u624b&#xff0c;\u5f88\u9ad8\u5174\u4e3a\u4f60\u670d\u52a1\u3002&#034;});<br \/>\n    \/\/ \u65b0\u4e00\u8f6e\u7528\u6237\u63d0\u95ee&#xff1a;\u6a21\u578b\u9700\u8981\u7ed3\u5408\u4e0a\u9762\u4e24\u6761\u5386\u53f2\u4e00\u8d77\u7406\u89e3\u4e0a\u4e0b\u6587&#xff0c;\u77e5\u9053\u201c\u6211\u53eb\u4ec0\u4e48\u201d<br \/>\n    messages.push_back({&#034;user&#034;, &#034;\u6211\u53eb\u4ec0\u4e48&#xff1f;&#034;});<\/p>\n<p>    \/\/ 6\u3001\u8c03\u7528ssendMessageStreame\u53d1\u9001\u6d88\u606f<br \/>\n    auto response &#061; deepseekProvider-&gt;sendMessageStream(<br \/>\n        messages, requestConfig,<br \/>\n        [&amp;](const std::string &amp;chunk, bool isEnd)<br \/>\n        {<br \/>\n            INFO(&#034;chunk: {}&#034;, chunk);<br \/>\n            if (isEnd)<br \/>\n            {<br \/>\n                INFO(&#034;[DONE]&#034;);<br \/>\n            }<br \/>\n        });<br \/>\n    \/\/ 6.1 \u68c0\u67e5\u54cd\u5e94\u662f\u5426\u4e3a\u7a7a<br \/>\n    ASSERT_TRUE(response.has_value());<br \/>\n    INFO(&#034;response: {}&#034;, response.value());<br \/>\n} <\/p>\n<h3 id=\"%C2%A0%202.2%C2%A0%E5%85%A5%E5%8F%A3%E5%87%BD%E6%95%B0\">\u00a0 2.2\u00a0\u5165\u53e3\u51fd\u6570<\/h3>\n<p>int main(int argc, char **argv)<br \/>\n{<br \/>\n    \/\/ \u521d\u59cb\u5316Google Test\u6846\u67b6<br \/>\n    testing::InitGoogleTest(&amp;argc, argv);<\/p>\n<p>    \/\/ \u521d\u59cb\u5316\u65e5\u5fd7\u7cfb\u7edf<br \/>\n    Logger::logger_init(&#034;testLLM&#034;, &#034;stdout&#034;, spdlog::level::debug);<\/p>\n<p>    \/\/ \u8fd0\u884c\u6240\u6709\u6d4b\u8bd5\u7528\u4f8b<br \/>\n    return RUN_ALL_TESTS();<br \/>\n} <\/p>\n<h3 id=\"%C2%A0%202.3%20%E8%BF%90%E8%A1%8C%E7%BB%93%E6%9E%9C%E5%B1%95%E7%A4%BA\">\u00a0 2.3 \u8fd0\u884c\u7ed3\u679c\u5c55\u793a<\/h3>\n<p># \u8fdb\u5165\u6784\u5efa\u76ee\u5f55<br \/>\ncd test\/build<\/p>\n<p># \u751f\u6210\u6784\u5efa\u6587\u4ef6<br \/>\ncmake ..<\/p>\n<p># \u6e05\u7406\u5e76\u7f16\u8bd1<br \/>\nmake clean<br \/>\nmake<\/p>\n<p># \u8fd0\u884c\u6d4b\u8bd5\u7a0b\u5e8f<br \/>\n.\/testLLM<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104220107-6aebab2365be3.png\" \/><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u8fd9\u662f\u5185\u5bb9\u62fc\u63a5\u5b8c\u7684\u6700\u7ec8\u5b8c\u6574\u6837\u5b50&#xff0c;\u90a3\u6d41\u5f0f\u7684\u6548\u679c\u662f\u4ec0\u4e48\u6837\u7684\u5462&#xff1f;\u5982\u4e0b\u9762\u6240\u793a&#xff1a;<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104220107-6aebab23ceeab.png\" \/> <img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104220108-6aebab244e8eb.png\" \/> <img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104220108-6aebab24bf8fd.png\" \/><\/p>\n<h3 id=\"%C2%A0%202.4%C2%A0%E5%BC%95%E5%87%BA%E7%96%91%E9%97%AE\">\u00a0 2.4\u00a0\u5f15\u51fa\u7591\u95ee<\/h3>\n<p>\u00a0 \u00a0 \u00a0 \u770b\u5230\u4e0a\u9762\u7684\u65e5\u5fd7\u6253\u5370\u7ed3\u679c\u60f3\u5fc5\u5927\u5bb6\u5fc3\u91cc\u4e00\u5b9a\u4f1a\u5b58\u5728\u4e00\u4e2a\u95ee\u9898&#xff1a;<\/p>\n<p>DeepSeek \u8fd4\u56de\u7684\u6bcf\u4e00\u6b21 content_receiver \u56de\u8c03\u62ff\u5230\u7684 HTTP Chunk \u91cc\u9762&#xff0c;\u5305\u88f9\u7684\u5168\u90e8\u662f\u5b8c\u6574\u3001\u53ef\u76f4\u63a5\u5206\u5272\u7684 SSE \u4e8b\u4ef6&#xff0c;\u6ca1\u6709\u51fa\u73b0\u534a\u622a\u3001\u622a\u65ad\u7684 SSE \u62a5\u6587&#xff0c;\u8fd9\u662f\u4e3a\u4ec0\u4e48&#xff1f; \u4e0d\u7ba1\u662f\u524d\u9762\u6211\u4eec\u5b66\u4e60SSE\u534f\u8bae\u8fd8\u662f\u4e0a\u7bc7\u6587\u7ae0\u6211\u4eec\u5bf9 httplib Request \u53c2\u6570\u8fdb\u884c\u8bb2\u89e3&#xff0c;\u90fd\u63d0\u5230\u4e86\u670d\u52a1\u5668\u53d1\u9001\u8fc7\u6765\u7684\u62a5\u6587\u6240\u643a\u5e26\u7684HTTP chunk\u6570\u636e\u5757\u5185\u7684SSE\u4e8b\u4ef6\u5757\u53ef\u80fd\u5b58\u5728\u6b8b\u7f3a\u7684\u60c5\u51b5&#xff0c;\u4f46\u662f\u65e5\u5fd7\u6253\u5370\u7684\u7ed3\u679c\u5b8c\u5168\u6ca1\u6709\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5&#xff0c;\u96be\u9053\u662f\u6211\u4eec\u524d\u9762\u8bb2\u9519\u4e86\u5417&#xff1f;<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%202.4.1%C2%A0%E5%85%88%E8%A7%A3%E9%87%8A%EF%BC%9A%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E2%80%9C%E8%B4%B4%E5%BF%83%E2%80%9D%EF%BC%8C%E5%A4%A7%E6%A6%82%E7%8E%87%E5%8F%91%E9%80%81%E5%AE%8C%E6%95%B4%E7%9A%84%20SSE\">\u00a0 \u00a0 2.4.1\u00a0\u5148\u89e3\u91ca&#xff1a;\u670d\u52a1\u5668\u7684\u201c\u8d34\u5fc3\u201d&#xff0c;\u5927\u6982\u7387\u53d1\u9001\u5b8c\u6574\u7684 SSE<\/h4>\n<p>\u00a0 \u00a0 \u00a0 DeepSeek \u8fd9\u79cd\u5927\u6a21\u578b\u670d\u52a1\u7aef&#xff0c;\u5728\u5e95\u5c42\u53d1\u9001\u6d41\u5f0f\u6570\u636e\u65f6&#xff0c;\u901a\u5e38\u662f\u7531\u5176 Web \u6846\u67b6&#xff08;\u6bd4\u5982 Python \u7684 FastAPI\u3001Go \u7684 Gin \u7b49&#xff09;\u63a7\u5236\u7684\u3002 \u00a0 \u00a0 \u00a0 \u670d\u52a1\u7aef\u5728 yield \u6570\u636e\u65f6&#xff0c;\u901a\u5e38\u662f\u6309\u903b\u8f91\u5757\u5410\u51fa\u7684\u3002\u7f51\u7edc\u534f\u8bae\u6808\u5728\u6253\u5305\u6210 HTTP Chunk \u65f6&#xff0c;\u5f80\u5f80&#xff08;\u5728\u7edd\u5927\u591a\u6570\u7f51\u7edc\u72b6\u51b5\u826f\u597d\u7684\u60c5\u51b5\u4e0b&#xff09;\u4f1a\u628a\u4e00\u4e2a\u5b8c\u6574\u7684 data: {&#8230;}\\\\n\\\\n \u4f5c\u4e3a\u4e00\u4e2a\u6574\u4f53\u585e\u8fdb Chunk \u91cc\u3002\u8fd9\u5927\u5927\u51cf\u8f7b\u4e86\u5ba2\u6237\u7aef\u7684\u89e3\u6790\u538b\u529b\u3002\u00a0<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%202.4.2%C2%A0%E7%8E%B0%E5%AE%9E%E7%9A%84%E2%80%9C%E6%AE%8B%E9%85%B7%E2%80%9D%EF%BC%9A%E9%98%B2%E4%BA%BA%E4%B9%8B%E5%BF%83%E4%B8%8D%E5%8F%AF%E6%97%A0\">\u00a0 \u00a0 2.4.2\u00a0\u73b0\u5b9e\u7684\u201c\u6b8b\u9177\u201d&#xff1a;\u9632\u4eba\u4e4b\u5fc3\u4e0d\u53ef\u65e0<\/h4>\n<p>\u00a0 \u00a0 \u00a0 \u5c3d\u7ba1\u670d\u52a1\u7aef\u4f1a\u5c3d\u91cf\u53d1\u5b8c\u6574\u7684&#xff0c;\u4f46\u7f51\u7edc\u4f20\u8f93\u662f\u7269\u7406\u884c\u4e3a&#xff0c;\u4e0d\u53ef\u63a7\u56e0\u7d20\u592a\u591a\u4e86&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u7f51\u7edc\u4e2d\u95f4\u8bbe\u5907&#xff08;\u4ee3\u7406\u3001\u7f51\u5173&#xff09;&#xff1a;\u6709\u65f6\u5019 Nginx \u7b49\u4e2d\u95f4\u4ef6\u4f1a\u5bf9\u6d41\u8fdb\u884c\u91cd\u65b0\u5207\u5206\u3002<\/p>\n<\/li>\n<li>\n<p>TCP \u7684 Nagle \u7b97\u6cd5&#xff1a;\u53ef\u80fd\u628a\u5305\u5408\u5e76\u6216\u8005\u62c6\u5206\u3002<\/p>\n<\/li>\n<li>\n<p>\u6781\u7aef\u7684\u957f\u6587\u672c&#xff1a;\u5982\u679c\u67d0\u6b21\u6a21\u578b\u5410\u51fa\u7684\u5355\u5b57\u7279\u522b\u957f&#xff08;\u6216\u8005\u5305\u542b\u6781\u5927\u7684 Base64 \u56fe\u7247\u6570\u636e&#xff09;&#xff0c;\u5bfc\u81f4\u4e00\u4e2a SSE Event \u7684\u957f\u5ea6\u8d85\u8fc7\u4e86\u4e00\u4e2a HTTP Chunk \u7684\u6700\u5927\u9650\u5236&#xff0c;\u670d\u52a1\u7aef\u5c31\u4e0d\u5f97\u4e0d\u628a\u5b83\u5207\u5f00\u53d1\u9001\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u00a0 \u00a0 \u00a0 \u4e5f\u5c31\u662f\u8bf4&#xff1a;\u670d\u52a1\u7aef\u53ea\u662f \u201c\u5c3d\u91cf\u6309\u5b8c\u6574 SSE \u6253\u5305\u201d&#xff0c;\u534f\u8bae\u5c42\u9762\u6ca1\u6709\u4efb\u4f55\u627f\u8bfa\u4fdd\u8bc1 SSE \u4e0d\u4f1a\u8de8 chunk\u3002<\/p>\n<h4 id=\"%C2%A0%20%C2%A0%202.4.3%C2%A0%E7%BB%93%E8%AE%BA%EF%BC%9A%E6%97%A5%E5%BF%97%E9%87%8C%E7%9C%8B%E4%B8%8D%E5%88%B0%E5%8D%8A%E5%8C%85%20%E2%89%A0%20%E4%B8%8D%E9%9C%80%E8%A6%81%20buffer%20%2B%20while%20%E5%85%9C%E5%BA%95\">\u00a0 \u00a0 2.4.3\u00a0\u7ed3\u8bba&#xff1a;\u65e5\u5fd7\u91cc\u770b\u4e0d\u5230\u534a\u5305 \u2260 \u4e0d\u9700\u8981 buffer &#043; while \u515c\u5e95<\/h4>\n<p>\u00a0 \u00a0 \u00a0 \u6b63\u56e0\u4e3a\u4e0a\u8ff0\u7684\u201c\u4e0d\u786e\u5b9a\u6027\u201d&#xff0c;\u6211\u4eec\u6240\u8bbe\u8ba1\u7684\u4ee3\u7801\u5c31\u7edd\u4e0d\u80fd\u8d4c\u201c\u670d\u52a1\u7aef\u6bcf\u6b21\u53d1\u7684\u90fd\u662f\u5b8c\u6574\u7684\u201d\u3002\u670d\u52a1\u7aef\u53ef\u4ee5\u5e2e\u6211\u4eec\u51cf\u5c11\u534a\u5305\u6982\u7387&#xff0c;\u4f46\u662f\u5ba2\u6237\u7aef\u4e0d\u80fd\u628a\u4e1a\u52a1\u6b63\u786e\u6027\u5bc4\u6258\u5728\u670d\u52a1\u7aef\u548c\u7f51\u7edc \u201c\u597d\u5fc3\u4e0d\u62c6\u5305\u201d \u4e0a\u3002 \u00a0 \u00a0 \u00a0\u00a0\u6240\u4ee5&#xff0c;\u6700\u6807\u51c6\u3001\u6700\u65e0\u61c8\u53ef\u51fb\u7684\u5904\u7406\u65b9\u6848&#xff1a;<\/p>\n<p>\u201c\u5c06\u6b8b\u7559\u7684SSE\u4fdd\u5b58\u5230buffer\u7b49\u5f85\u4e0b\u6b21\u6570\u636e\u5230\u6765\u8fdb\u884c\u8ffd\u52a0\u201d<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u8fd9\u4e2a\u8fc7\u7a0b\u5c31\u8868\u73b0\u4e3a&#xff1a;<\/p>\n<li>\n<p>\u6570\u636e\u6765\u4e86&#xff0c;\u65e0\u8111\u585e\u8fdb buffer\u3002<\/p>\n<\/li>\n<li>\n<p>while \u627e \\\\n\\\\n\u3002\u627e\u5230\u4e86\u5207\u51fa\u6765&#xff0c;\u5904\u7406\u5b8c\u5e76\u5220\u9664&#xff1b;\u627e\u4e0d\u5230\u5c31\u4e0d\u7ba1\u3002<\/p>\n<\/li>\n<li>\n<p>\u5982\u679c\u8fd9\u6b21\u662f\u4e2a\u201c\u534a\u5305\u201d&#xff0c;buffer \u91cc\u5c31\u4f1a\u7559\u4e0b\u7c7b\u4f3c data: {&#034;content&#034;: &#034;\u95ee\u6211 \u8fd9\u6837\u7684\u6b8b\u7559\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e0b\u6b21 content_receiver \u88ab\u89e6\u53d1&#xff0c;\u65b0\u7684\u6570\u636e &#034;}}\\\\n\\\\n \u8ffd\u52a0\u8fdb buffer\u3002<\/p>\n<\/li>\n<li>\n<p>\u77ac\u95f4\u51d1\u9f50&#xff0c;while \u6210\u529f\u5207\u51fa\u5b8c\u6574\u7684 data: {&#034;content&#034;: &#034;\u95ee\u6211&#034;}\\\\n\\\\n&#xff0c;\u6e05\u7406 buffer\u3002<\/p>\n<\/li>\n<h4 id=\"%E6%80%BB%E7%BB%93%EF%BC%9A\">\u603b\u7ed3&#xff1a;<\/h4>\n<p>\u00a0 \u00a0 \u00a0 \u670d\u52a1\u7aef\u8d1f\u8d23\u201c\u5c3d\u91cf\u53d1\u5f97\u5b8c\u6574\u201d&#xff0c;\u5ba2\u6237\u7aef\u8d1f\u8d23\u201c\u4e0d\u7ba1\u4f60\u600e\u4e48\u53d1&#xff0c;\u6211\u90fd\u80fd\u62fc\u5b8c\u6574\u201d\u3002 \u00a0 \u00a0 \u00a0\u00a0\u6211\u4eec\u672c\u6b21\u6d4b\u8bd5\u89c2\u6d4b\u5230\u6240\u6709 HTTP chunk \u5185 SSE \u90fd\u662f\u5b8c\u6574\u7684&#xff0c;\u662f DeepSeek \u670d\u52a1\u6846\u67b6\u5728\u826f\u597d\u7f51\u7edc\u4e0b\u7684\u4f18\u5316\u6253\u5305\u884c\u4e3a&#xff1b;HTTP \u534f\u8bae\u672c\u8eab\u4e0d\u7ea6\u675f SSE \u4e8b\u4ef6\u4e0d\u80fd\u8de8 HTTP chunk&#xff0c;\u5f31\u7f51\u3001\u957f\u5185\u5bb9\u3001\u53cd\u5411\u4ee3\u7406\u573a\u666f\u4e0b\u4e00\u5b9a\u4f1a\u4ea7\u751f SSE \u534a\u5305&#xff0c;\u56e0\u6b64 buffer \u7f13\u5b58\u3001\u5faa\u73af\u5207\u5206\u7684\u89e3\u6790\u903b\u8f91\u662f\u5fc5\u987b\u4fdd\u7559\u7684\u3002<\/p>\n<h2 id=\"%E7%BB%93%E6%9D%9F%E8%AF%AD\">\u7ed3\u675f\u8bed<\/h2>\n<p>\u00a0 \u00a0 \u00a0 \u5230\u8fd9\u91cc&#xff0c;DeepSeek \u6d41\u5f0f\u54cd\u5e94\u63a5\u53e3\u7684\u4ee3\u7801\u5b9e\u73b0\u3001\u95ee\u9898\u6392\u9519\u3001\u5355\u5143\u6d4b\u8bd5\u4e0e\u534f\u8bae\u5c42\u9762\u7684\u601d\u8003\u5c31\u5168\u90e8\u5b8c\u6210\u4e86\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u6211\u4eec\u987a\u7740\u76ee\u5f55\u4e00\u6b65\u6b65\u843d\u5730\u4e86 SSE \u6d41\u5f0f\u8c03\u7528\u94fe\u8def&#xff0c;\u4e0d\u4ec5\u5199\u51fa\u4e86\u53ef\u8fd0\u884c\u7684 C&#043;&#043; \u4ee3\u7801&#xff0c;\u66f4\u5398\u6e05\u4e86 HTTP Chunk \u548c SSE \u4e8b\u4ef6\u4e24\u5957\u72ec\u7acb\u7684\u5206\u7247\u8fb9\u754c\u3002\u4ece\u5b9e\u9645\u6d4b\u8bd5\u65e5\u5fd7\u4e2d\u6211\u4eec\u770b\u5230\u7406\u60f3\u73af\u5883\u4e0b\u670d\u52a1\u7aef\u5e38\u5e38\u8fd4\u56de\u5b8c\u6574 SSE \u4e8b\u4ef6&#xff0c;\u4f46\u4e5f\u660e\u767d\u4e86\u8fd9\u53ea\u662f\u670d\u52a1\u6846\u67b6\u5e26\u6765\u7684\u4fbf\u5229&#xff0c;\u4e0d\u80fd\u4f5c\u4e3a\u7f16\u7801\u7684\u524d\u63d0&#xff0c;buffer &#043; while\u7684\u534a\u5305\u5904\u7406\u662f\u9762\u5411\u516c\u7f51\u3001\u5f31\u7f51\u3001\u53cd\u5411\u4ee3\u7406\u573a\u666f\u5fc5\u4e0d\u53ef\u5c11\u7684\u9632\u5fa1\u903b\u8f91\u3002\u540c\u65f6\u6211\u4eec\u4e5f\u8bb0\u5f55\u4e86\u5f00\u53d1\u8fc7\u7a0b\u91cc\u9047\u5230\u7684\u7f16\u8bd1\u95ee\u9898&#xff0c;\u628a\u8e29\u5751\u7ecf\u9a8c\u6c89\u6dc0\u4e0b\u6765\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u6d41\u5f0f\u63a5\u53e3\u662f\u5927\u6a21\u578b SDK \u91cc\u590d\u6742\u5ea6\u5f88\u9ad8\u7684\u4e00\u73af&#xff0c;\u4e5f\u662f\u804a\u5929\u7c7b\u4e1a\u52a1\u7684\u6838\u5fc3\u80fd\u529b\u3002\u638c\u63e1\u8fd9\u90e8\u5206\u4e4b\u540e&#xff0c;\u6211\u4eec\u7684 SDK \u5df2\u7ecf\u540c\u65f6\u652f\u6301\u975e\u6d41\u5f0f\u3001\u6d41\u5f0f\u4e24\u79cd\u8c03\u7528\u6a21\u5f0f\u3002\u540e\u7eed\u6211\u4eec\u53ef\u4ee5\u57fa\u4e8e\u5f53\u524d\u8fd9\u5957 Provider \u62bd\u8c61&#xff0c;\u7ee7\u7eed\u63a5\u5165\u5176\u4ed6\u5382\u5546\u7684\u5927\u6a21\u578b\u670d\u52a1&#xff0c;\u8fdb\u4e00\u6b65\u5b8c\u5584\u6574\u4e2a SDK \u7684\u6269\u5c55\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x1f525;\u5c0f\u53f6-duck&#xff1a;\u4e2a\u4eba\u4e3b\u9875 \u2744\ufe0f\u4e2a\u4eba\u4e13\u680f&#xff1a;\u300aData-Structure-Learning\u300b\u300aC\u5165\u95e8\u5230\u8fdb\u9636&amp;\u81ea\u6211\u5b66\u4e60\u8fc7\u7a0b\u8bb0\u5f55\u300b \u300aLinux\u7cfb\u7edf\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b\u300aLinux\u7f51\u7edc\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b \u300aQt \u65b9\u5bf8\u6781\u5883\u300b\u00a0\u300aMySQL\u300b<br \/>\n\u2728\u672a\u62e9\u4e4b\u8def&#xff0c;\u4e0d\u987b\u56de\u5934 \u5df2\u62e9\u4e4b\u8def&#xff0c;\u7eb5\u662f\u8346\u68d8\u904d\u91ce&#xff0c;\u4ea6\u4f5c\u82b1\u6d77\u9068\u6e38 \u76ee\u5f55<br \/>\n\u524d\u8a00<br \/>\n\u4e00\u3001DeepSeek \u6d41\u5f0f\u54cd\u5e94\u63a5\u53e3\u5b9e\u73b0 1.1\u00a0\u63a5\u53e3\u5b9a\u4e49\u4e0e\u804c\u8d23\u8fb9\u754c 1.1.1\u00a0\u65b9\u6cd5\u7b7e\u540d <\/p>\n","protected":false},"author":2,"featured_media":122562,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11820,55,190,78,51],"topic":[],"class_list":["post-122571","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-atomgit","tag-c","tag-190","tag-78","tag-51"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u300aC++ \u9879\u76ee\uff1a\u624b\u5199\u5927\u6a21\u578b\u63a5\u5165 SDK\u300bDeepSeek\u63a5\u53e3\u8bbe\u8ba1\uff08\u4e0b\uff09\uff1a\u6d41\u5f0f\u54cd\u5e94\u5b9e\u73b0\u548c\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/122571.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u300aC++ \u9879\u76ee\uff1a\u624b\u5199\u5927\u6a21\u578b\u63a5\u5165 SDK\u300bDeepSeek\u63a5\u53e3\u8bbe\u8ba1\uff08\u4e0b\uff09\uff1a\u6d41\u5f0f\u54cd\u5e94\u5b9e\u73b0\u548c\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"&#x1f525;\u5c0f\u53f6-duck&#xff1a;\u4e2a\u4eba\u4e3b\u9875 \u2744\ufe0f\u4e2a\u4eba\u4e13\u680f&#xff1a;\u300aData-Structure-Learning\u300b\u300aC\u5165\u95e8\u5230\u8fdb\u9636&amp;\u81ea\u6211\u5b66\u4e60\u8fc7\u7a0b\u8bb0\u5f55\u300b \u300aLinux\u7cfb\u7edf\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b\u300aLinux\u7f51\u7edc\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b \u300aQt \u65b9\u5bf8\u6781\u5883\u300b\u00a0\u300aMySQL\u300b \u2728\u672a\u62e9\u4e4b\u8def&#xff0c;\u4e0d\u987b\u56de\u5934 \u5df2\u62e9\u4e4b\u8def&#xff0c;\u7eb5\u662f\u8346\u68d8\u904d\u91ce&#xff0c;\u4ea6\u4f5c\u82b1\u6d77\u9068\u6e38 \u76ee\u5f55 \u524d\u8a00 \u4e00\u3001DeepSeek \u6d41\u5f0f\u54cd\u5e94\u63a5\u53e3\u5b9e\u73b0 1.1\u00a0\u63a5\u53e3\u5b9a\u4e49\u4e0e\u804c\u8d23\u8fb9\u754c 1.1.1\u00a0\u65b9\u6cd5\u7b7e\u540d\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/122571.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-04T22:01:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104220101-6aebab1d8cfd7.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/122571.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/122571.html\",\"name\":\"\u300aC++ \u9879\u76ee\uff1a\u624b\u5199\u5927\u6a21\u578b\u63a5\u5165 SDK\u300bDeepSeek\u63a5\u53e3\u8bbe\u8ba1\uff08\u4e0b\uff09\uff1a\u6d41\u5f0f\u54cd\u5e94\u5b9e\u73b0\u548c\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-04T22:01:10+00:00\",\"dateModified\":\"2026-11-04T22:01:10+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/122571.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/122571.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/122571.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u300aC++ \u9879\u76ee\uff1a\u624b\u5199\u5927\u6a21\u578b\u63a5\u5165 SDK\u300bDeepSeek\u63a5\u53e3\u8bbe\u8ba1\uff08\u4e0b\uff09\uff1a\u6d41\u5f0f\u54cd\u5e94\u5b9e\u73b0\u548c\u6d4b\u8bd5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u300aC++ \u9879\u76ee\uff1a\u624b\u5199\u5927\u6a21\u578b\u63a5\u5165 SDK\u300bDeepSeek\u63a5\u53e3\u8bbe\u8ba1\uff08\u4e0b\uff09\uff1a\u6d41\u5f0f\u54cd\u5e94\u5b9e\u73b0\u548c\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/122571.html","og_locale":"zh_CN","og_type":"article","og_title":"\u300aC++ \u9879\u76ee\uff1a\u624b\u5199\u5927\u6a21\u578b\u63a5\u5165 SDK\u300bDeepSeek\u63a5\u53e3\u8bbe\u8ba1\uff08\u4e0b\uff09\uff1a\u6d41\u5f0f\u54cd\u5e94\u5b9e\u73b0\u548c\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"&#x1f525;\u5c0f\u53f6-duck&#xff1a;\u4e2a\u4eba\u4e3b\u9875 \u2744\ufe0f\u4e2a\u4eba\u4e13\u680f&#xff1a;\u300aData-Structure-Learning\u300b\u300aC\u5165\u95e8\u5230\u8fdb\u9636&amp;\u81ea\u6211\u5b66\u4e60\u8fc7\u7a0b\u8bb0\u5f55\u300b \u300aLinux\u7cfb\u7edf\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b\u300aLinux\u7f51\u7edc\u4ece\u5165\u95e8\u5230\u5b9e\u8df5\u300b \u300aQt \u65b9\u5bf8\u6781\u5883\u300b\u00a0\u300aMySQL\u300b \u2728\u672a\u62e9\u4e4b\u8def&#xff0c;\u4e0d\u987b\u56de\u5934 \u5df2\u62e9\u4e4b\u8def&#xff0c;\u7eb5\u662f\u8346\u68d8\u904d\u91ce&#xff0c;\u4ea6\u4f5c\u82b1\u6d77\u9068\u6e38 \u76ee\u5f55 \u524d\u8a00 \u4e00\u3001DeepSeek \u6d41\u5f0f\u54cd\u5e94\u63a5\u53e3\u5b9e\u73b0 1.1\u00a0\u63a5\u53e3\u5b9a\u4e49\u4e0e\u804c\u8d23\u8fb9\u754c 1.1.1\u00a0\u65b9\u6cd5\u7b7e\u540d","og_url":"https:\/\/www.wsisp.com\/helps\/122571.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-04T22:01:10+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/11\/20261104220101-6aebab1d8cfd7.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"13 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/122571.html","url":"https:\/\/www.wsisp.com\/helps\/122571.html","name":"\u300aC++ \u9879\u76ee\uff1a\u624b\u5199\u5927\u6a21\u578b\u63a5\u5165 SDK\u300bDeepSeek\u63a5\u53e3\u8bbe\u8ba1\uff08\u4e0b\uff09\uff1a\u6d41\u5f0f\u54cd\u5e94\u5b9e\u73b0\u548c\u6d4b\u8bd5 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-04T22:01:10+00:00","dateModified":"2026-11-04T22:01:10+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/122571.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/122571.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/122571.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u300aC++ \u9879\u76ee\uff1a\u624b\u5199\u5927\u6a21\u578b\u63a5\u5165 SDK\u300bDeepSeek\u63a5\u53e3\u8bbe\u8ba1\uff08\u4e0b\uff09\uff1a\u6d41\u5f0f\u54cd\u5e94\u5b9e\u73b0\u548c\u6d4b\u8bd5"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/122571","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=122571"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/122571\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/122562"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=122571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=122571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=122571"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=122571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}