news 2026/5/1 7:52:12

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/4/23 1:26:06

企业邮箱活动:主流服务商最新优惠盘点

企业邮箱活动成为众多邮箱服务商吸引客户、展示服务优势的重要窗口。无论是新用户注册、老客户续费&#xff0c;还是特定时段的促销&#xff0c;这些企业邮箱优惠都直接关系到企业的采购成本与服务选择。本文旨在为您梳理当前市场上主流企业邮箱服务商的最新企业邮箱活动&#…

作者头像 李华
网站建设 2026/4/25 11:15:08

四层电梯三菱 PLC 程序搭建之旅

四4层电梯三菱PLC程序带io表接线图 商品主要功能&#xff1a; 1. 电梯内选和外选按钮的呼叫与对应指示灯的显示功能&#xff1b; 2. 电梯开门和关门动作&#xff0c;开门到位延时后&#xff0c;自动关闭&#xff1b; 3. 电梯上升和下降的动作&#xff1b; 4. 电梯停止在某一个楼…

作者头像 李华
网站建设 2026/5/1 6:10:49

Qwen-Image-2512-ComfyUI动漫头像生成:轻量级工作流搭建指南

Qwen-Image-2512-ComfyUI动漫头像生成&#xff1a;轻量级工作流搭建指南 镜像/应用大全&#xff0c;欢迎访问 你是否也想一键生成专属的二次元动漫头像&#xff1f;阿里最新开源的 Qwen-Image-2512 模型&#xff0c;结合可视化AI绘图平台 ComfyUI&#xff0c;让这个过程变得前…

作者头像 李华
网站建设 2026/5/1 6:05:35

Z-Image-Turbo小企业应用:低成本营销图生成部署实战

Z-Image-Turbo小企业应用&#xff1a;低成本营销图生成部署实战 1. 引言&#xff1a;为什么小企业需要自己的AI图像生成工具&#xff1f; 你有没有遇到过这样的情况&#xff1f;明天就要发新品&#xff0c;宣传海报还没做&#xff1b;临时要发朋友圈推广&#xff0c;配图得现…

作者头像 李华
网站建设 2026/4/23 15:22:36

麦橘超然与Krita AI插件对比:创作流程整合评测

麦橘超然与Krita AI插件对比&#xff1a;创作流程整合评测 1. 引言&#xff1a;当本地生成遇上创意工作流 你有没有这样的体验&#xff1f;花了几分钟写提示词、调参数&#xff0c;终于生成了一张满意的AI图像&#xff0c;结果想把它放进设计稿里时&#xff0c;却要先保存到本…

作者头像 李华
网站建设 2026/4/25 6:20:16

为什么你的LINQ多表查询总是慢?5步精准定位并解决性能瓶颈

第一章&#xff1a;为什么你的LINQ多表查询总是慢&#xff1f;5步精准定位并解决性能瓶颈 在开发基于 .NET 的数据驱动应用时&#xff0c;LINQ to Entities 是处理数据库操作的常用工具。然而&#xff0c;当涉及多表连接查询时&#xff0c;性能问题常常悄然而至。许多开发者发现…

作者头像 李华