当前位置: 首页 > wzjs >正文

用lls建设一个网站做网站的软件叫什么

用lls建设一个网站,做网站的软件叫什么,秒火食品代理网,广安市网站建设解决方案 把reasoning content的东西移到content中来 并在reasoning时,手动加上标签。具体做法是截获第三方api返回的stream,并修改其中的内容,再移交给open webUI处理。 在backend\open_webui\routers\openai.py中 找到 generate_chat_com…

解决方案

把reasoning content的东西移到content中来 并在reasoning时,手动加上标签。具体做法是截获第三方api返回的stream,并修改其中的内容,再移交给open webUI处理。

在backend\open_webui\routers\openai.py中 找到 generate_chat_completion 这个函数

r = Nonesession = Nonestreaming = Falseresponse = None

下方 增加截获函数 这个方案适用于 火山 百炼 vLLM我没试过,但是思路是一样的,根据vLLM返回的chunk内容,把reasoning的部分贴到content中去就能正常显示了。

async def modify_stream_content(original_stream):start_reasoning = Trueend_reasoning = True# 逐块处理流式内容async for chunk in original_stream:# 示例:修改 chunk 内容(假设 chunk 是 JSON 字符串)try:# 1. 解码字节流为字符串decoded_chunk = chunk.decode('utf-8').lstrip('data: ').strip()# 2. 解析 JSON(根据实际格式调整)chunk_data = json.loads(decoded_chunk)# 3. 修改内容if "choices" in chunk_data and len(chunk_data["choices"]) > 0:delta = chunk_data["choices"][0].get("delta", {})# print(delta)if delta["content"] == None:delta["content"] = ""if "reasoning_content" in delta and delta["reasoning_content"] == None:delta["reasoning_content"] = ""if delta["content"] == "":if start_reasoning:delta["content"] = "<think>" + delta["content"] + delta["reasoning_content"]start_reasoning = Falseelse:delta["content"] = delta["content"] + delta["reasoning_content"]else:if end_reasoning:delta["content"] = "</think>" + delta["content"]end_reasoning = False# print(delta)# 4. 重新编码为字节流modified_chunk = f"data: {json.dumps(chunk_data)}\n\n".encode('utf-8')except (json.JSONDecodeError, KeyError) as e:# 处理错误(可选:记录日志或跳过)modified_chunk = chunk  # 保留原始数据# 5. 返回修改后的 chunkyield modified_chunk

在下方,if "text/event-stream" in r.headers.get("Content-Type", ""): 分支里。调用截获函数并返回

 # Check if response is SSEif "text/event-stream" in r.headers.get("Content-Type", ""):streaming = True# 调用截获函数modified_stream = modify_stream_content(r.content)return StreamingResponse(# r.content,modified_stream,status_code=r.status,headers=dict(r.headers),background=BackgroundTask(cleanup_response, response=r, session=session),)
http://www.dtcms.com/wzjs/313450.html

相关文章:

  • 黑龙江做网站哪家好新手如何自己做网站
  • 搜索引擎优化排名优化培训seo公司的选上海百首网络
  • 魔兽世界 建设公会网站文件关键词搜索工具
  • 网站的模版可以换吗企业网站推广
  • 西昌市规划建设局网站郑州seo网络营销
  • 嘉兴城乡建设局网站新闻稿件代发平台
  • 创建一个平台多少钱深圳高端seo外包公司
  • 网站目录遍历济南百度
  • 北京住房建设委员会官方网站电商网络推广
  • 电脑怎么建网站详细步骤宁阳网站seo推广
  • 星沙做网站优化网站快速排名软件
  • wordpress 韩版 企业seo推广是什么意思
  • 建设网站需要多少钱windows优化大师有用吗
  • 郑州网络推广专员阿亮seo技术
  • 咸阳做网站的怎样搭建自己的网站
  • 成都微信网站建设多少百度销售平台
  • 怎么给网站动态做伪静态企点
  • 企业服务器沧州网站建设优化公司
  • 网站设计稿是怎么做的代推广app下载
  • 政府网站建设的战略营销策略ppt
  • html5自适应网站模版搜索引擎优化的流程是什么
  • 网站使用什么语言好百度客服联系方式
  • 在线设计平台csnva重庆百度推广优化排名
  • 网站建设模板怎么做sq网站推广
  • 做旅游网站挣钱吗公司的公关
  • 上海做网站建设百度网盘人工客服电话多少
  • 寻找郑州网站建设公司windows优化大师
  • id97网站怎么做的西安网站seo公司
  • Wordpress支付时效无锡网站优化
  • 手机网站优化技巧seo网络推广企业