news 2026/7/1 20:31:43

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/6/22 15:21:34

Paraformer-large前端交互升级:添加进度条和状态提示实战

Paraformer-large前端交互升级&#xff1a;添加进度条和状态提示实战 在语音识别应用中&#xff0c;用户体验往往不仅取决于模型的准确率&#xff0c;还与界面交互的流畅性和反馈及时性密切相关。当前基于 Gradio 搭建的 Paraformer-large 语音识别系统虽然功能完整&#xff0…

作者头像 李华
网站建设 2026/7/1 5:53:17

【DDoS攻击】DDOS攻击,一篇文章给你讲清!

1、互联网安全现状 随着网络世界的高速发展&#xff0c;各行业数字化转型也在如火如荼的进行。但由于TCP/IP网络底层的安全性缺陷&#xff0c;钓鱼网站、木马程序、DDoS攻击等层出不穷的恶意攻击和高危漏洞正随时入侵企业的网络&#xff0c;如何保障网络安全成为网络建设中的刚…

作者头像 李华
网站建设 2026/6/22 15:21:30

Glyph视频帧推理应用:时序信息压缩部署案例

Glyph视频帧推理应用&#xff1a;时序信息压缩部署案例 1. Glyph&#xff1a;用图像压缩长文本的视觉推理新思路 你有没有遇到过这样的问题&#xff1a;一段长达几千字的技术文档、会议记录或者小说章节&#xff0c;想让大模型理解并总结&#xff0c;结果发现大多数语言模型的…

作者头像 李华
网站建设 2026/7/1 18:16:57

阿里达摩院SenseVoiceSmall实战:Gradio可视化界面快速部署

阿里达摩院SenseVoiceSmall实战&#xff1a;Gradio可视化界面快速部署 1. 项目简介与核心能力 你有没有遇到过这样的场景&#xff1a;一段语音里不仅有说话内容&#xff0c;还夹杂着笑声、背景音乐&#xff0c;甚至能听出说话人是开心还是生气&#xff1f;传统的语音识别只能…

作者头像 李华
网站建设 2026/6/26 3:57:11

verl高吞吐训练秘诀:SOTA框架集成部署解析

verl高吞吐训练秘诀&#xff1a;SOTA框架集成部署解析 1. verl 介绍 verl 是一个灵活、高效且可用于生产环境的强化学习&#xff08;RL&#xff09;训练框架&#xff0c;专为大型语言模型&#xff08;LLMs&#xff09;的后训练设计。它由字节跳动火山引擎团队开源&#xff0c…

作者头像 李华
网站建设 2026/6/26 0:24:55

什么是线上支付?线上支付呢,主要分四个板块。

线上支付主要包含四大业务类型&#xff0c;各类型的支付形式与适用场景各有明确界定&#xff0c;具体如下&#xff1a;1. API商城接口H5&#xff1a;依托微信支付、支付宝、银联快捷等主流支付渠道&#xff0c;为线上商城类场景提供的标准化支付接口服务。2. 伪H5支付&#xff…

作者头像 李华