const{createApp}=Vue const{createVuetify,useGoTo,useDisplay}=Vuetify var data={alert:{show:false,color:'success',text:'',timeout:0,},theme:{dark:false,},nav:{showDrawer:false,showTOC:true,tocPanel:0,tab:'account',post:{discussionId:6591,currentPage:1,targetPage:1,total:18,anchor:0,goToOptions:{container:null,duration:0,easing:'easeInOutCubic',offset:-100,},worker:null,task:[],active:[],apiLock:[],originLike:new Map([]),},related:{block:1,}},search:{width:80,text:null,loading:false,},tags:[{id:49,url:'/t/1e227a036a045c7369770b31393d',name:'DeepSeek',color:'#66BB6A',icon:'mdi-tag-heart',},],posts:[{id:80705,num:0,uid:2936,content:'\u003Cp\u003E前几天我用 deepspeek 给商品分类。效果挺不错的。\u003C/p\u003E\u003Cp\u003E接口速度平均 10s,但是不需要速度,分类了一万个商品。\u003C/p\u003E\u003Cp\u003E\u003Cimg src\u003D\"https://i.imgur.com/Jqbblhl.png\"\u003E\u003C/p\u003E昨天\u003Cp\u003E程序运行几分钟就停止了,看打印速度也不对劲。\u003C/p\u003E\u003Cp\u003E\u003Cimg src\u003D\"https://i.imgur.com/jteKECt.png\"\u003E\u003C/p\u003E\u003Cp\u003E5 秒? 太快了\u003C/p\u003E\u003Cp\u003E分类分数居然有 0.8? 之前我见过最低都是 0.9 。 \u003C/p\u003E\u003Cp\u003E我就猜测是阉割了。\u003C/p\u003E\u003Cp\u003E他有时候返回:\u003Ccode\u003E\u0026#34;content\u0026#34;:\u0026#34;```json\\n{\\\u0026#34;id\\\u0026#34;:821,\\\u0026#34;name\\\u0026#34;:\\\u0026#34;奶茶\\\u0026#34;,\\\u0026#34;score\\\u0026#34;:0.9}\\n```\u0026#34;}\u003C/code\u003E\u003C/p\u003E\u003Cp\u003E导致我 json 解析失败。\u003C/p\u003E\u003Cp\u003E于是我给他加上一条:\u003Ccode\u003E- 禁止返回带```的\u003C/code\u003E\u003C/p\u003E今天\u003Cp\u003E还是没效果,照样返回\u003Ccode\u003E ```json```\u003C/code\u003E。\u003C/p\u003E\u003Cp\u003E之前一万个商品都返回正常,现在每隔几十个商品就带\u003Ccode\u003E```json```\u003C/code\u003E。\u003C/p\u003E\u003Cp\u003E估计分类也没之前准确。\u003C/p\u003E',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 17:00:30',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80706,num:1,uid:728,content:'v3 昨天更新了新版本 v3-0324 ,可能有关系',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 17:05:10',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80707,num:2,uid:9248,content:'不是阉割了, 是 v3 换版本了',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 17:05:22',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80708,num:3,uid:7150,content:'应该是 v3 更新导致的,可以试试深度思考,还是基于之前的 v3 版本',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 17:09:47',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80709,num:4,uid:2936,content:'估计就是 v3 更新导致的。\u003Cbr\u003E虽然速度快了,但是我又没要求。\u003Cbr\u003E更新了,对我来说: 变智障了',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 17:15:04',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80710,num:5,uid:14825,content:'你试一下改温度? https://api-docs.deepseek.com/zh-cn/quick_start/parameter_settings',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 17:26:15',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80711,num:6,uid:3029,content:'用 vLLM 跑的 qwen 可以指定 JSON 输出格式:\u003Cbr\u003E\u003Cbr\u003Ehttps://www.v2ex.com/t/1101310',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 17:30:46',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80712,num:7,uid:5868,content:'API 不是可以指定输出 json 吗,还会出现这种情况吗',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 17:41:49',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80713,num:8,uid:14826,content:'AI 解析日常操作 replace(\u0026#34;```json\u0026#34;, \u0026#34;\u0026#34;).replace(\u0026#34;```\u0026#34;,\u0026#34;\u0026#34;)\u003Cbr\u003E\u003Cbr\u003E顺便推荐一个 python 库: https://github.com/mangiucugna/json_repair 。能够实现 JSON 补全,stream 返回有用。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 17:51:07',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80714,num:9,uid:14826,content:'还是会遇到,可能官方也是使用 prompt 实现的,保证不了稳定性。。。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 17:52:09',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80715,num:10,uid:7128,content:'可以试试这个逻辑:\u003Cbr\u003E···\u003Cbr\u003E# 尝试解析 JSON 结果\u003Cbr\u003E try:\u003Cbr\u003E # 如果结果包含在 ```json ``` 中,提取内部内容\u003Cbr\u003E if \u0026#34;```json\u0026#34; in translated_text:\u003Cbr\u003E translated_text \u003D translated_text.split(\u0026#34;```json\u0026#34;)[1].split(\u0026#34;```\u0026#34;)[0].strip()\u003Cbr\u003E elif \u0026#34;```\u0026#34; in translated_text:\u003Cbr\u003E translated_text \u003D translated_text.split(\u0026#34;```\u0026#34;)[1].split(\u0026#34;```\u0026#34;)[0].strip()\u003Cbr\u003E import re\u003Cbr\u003E\u003Cbr\u003E json_match \u003D re.search(r\u0026#39;```json\\s*([\\s\\S]*?)\\s*```|({[\\s\\S]*})\u0026#39;, translated_text)\u003Cbr\u003E if json_match:\u003Cbr\u003E json_str \u003D json_match.group(1) or json_match.group(2)\u003Cbr\u003E result \u003D json.loads(json_str)\u003Cbr\u003E else:\u003Cbr\u003E # 如果没有找到 JSON 格式,尝试直接解析\u003Cbr\u003E result \u003D json.loads(translated_text)\u003Cbr\u003E···',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 18:00:10',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80716,num:11,uid:14528,content:'我还以为依赖 AI 输出 JSON 就我一个呢,原来都在这么干。\u003Cbr\u003E我就是感觉不管是 DeepSeek 还是通义或者别的什么 AI ,就很不稳定,有时候会输出些别的乱七八糟的东西,还以为是我提示词问题或者根本就不应该这么用……',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 18:00:46',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80717,num:12,uid:9525,content:'直接用上面提到的 json_repair ,不用搞奇技淫巧',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 18:06:04',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80718,num:13,uid:2936,content:'\u003Cimg src\u003D\"https://i.imgur.com/DkJfOou.png\"\u003E\u003Cbr\u003E\u003Cbr\u003E文档有说的,我压根没看。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 18:06:33',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80719,num:14,uid:2936,content:'```\u003Cbr\u003E5. 返回格式必须严格按照以下 JSON 格式,不要添加任何其他内容:\u003Cbr\u003E {\u0026#34;id\u0026#34;: number, \u0026#34;name\u0026#34;: \u0026#34;string\u0026#34;, \u0026#34;score\u0026#34;: number}\u003Cbr\u003E 注意:\u003Cbr\u003E - id 必须是数字类型,不能带引号\u003Cbr\u003E - name 必须是字符串类型,必须带引号\u003Cbr\u003E - score 必须是 0-1 之间的小数,表示分类的可能性\u003Cbr\u003E - 不要返回 markdown 格式或其他任何格式\u003Cbr\u003EEOT],\u003Cbr\u003E [\u0026#39;role\u0026#39; \u003D\u0026gt; \u0026#39;user\u0026#39;, \u0026#39;content\u0026#39; \u003D\u0026gt; \u0026#34;请为商品\\\u0026#34;{$product_name}\\\u0026#34;选择最合适的分类\u0026#34;]\u003Cbr\u003E ],\u003Cbr\u003E \u0026#39;temperature\u0026#39; \u003D\u0026gt; 0.1\u003Cbr\u003E ]); \u003Cbr\u003E```\u003Cbr\u003E\u003Cbr\u003E\u003Cbr\u003E我这样给的,之前稳定。\u003Cbr\u003E现在不行,估计加`{type:\u0026#39;json_object\u0026#39;}`就行了。\u003Cbr\u003E(temperature \u003D\u0026gt; 0.1 curosr 帮我改的... 压根没这个)',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 18:08:58',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80720,num:15,uid:9833,content:'插个题外话问个,现在其他家谁家有新版 v3api 可用了嘛?官网的充不了钱呀',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 18:14:33',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80721,num:16,uid:5032,content:'官网 api 慢得很,欧派和火山的 api 比较快。欧派有新版 v3 了, 不过限流比较严格。',ipRegion:'',updatedByUid:0,createdAt:'2025-03-26 19:00:56',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},{id:80722,num:17,uid:2936,content:'官网已经可以充钱了啊',ipRegion:'',updatedByUid:0,createdAt:'2025-03-27 09:09:39',updatedAt:'2025-03-28 10:44:44',mentionNum:0,mentionedBy:[],mentionUsers:[],likeUsers:[],},],usersMap:new Map([[14528,{uid:14528,url:'/u/020760036a045d7365685e6f01186603',avatar:'/a/020760036a045d7365685e6f01186603',username:'akiyamamio🤖',}],[728,{uid:728,url:'/u/12077b206a045c7767685e6f312e291f',avatar:'/a/12077b206a045c7767685e6f312e291f',username:'shintendo🤖',}],[2936,{uid:2936,url:'/u/297c432f6a045c756969506f321e3902',avatar:'/a/297c432f6a045c756969506f321e3902',username:'lyxxxh2🤖',}],[9833,{uid:9833,url:'/u/2c11625b6a045c7e6869556f461b381e',avatar:'/a/2c11625b6a045c7e6869556f461b381e',username:'LeeReamond🤖',}],[9525,{uid:9525,url:'/u/2e2b63266a045c7e6568536f323c1e21',avatar:'/a/2e2b63266a045c7e6568536f323c1e21',username:'9hills🤖',}],[14825,{uid:14825,url:'/u/160759206a045d736868536f1e59220e',avatar:'/a/160759206a045d736868536f1e59220e',username:'iamsad3508🤖',}],[7128,{uid:7128,url:'/u/1e197c5c6a045c7061685e6f3b0c1f04',avatar:'/a/1e197c5c6a045c7061685e6f3b0c1f04',username:'zqqian🤖',}],[7150,{uid:7150,url:'/u/697f55056a045c70616f566f4f186077',avatar:'/a/697f55056a045c70616f566f4f186077',username:'NoManPlay🤖',}],[3029,{uid:3029,url:'/u/177046296a045c7460685f6f423d3e06',avatar:'/a/177046296a045c7460685f6f423d3e06',username:'Livid🤖',}],[5032,{uid:5032,url:'/u/091f703c6a045c726069546f0d113870',avatar:'/a/091f703c6a045c726069546f0d113870',username:'**artruid🤖',}],[5868,{uid:5868,url:'/u/35047f076a045c72686c5e6f1a136775',avatar:'/a/35047f076a045c72686c5e6f1a136775',username:'bjzhou1990🤖',}],[14826,{uid:14826,url:'/u/2a7845076a045d736868506f1a3c2b35',avatar:'/a/2a7845076a045d736868506f1a3c2b35',username:'zfjdif🤖',}],[9248,{uid:9248,url:'/u/2e2842196a045c7e626e5e6f053f6009',avatar:'/a/2e2842196a045c7e626e5e6f053f6009',username:'SantinoSong🤖',}],]),related:[{title:'deepseek 的本次更新会带火国内的 ai 编程吗?程序员瑟瑟发抖呀...',url:'/d/082865246a045c77606a5674425a606a3c70321f',},{title:'继上一个贴:今晚用Deepseek成功和一个妹子拉近了关系(更新来了)',url:'/d/332f0a206a045c77606a5677475c6b6a59096106',},{title:'DeepSeek 写的“音符记忆”网页',url:'/d/0b2f500e6a045c77606a56764258636a2609030b',},{title:'元宝的deepseek r1是不是有问题',url:'/d/6c0a02066a045c77606a56714f516a6a54703a34',},{title:'免费Cluade3.7,DeepL翻译,文生图,文生视频!',url:'/d/0f0c642f6a045c77606a5671415d616a04360536',},{title:'ai真是个好东西',url:'/d/0a2d46286a045c77606a5671465f646a1f040006',},{title:'deepseek有什么办法免费用嘛',url:'/d/0b00710e6a045c77606a56714751646a350f6600',},{title:'deepseek的正确使用姿势是啥?你们都是怎么用的?',url:'/d/021842086a045c77606a56704151606a010d172b',},{title:'推荐几个DeepSeek满血版网页直接使用免费的网站',url:'/d/11025d0e6a045c77606a5670455d606a06136719',},{title:'deepseek的api也是服务器繁忙吗',url:'/d/3f3f5a236a045c77606a56704659656a06203d3f',},{title:'哪家的deepseek api审查最松',url:'/d/2c220b0a6a045c77606a56734f5b666a35126065',},{title:'哪家DeepSeek R1的API支持的上下文和输入输出的token最长?',url:'/d/6e026a186a045c77606a5673435c636a217b6713',},{title:'一个赛博修禅的 AI 对话网站',url:'/d/133d000b6a045c77606a5673475b676a5b732524',},{title:'请问我有 3 个 NVIDIA GT 1030(18GB RAM) (总共 80) 如何串接用在 ollama, deepseek?',url:'/d/6219700c6a045c77606a567347596b6a5b290666',},{title:'deepseek r1的api现在哪个平台最划算呢?',url:'/d/09237c1a6a045c77606a56724e5b646a14211425',},{title:'用 AI 写爬虫,做了个爬取个人社交平台内容并分析的工具',url:'/d/1601671e6a045c77606a56724f59636a0a101739',},{title:'我用周末开发了新插件, deepseek 增强扩展,补充对 cursor 的吐槽',url:'/d/3c3a54096a045c77606a5672435d616a24051220',},],} const App={setup(){const goTo=useGoTo() const{mdAndUp}=useDisplay() return{goTo,mdAndUp}},data(){return data;},mounted(){const themeDark=localStorage.getItem("themeDark") if(themeDark!==null){this.theme.dark=JSON.parse(themeDark)} if(this.nav.post.total>(this.nav.post.currentPage-1)*100+20){let moreLen=100 if(this.nav.post.total({id:null,num:(this.nav.post.currentPage-1)*100+v,uid:null,content:null,ipRegion:null,updatedByUid:null,createdAt:null,updatedAt:null,mentionNum:null,mentionedBy:null,mentionUsers:null,likeUsers:null,})) this.posts.push(...morePosts.slice(20))} this.workerStart() const hash=window.location.hash const match=hash.match(/#(\d+)/) if(match){const n=parseInt(match[1],10) if(n>=(this.nav.post.currentPage-1)*100&&n{this.jumpTo(n)})}} this.$nextTick(()=>{this.addHeadingIds() tocbot.init({tocSelector:'.toc',contentSelector:'#post-content-0',headingSelector:'h2, h3, h4',headingsOffset:100,scrollSmoothOffset:-100,scrollSmooth:true,collapseDepth:6,onClick:function(e){setTimeout(()=>{history.replaceState(null,'',window.location.pathname+window.location.search)},0)},}) tocbot.refresh()});},beforeUnmount(){this.workerStop() if(this.quill){this.quill.destroy() this.quill=null}},computed:{dposts(){return this.posts.slice(20);},},created(){},methods:{successAlert(msg){this.alert={show:true,color:'success',text:msg,timeout:1500,}},failureAlert(msg){this.alert={show:true,color:'error',text:msg,timeout:5000,}},flipThemeDark(){this.theme.dark=!this.theme.dark localStorage.setItem("themeDark",JSON.stringify(this.theme.dark))},toSearch(){if(!this.search.text){this.failureAlert('搜索词不能为空') return} let keywords=this.search.text.trim() if(keywords.length<1){this.failureAlert('搜索词不能为空') return} if(keywords.length>100){this.failureAlert('搜索词过长') return} this.doSearch(keywords)},toReg(){window.location.href="/reg"},toLogin(){window.location.href="/login"},toPage(){let url=window.location.href url=url.replace(/(\/\d+)?(#[0-9]+)?$/,this.nav.post.targetPage>1?`/${this.nav.post.targetPage}`:'') window.location.href=url},toLoadRelated({done}){if(this.my&&this.my.uid){this.apiLoadRelated({done})}else{done('ok')}},workerStart(){this.nav.post.worker=setInterval(()=>{this.workerLoad()},500);},workerStop(){if(this.nav.post.worker){clearInterval(this.nav.post.worker);this.nav.post.worker=null;}},async jumpTo(num){const page=Math.floor(num/100)+1 const i=num-(page-1)*100 if(page===this.nav.post.currentPage){this.goTo("#post-"+num,this.nav.post.goToOptions) if(!this.posts[i].id){const block=Math.floor(num/20)+1 this.nav.post.apiLock[block]=true await this.apiLoadPosts(block) this.$nextTick(()=>{this.goTo("#post-"+num,this.nav.post.goToOptions)})}}else{let url=window.location.href url=url.replace(/(\/\d+)?(#[0-9]+)?$/,page>1?`/${page}`:'') url=url+"#"+num window.location.href=url}},postIntersect(num){return(isIntersecting,entries,observer)=>{if(isIntersecting){this.nav.post.task.push(num) this.nav.post.active.push(num) this.nav.post.active=this.nav.post.active.filter(item=>Math.abs(item-num)<=5) this.nav.post.active.sort((a,b)=>a-b)}else{this.nav.post.active=this.nav.post.active.filter(item=>item!==num)} if(this.nav.post.active[0]){this.nav.post.anchor=this.nav.post.active[0]}else{this.nav.post.anchor=0}}},async apiLoadPosts(block){try{const response=await axios.post('/fapi/v1/post/block/'+block,{discussionId:this.nav.post.discussionId,}) if(response.data.code===0){response.data.data.posts.forEach(post=>{const i=post.num%100 Object.assign(this.posts[i],post)}) response.data.data.users.forEach(user=>{this.usersMap.set(user.uid,user)})}else{this.failureAlert('回帖数据加载失败: '+response.data.msg)}}catch(error){this.failureAlert('回帖数据加载失败: '+error)} this.nav.post.apiLock[block]=false},workerLoad(){while(this.nav.post.task.length){const num=this.nav.post.task.pop() const i=num-(this.nav.post.currentPage-1)*100 if(!this.posts[i].id){const block=Math.floor(num/20)+1 if(!this.nav.post.apiLock[block]){this.nav.post.apiLock[block]=true this.apiLoadPosts(block)}}}},getTimeInfo(t){if(!t){return ""} const now=new Date();const then=new Date(t);const diff=now-then;const minute=60*1000;const hour=minute*60;const day=hour*24;const month=day*30;const year=month*12;if(diffpost.num===num) if(!post){return "#"+num} const uid=post.uid const username=this.usersMap.get(uid)?.username if(!username){return "#"+num} return username},getUsernameByPostId(id){const post=this.posts.find(post=>post.id===id) if(!post){return "#"+this.getPostNumByPostId(id)} const uid=post.uid const username=this.usersMap.get(uid).username if(!username){return "#"+this.getPostNumByPostId(id)} return username},getPostNumByPostId(id){const post=this.posts.find(post=>post.id===id) return post.num},getPostById(id){const post=this.posts.find(post=>post.id===id) return post},getPostByNum(num){const post=this.posts.find(post=>post.num===num) return post},getAvatarByUid(uid){const avatar=this.usersMap.get(uid)?.avatar if(!avatar){return this.getRandomAvatar()} return avatar},getAvatarByPostNum(num){const post=this.posts.find(post=>post.num===num) if(!post){return this.getRandomAvatar()} const uid=post.uid return this.getAvatarByUid(uid)},getRandomAvatar(){const num=Math.floor(Math.random()*100) return "https://randomuser.me/api/portraits/men/"+num+".jpg"},getUrlByUid(uid){const url=this.usersMap.get(uid)?.url if(!url){return ""} return url},getTextByPostNum(num){const post=this.posts.find(post=>post.num===num) if(!post||!post.content){return '点击跳转到#'+num+'查看'} const parser=new DOMParser() const doc=parser.parseFromString(post.content,'text/html') const text=doc.body.textContent||'' return text.slice(0,100)},addHeadingIds(){const content=document.getElementById('post-content-0') if(!content){this.nav.showTOC=false return} const headings=content.querySelectorAll('h2, h3, h4') headings.forEach((heading,index)=>{if(!heading.id){heading.id=`toc-nav-${index}`}}) if(headings.length==0){this.nav.showTOC=false}},async doSearch(keywords){this.search.loading=true try{const response=await axios.post('/fapi/v1/search',{keywords:keywords,}) if(response.data.code===0){if(response.data.data.hash&&response.data.data.hash.length===32){window.location.href="/s/"+response.data.data.hash}else{this.failureAlert('搜索失败: 搜索服务异常')}}else{this.failureAlert('搜索失败: '+response.data.msg)}}catch(error){this.failureAlert('搜索失败: '+error)} this.search.loading=false},debounce(fn,delay){let timer=null return function(...args){if(timer)clearTimeout(timer) timer=setTimeout(()=>{fn.apply(this,args)},delay);};},},watch:{'nav.post.targetPage':{handler:async function(newV,oldV){this.toPage()},immediate:false},},} const vuetify=createVuetify({defaults:{global:{ripple:true,},},}) const app=createApp(App) app.use(vuetify).mount("#app")