news 2026/10/13 10:12:16

lm-studio本地部署glm-4.7-flash并配置opencode使用

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
lm-studio本地部署glm-4.7-flash并配置opencode使用

模型文件

https://modelscope.cn/models/unsloth/GLM-4.7-Flash-GGUF

如何运行 GLM-4.7-Flash 指南!

https://unsloth.ai/docs/models/glm-4.7-flash

  • 禁用重复惩罚。
  • 推荐参数:

–temp 0.2 --top-k 50 --top-p 0.95 --min-p 0.01

  • jinja模板
[gMASK]<sop>{%-iftools-%}<|system|># Tools You may call one or more functions to assistwiththe user query.You are providedwithfunctionsignatures within<tools></tools>XMLtags:<tools>{%fortoolintools%}{{tool|tojson(ensure_ascii=False)}}{%endfor%}</tools>For eachfunctioncall,output thefunctionname and arguments within the followingXMLformat:<tool_call>{function-name}<arg_key>{arg-key-1}</arg_key><arg_value>{arg-value-1}</arg_value><arg_key>{arg-key-2}</arg_key><arg_value>{arg-value-2}</arg_value>...</tool_call>{%-endif-%}{%-macrovisible_text(content)-%}{%-ifcontent is string-%}{{-content}}{%-elif content is iterable and content is not mapping-%}{%-foritemincontent-%}{%-ifitem is mapping and item.type=='text'-%}{{-item.text}}{%-elif item is string-%}{{-item}}{%-endif-%}{%-endfor-%}{%-else-%}{{-content}}{%-endif-%}{%-endmacro-%}{%-setns=namespace(last_user_index=-1)%}{%-forminmessages%}{%-ifm.role=='user'%}{%setns.last_user_index=loop.index0-%}{%-endif%}{%-endfor%}{%forminmessages%}{%-ifm.role=='user'-%}<|user|>{{visible_text(m.content)}}{%-elif m.role=='assistant'-%}<|assistant|>{%-setreasoning_content=''%}{%-setcontent=visible_text(m.content)%}{%-ifm.reasoning_content is string%}{%-setreasoning_content=m.reasoning_content%}{%-else%}{%-if'</think>'incontent%}{%-setreasoning_content=content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n')%}{%-setcontent=content.split('</think>')[-1].lstrip('\n')%}{%-endif%}{%-endif%}{%-if((clear_thinking is defined and not clear_thinking)or loop.index0>ns.last_user_index)and reasoning_content-%}{{'<think>'+reasoning_content.strip()+'</think>'}}{%-else-%}{{'</think>'}}{%-endif-%}{%-ifcontent.strip()-%}{{content.strip()}}{%-endif-%}{%ifm.tool_calls%}{%fortcinm.tool_calls%}{%-iftc.function%}{%-settc=tc.function%}{%-endif%}{{-'<tool_call>'+tc.name-}}{%set_args=tc.arguments%}{%fork,vin_args.items()%}<arg_key>{{k}}</arg_key><arg_value>{{v|tojson(ensure_ascii=False)ifv is not stringelsev}}</arg_value>{%endfor%}</tool_call>{%endfor%}{%endif%}{%-elif m.role=='tool'-%}{%-ifm.content is string-%}{%-ifloop.firstor(messages[loop.index0-1].role!="tool")%}{{-'<|observation|>'}}{%-endif%}{{-'<tool_response>'}}{{-m.content}}{{-'</tool_response>'}}{%-else-%}<|observation|>{%fortrinm.content%}<tool_response>{{tr.outputiftr.output is definedelsetr}}</tool_response>{%endfor-%}{%endif-%}{%-elif m.role=='system'-%}<|system|>{{visible_text(m.content)}}{%-endif-%}{%-endfor-%}{%-ifadd_generation_prompt-%}<|assistant|>{{-'</think>'if(enable_thinking is defined and not enable_thinking)else'<think>'-}}{%-endif-%}

windows版opencode配置lmstudio

  • 从github上下载windows版本opencode解压到指定路径:D:\Program Files (x86)\opencode.exe
  • 创建调用文件添加到环境变量
  • opencode.cmd
@echo off start"""D:\Program Files (x86)\opencode.exe""D:\opencode"%*
  • opencode.ps1
param([string[]]$arguments)if($arguments){Start-Process-FilePath"D:\Program Files (x86)\opencode.exe"-ArgumentList"D:\opencode",$arguments}else{Start-Process-FilePath"D:\Program Files (x86)\opencode.exe"-ArgumentList"D:\opencode"}
  • 创建配置文件连接lmstudio,没有则创建:C:\Users\dch\.config\opencode\opencode.json
{"$schema":"https://opencode.ai/config.json","provider":{"vllm-local":{"npm":"@ai-sdk/openai-compatible","options":{"baseURL":"http://localhost:12345/v1"},"models":{"Qwen3-4B-Thinking-2507-AWQ":{"name":"Qwen3-4B-Thinking-2507-AWQ (local)"},"Qwen3-0.6B":{"name":"Qwen3-0.6B (local)"}}},"lmstudio-local":{"npm":"@ai-sdk/openai-compatible","options":{"baseURL":"http://192.168.137.1:1234/v1"},"models":{"lmstudio-community/modelscope.cn_Qwen_Qwen3-8B-GGUF_latest":{"name":"modelscope.cn_Qwen_Qwen3-8B-GGUF_latest (local)"},"lmstudio-community/GLM-4.7-Flash-Q4_K_M":{"name":"glm-4.7-flash (local)"}}}}}
  • opencode auth login -> 输入Other -> 输入lmstudio-local -> 密钥随便输
  • 启动lmstudio模型服务,可以通过浏览器输入http://192.168.137.1:1234/v1/models校验api服务是否成功建立
  • opencode -> /models -> 选择lmstudio-local模型进行对话

评价

受硬件约束,推理有点慢,但是整个推理过程和调用工具方面还是可以的。

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/10/6 12:02:07

Qwen3-1.7B响应质量不稳定?prompt工程优化实践

Qwen3-1.7B响应质量不稳定&#xff1f;prompt工程优化实践 你有没有遇到过这种情况&#xff1a;明明用的是同一个模型&#xff0c;输入的问题看起来也差不多&#xff0c;但Qwen3-1.7B有时候回答得特别清晰专业&#xff0c;有时候却答非所问、逻辑混乱&#xff0c;甚至开始“胡…

作者头像 李华
网站建设 2026/10/12 9:31:18

企业招聘系统的权限管理与安全优化方案(附源码)

博主介绍&#xff1a; 所有项目都配有从入门到精通的安装教程&#xff0c;可二开&#xff0c;提供核心代码讲解&#xff0c;项目指导。 项目配有对应开发文档、解析等 项目都录了发布和功能操作演示视频&#xff1b; 项目的界面和功能都可以定制&#xff0c;包安装运行&#xf…

作者头像 李华
网站建设 2026/10/12 1:43:33

如何监控处理进度?unet批量状态文本解读

如何监控处理进度&#xff1f;unet批量状态文本解读 1. 功能概述 本工具基于阿里达摩院 ModelScope 的 DCT-Net 模型&#xff0c;支持将真人照片转换为卡通风格。核心功能聚焦于人像的高质量风格迁移&#xff0c;特别适用于内容创作、社交头像生成、个性化设计等场景。 主要…

作者头像 李华
网站建设 2026/10/10 23:34:53

后端浅谈篇章

后端&#xff1a; 引入对象&#xff0c;获取参数 const koaCors require(koa-cors); 创建对象&#xff1a; app.use(koaCors());前端&#xff1a; 请求数据 (向后端) <script> $(function(){ $.ajax({ url:"http://localhost:5500/tag", type:"GET"…

作者头像 李华
网站建设 2026/10/10 19:06:37

基于深度学习YOLOv8的工地安全帽防护衣检测系统(YOLOv8+YOLO数据集+UI界面+Python项目源码+模型)

一、项目介绍 摘要 项目基于YOLOv8目标检测算法开发了一套专门用于建筑工地安全管理的智能检测系统&#xff0c;能够实时识别并检测工人是否佩戴安全帽、穿着防护衣等关键安全装备。系统采用五分类检测模型(nc5)&#xff0c;可准确识别helmet(安全帽)、no-helmet(未戴安全帽)…

作者头像 李华
网站建设 2026/10/10 14:51:08

fft npainting lama自动化标注流程:AI辅助mask生成新思路

fft npainting lama自动化标注流程&#xff1a;AI辅助mask生成新思路 1. 引言&#xff1a;图像修复的痛点与新解法 你有没有遇到过这样的情况&#xff1f;一张精心拍摄的照片&#xff0c;却因为画面中某个不想要的物体而无法使用——可能是路人乱入、水印遮挡&#xff0c;又或…

作者头像 李华