# AI 语言大模型 免费上线啦 让 deepSeek 不在卡顿! *码本服务项目* 完美接入 deepSeek 模型,并根据最新的数据进行微调!支持 ollama 相同的调用方法 提供 Java python 调用示例! ## 目录 [TOC] ## 介绍 是否还在为 deepSeek 的性能问题及无法使用而困扰?我们为您提供了一个免费的在线网页版解决方案,并支持通过API直接接入我们的服务! ## 使用指南 ### 网页端使用 访问 LY码本录 网站后,您会在右下角发现一个机器人图标。这个图标代表了集成了 codebook-deepSeek 模型的语言助手,能够满足您的各种需求。  您也可以直接访问[ AI 应用广场](/toolsPage/botApps.html " AI 应用广场"),在网页使用! ### 集成至您的系统 对于那些有远大理想和创新思维的开发者、领航者或AI爱好者来说,即使缺乏搭建模型所需的资源,也可以利用我们的API服务。我们的API设计与 ollama 完全兼容,包括 chat 和内容生成接口,使得集成到现有的知识系统变得简单快捷。 #### 获取 API 访问权限 若您希望使用我们的API,请点击 [立即购买](https://shop.lingyuzhao.top/product/17) 加入我们,开启全新的体验! ### API 格式详解 > 我们的 API 就是指向的一个链接,链接的格式如下所示 ``` https://api.get.lingyuzhao.top:8081/api/chat/generate?id=您的id&sk=您的服务sk&type=您的模型类型&model=模型编号 ``` #### model 参数 其中 `model` 参数的取值如下,此参数可以让您的模型被优化,搭配 type 参数使用! > 这是一个可选参数 | 模型名字 | 图像支持 | 语言支持| 函数支持 | 描述 | |--------------------|--------|--------|--------|------------------------------------| | model01 | × | √ | × | 适合深度思考,基于deepSeek | | model02 | × | √ | √ | 适合快速回复,支持 tools 调用 | | model03 | √ | √ | × | 适合图像处理与情绪感知 | | model04 | × | √ | × | 适合深度思考,基于qwq | | model05 | × | √ | × | 适合快速回复 | | model01_network | × | √ | × | 可以联网但不能访问链接 | | model02_network | × | √ | √ | 可以联网但不能访问链接 | | model01_network_by_url | × | √ | × | 可以访问链接和共享回忆 | | model02_network_by_url | × | √ | √ | 可以访问链接和共享回忆 | #### type 参数 其中 `type` 参数的取值如下,此参数可以让您使用一些更加具有针对性的模型! > 这是一个可选参数 > 是我们定向训练+定向提示词实现的效果,您不需要为其传递 system 参数,可以直接操作 message 的 user 消息! | 取值 | 类型 | 解释 | 建议搭配的model参数 | 群聊支持(group后缀) | | :------------: | :------------: | :------------: | :------------: | :------------: | | none | 通用 | 默认的模型类型,没有任何特殊的额外训练 | 无要求 | 支持 | | gentle_older_sister | 角色 | 以温柔大姐姐的角色数据特殊训练的模型 | model01 | 不支持 | | gentle_older_sister_s | 角色 | 以温柔大姐姐的角色数据特殊训练的模型 | model01 | 不支持 | | gentle_older_brother | 角色 | 以温柔大哥哥的角色数据特殊训练的模型 | model01 | 不支持 | | boss | 角色 | 以强势的公司领导的角色数据特殊训练的模型 | model01 | 不支持 | | disgruntled_employees | 角色 | 以不服气的员工的角色数据特殊训练的模型 | model01 | 不支持 | | gentle_little_sister | 角色 | 以乖巧可爱的妹妹的角色数据特殊训练的模型 | model01 | 不支持 | | ancient_scholars | 角色 | 以古代书生的角色数据特殊训练的模型 | model01 | 不支持 | | surly | 角色 | 以暴脾气语言数据特殊训练的模型(能查觉用户语气,识别到用户不满会转变态度,大概吧?) | model01 | 不支持 | | cat_neko | 角色 | 超可爱的小猫娘 | model01 | 支持 | | lovely_girl | 角色 | 一个20岁左右的人类小姑娘 | model01 | 支持 | | anonymity | 功能 | 懂哥模型 | model01 | 支持 | | keyword | 功能 | 关键字提取大师 | model02 | 支持 | | network | 功能 | 赋予大模型联网能力 | model01_network | 不支持 | | title_work | 功能 | 为文章生成标题和描述 | model02 | 支持 | | skill_choices | 功能 | 为用户进行技能决策之类的事情,适合作为游戏NPC | model02 | 不支持 | | shell_command | 功能 | 专注于处理Windows和Linux的命令 | model02 | 不支持 | #### 直接使用 curl 来调用! ##### 非流的调用 ``` # 在这里要写您的 id 和 sk curl "https://api.get.lingyuzhao.top:8081/api/chat/generate?id=您的id&sk=您的服务sk" \ -H "Content-Type: application/json" \ -d '{ "model": "model01", "prompt": "你好呀 很开心认识你", "stream": false }' ``` 下面是回复数据 ``` { "model": "codeBook-DeepSeek", "created_at": "2025-02-20T11:13:00.91449962Z", "response": "<think>\n好的,现在我要仔细思考用户的问题,并给出详细的中文回复。用户发来的是“你好呀 很开心认识你”,这是在用中文表达问候和愉快的情绪。\n\n首先,我应该礼貌地回应用户的问候,表达同样高兴的认识之情。接下来,可以邀请用户多聊聊,了解他们的兴趣、爱好或者最近的生活情况,这样能让对话更深入,也显示出对用户的关心。\n\n可能的话,还可以加入一些轻松的话题,比如最近有没有什么有趣的事情发生,或者用户喜欢做什么活动等。这样不仅回应了问候,还主动开启了进一步交流的大门,让对话更加自然流畅。\n</think>\n\n你好呀!很高兴认识你!有什么我可以帮助你的吗?", "done": true, "done_reason": "stop", "context": [ 151644, 108386, 104256, ....... 104139, 109944, 100364, 103929, 101037, 11319 ], "total_duration": 8227799192, "load_duration": 2980665634, "prompt_eval_count": 10, "prompt_eval_duration": 156000000, "eval_count": 145, "eval_duration": 5089000000 } ``` ##### 流的调用 ``` # 在这里要写您的 id 和 sk curl "https://api.get.lingyuzhao.top:8081/api/chat/generate?id=您的id&sk=您的服务sk" \ -H "Content-Type: application/json" \ -d '{ "model": "model01", "prompt": "你好呀 很开心认识你", "stream": true }' ``` 下面是回复数据 ``` {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.454634366Z","response":"<think>","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.489679962Z","response":"\n","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.524833742Z","response":"好","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.559989338Z","response":",","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.595085778Z","response":"用户","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.630118383Z","response":"说","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.665046226Z","response":"“","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.700078343Z","response":"你好","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.735096141Z","response":"呀","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.804842666Z","response":" 很","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.839803265Z","response":"开心","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.874719794Z","response":"认识","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.909621307Z","response":"你","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.944544052Z","response":"”,","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:43.979476225Z","response":"我","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:44.014565542Z","response":"该怎么","done":false} ........................ {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:48.250665601Z","response":"你想","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:48.285743394Z","response":"聊","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:48.321389066Z","response":"些什么","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:48.356872777Z","response":"呢","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:48.392019573Z","response":"?","done":false} {"model":"codeBook-DeepSeek","created_at":"2025-02-20T11:17:48.427794243Z","response":"","done":true,"done_reason":"stop","context":[151644,108386,104256,84141,230,102313,100720,56568,151645,151648,198,52801,3837,20002,36587,2073,108386,104256,84141,230,102313,100720,56568,33590,35946,110801,104493,101036,11319,101140,3837,100662,106098,33108,102379,20412,99936,1773,35946,99730,102124,20221,107948,102313,90395,100136,100437,42411,3407,106287,3837,73670,60726,11622,104811,104493,3837,99654,33126,109010,1773,101889,3837,102106,56007,111410,104139,109944,106128,9370,3837,100631,99172,100281,109565,1773,114717,3837,105051,26232,100640,101169,3407,101948,3837,102064,30534,99795,3837,115596,101093,1773,101912,11622,2073,104256,854,101893,110098,99689,3837,104392,33126,105874,33108,106098,3407,116880,3837,104493,99730,100630,5122,113940,5373,102313,108876,102124,5373,100437,3837,101034,104331,100642,101069,8997,151649,271,108386,104256,6313,104526,102483,100720,56568,26525,232,220,104139,109944,99663,103929,101037,11319,100631,107409,100281,109565,101036,11319],"total_duration":5047174822,"load_duration":23545179,"prompt_eval_count":10,"prompt_eval_duration":14000000,"eval_count":142,"eval_duration":5008000000} ``` #### java 调用 ##### 导入依赖 ``` <dependencies> <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> <version>4.5.14</version> </dependency> <dependency> <groupId>io.github.BeardedManZhao</groupId> <artifactId>zhao-utils</artifactId> <version>1.2.20250218</version> </dependency> </dependencies> ``` ##### 非流式 ``` package org.example; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import top.lingyuzhao.utils.StringFormatter; import java.io.IOException; import java.util.regex.Pattern; public class Main { public static void main(String[] args) throws IOException { StringFormatter format = StringFormatter.createFormat( "{\"prompt\": \"{zhaoZhao}\", \"stream\":false}", Pattern.compile("\\{zhaoZhao}") ); try (CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpPost httpPost = new HttpPost("https://api.get.lingyuzhao.top:8081/api/chat/generate?id=48&sk=2531543885707671800"); httpPost.setEntity(new StringEntity( format.function("你好,很高兴认识你!"), ContentType.APPLICATION_JSON )); try (CloseableHttpResponse execute = httpClient.execute(httpPost)) { if (execute.getStatusLine().getStatusCode() != 200) { throw new RuntimeException("请求失败"); } System.out.println(EntityUtils.toString(execute.getEntity())); } } } } ``` 下面式回复数据 ``` { "model": "codeBook-DeepSeek", "created_at": "2025-02-20T11:26:44.046575057Z", "response": "<think>\n嗯,用户发来一条问候:“你好,很高兴认识你!”看起来他想和我建立联系。首先,我需要回应他的问候,表达我也很高兴认识他。然后,我应该邀请他告诉我更多关于自己或他感兴趣的话题,这样可以引导对话继续下去。我要确保语气友好且开放,让他感到舒适,愿意进一步交流。\n\n也许他会问一些问题或者分享自己的兴趣爱好,所以我得准备好各种话题的应对策略。同时,保持回应简洁明了,避免信息过载,让用户感觉自然流畅。还要注意用词亲切,比如使用“朋友”这样的称呼,增加亲和力。\n\n接下来,我应该怎样组织语言呢?先感谢他的问候,然后表达高兴认识他,最后邀请他分享更多信息。这样结构清晰,逻辑顺畅,能够有效引导对话的发展。同时,避免任何可能让用户感到压力的语言,确保他可以轻松地继续交流。\n\n总的来说,回应需要友好、开放,并且鼓励用户进一步互动。这样才能让整个对话过程愉快且有意义。\n</think>\n\n你好!很高兴认识你!有什么我可以帮助你的吗?", "done": true, "done_reason": "stop", "context": [ 151644, 108386, ....... 108386, 6313, 112169, 100720, 56568, 6313, 104139, 109944, 100364, 103929, 101037, 11319 ], "total_duration": 8091550760, "load_duration": 26371884, "prompt_eval_count": 9, "prompt_eval_duration": 27000000, "eval_count": 227, "eval_duration": 8037000000 } ``` ##### 流式 ``` package org.example; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import top.lingyuzhao.utils.StringFormatter; import java.io.IOException; import java.util.regex.Pattern; public class Main { public static void main(String[] args) throws IOException { StringFormatter format = StringFormatter.createFormat( "{\"prompt\": \"{zhaoZhao}\", \"stream\":true}", Pattern.compile("\\{zhaoZhao}") ); try (CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpPost httpPost = new HttpPost("https://api.get.lingyuzhao.top:8081/api/chat/generate?id=您的服务ID&sk=您的SK"); httpPost.setEntity(new StringEntity( format.function("你好,很高兴认识你!"), ContentType.APPLICATION_JSON )); try (CloseableHttpResponse execute = httpClient.execute(httpPost)) { if (execute.getStatusLine().getStatusCode() != 200) { throw new RuntimeException("请求失败"); } System.out.println(EntityUtils.toString(execute.getEntity())); } } } } ``` 如果您需要一个更全的示例,处理流式消息,那么这是一个交互式的,体现出流式的有趣! ``` package org.example; import com.alibaba.fastjson2.JSONObject; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import top.lingyuzhao.utils.StringFormatter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.regex.Pattern; public class Main { public static void main(String[] args) throws IOException { StringFormatter format = StringFormatter.createFormat( "{\"prompt\": \"{zhaoZhao}\", \"stream\":true}", Pattern.compile("\\{zhaoZhao}") ); try (CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpPost httpPost = new HttpPost("https://api.get.lingyuzhao.top:8081/api/chat/generate?id=您的服务id&sk=您的sk"); Scanner scanner = new Scanner(System.in); while (true) { System.out.print("\n > "); String function = format.function(scanner.nextLine()); System.out.println(function); httpPost.setEntity(new StringEntity(function, ContentType.APPLICATION_JSON)); try (CloseableHttpResponse execute = httpClient.execute(httpPost)) { if (execute.getStatusLine().getStatusCode() != 200) { throw new RuntimeException("请求失败"); } // 获取到回复数据 try (BufferedReader content = new BufferedReader(new InputStreamReader(execute.getEntity().getContent()))) { String line; JSONObject jsonObject; while ((line = content.readLine()) != null) { jsonObject = JSONObject.parseObject(line); System.out.print(jsonObject.getString("response")); } } } } } } } ``` ### 多轮对话模型调用示例 多轮对话可以将您之前的对话记住,这能够实现用户对话的连贯性!! #### curl 调用 非流 ``` curl "https://api.get.lingyuzhao.top:8081/api/chat/?id=48&sk=2531543885707671800" \ -H "Content-Type: application/json" \ -d '{ "messages": [ { "role": "user", "content": "你好,我叫zhao,请记住我!" }, { "role": "assistant", "content": "你好,赵!我已经记住了你的名字。有什么我可以帮你的吗?" }, { "role": "user", "content": "你还记得我叫什么吗?" } ], "stream": false }' ``` 下面是返回的 json ``` { "model": "codeBook-DeepSeek", "created_at": "2025-02-20T11:42:52.014753014Z", "message": { "role": "assistant", "content": "<think>\nOkay, the user just asked me if I remember their name. Let me check our conversation history.\n\nOh right, the user introduced themselves as Zhao earlier. But in my response, I called them赵 instead of Zhao. That might have confused them because Zhao is the English version, while 赵 is their surname in Chinese.\n\nI should acknowledge that I do remember them and confirm their name clearly. Maybe they're concerned about whether I recognize them or if there's been a mix-up.\n\nI want to make sure my response is friendly and reassuring. Apologizing for any confusion could help build trust. Offering further assistance shows I'm here to help with whatever they need.\n</think>\n\n你好!是的,我记得你叫赵。有什么我可以帮助你的吗?如果有任何事情需要我帮忙,请随时告诉我!" }, "done_reason": "stop", "done": true, "total_duration": 6261329730, "load_duration": 20128422, "prompt_eval_count": 39, "prompt_eval_duration": 38000000, "eval_count": 166, "eval_duration": 5866000000 } ``` #### Java 调用 非流 交互的 ``` package org.example; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import java.io.IOException; import java.util.Scanner; public class Main2 { public static void main(String[] args) throws IOException { // 构建请求体 JSONObject jsonObject1 = JSONObject.parseObject("{\"messages\": \"[]\", \"stream\":false}"); // 设置消息历史 JSONArray objects = jsonObject1.putArray("messages"); try (CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpPost httpPost = new HttpPost("https://api.get.lingyuzhao.top:8081/api/chat/?id=48&sk=2531543885707671800"); Scanner scanner = new Scanner(System.in); while (true) { System.out.print("\n > "); // 构建消息对象 JSONObject jsonObject2 = objects.addObject(); jsonObject2.put("role", "user"); jsonObject2.put("content", scanner.nextLine()); httpPost.setEntity(new StringEntity(jsonObject1.toString(), ContentType.APPLICATION_JSON)); try (CloseableHttpResponse execute = httpClient.execute(httpPost)) { if (execute.getStatusLine().getStatusCode() != 200) { throw new RuntimeException("请求失败"); } // 获取到回复数据 JSONObject jsonObject = JSONObject.parseObject(EntityUtils.toString(execute.getEntity())); String string = jsonObject.getJSONObject("message").getString("content"); System.out.println(string); // 将历史消息追加 JSONObject jsonObject3 = objects.addObject(); jsonObject3.put("role", "assistant"); jsonObject3.put("content", string); } } } } } ``` #### java调用 流式 交互的 ``` package org.example; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Main2 { public static void main(String[] args) throws IOException { // 构建请求体 JSONObject jsonObject1 = JSONObject.parseObject("{\"messages\": \"[]\", \"stream\":true}"); // 设置消息历史 JSONArray objects = jsonObject1.putArray("messages"); try (CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpPost httpPost = new HttpPost("https://api.get.lingyuzhao.top:8081/api/chat/?id=48&sk=2531543885707671800"); Scanner scanner = new Scanner(System.in); while (true) { System.out.print("\n > "); // 构建消息对象 JSONObject jsonObject2 = objects.addObject(); jsonObject2.put("role", "user"); jsonObject2.put("content", scanner.nextLine()); httpPost.setEntity(new StringEntity(jsonObject1.toString(), ContentType.APPLICATION_JSON)); try (CloseableHttpResponse execute = httpClient.execute(httpPost)) { if (execute.getStatusLine().getStatusCode() != 200) { throw new RuntimeException("请求失败"); } // 获取到回复数据 try (BufferedReader content = new BufferedReader(new InputStreamReader(execute.getEntity().getContent()))) { String line; JSONObject jsonObject; StringBuilder stringBuilder = new StringBuilder(); while ((line = content.readLine()) != null) { // 如果您使用的是流式的 API 则在这里会接受到每一个 JSON 数据块 jsonObject = JSONObject.parseObject(line); // 在这里输出每一条数据块 String string = jsonObject.getJSONObject("message").getString("content"); System.out.print(string); // 构建历史消息 stringBuilder.append(string); } // 将历史消息追加 JSONObject jsonObject3 = objects.addObject(); jsonObject3.put("role", "assistant"); jsonObject3.put("content", stringBuilder.toString()); } } } } } } ``` #### openAI 调用 非流式 ```python from openai import OpenAI # 这里的模型参数 可以在 https://www.lingyuzhao.top/b/Article/377388518747589#API%20%E6%A0%BC%E5%BC%8F%E8%AF%A6%E8%A7%A3 查询资料 # 设置您的模型名字 model_name = "model01" # 设置您的模型类型 model_type = "cat_neko" # 设置您的服务 id 和 sk server_id, server_sk = "", "" client = OpenAI( base_url=f"https://api.get.lingyuzhao.top:8081/api/chat/{model_type}/", api_key=f"{server_id}:{server_sk}", ) chat_completion = client.chat.completions.create( messages=[ { "role": "user", # 在这里输入您的句子 "content": "你好呀", } ], model=model_name, stream=False ) # 获取回复内容 message = chat_completion.message # 打印回复内容整个对象 print(chat_completion) # 提取出模型回复的句子 print("Reply:", message['content']) ``` #### python 调用 非流式 ``` import requests # 设置您的id和sk server_id = 0 server_sk = "" url = f"https://api.get.lingyuzhao.top:8081/api/chat/?id={server_id}&sk={server_sk}" headers = { "Content-Type": "application/json" } data = { "model": "model01", "messages": [ { "role": "user", "content": "你好,我叫zhao,请记住我!" }, { "role": "assistant", "content": "你好,赵!我已经记住了你的名字。有什么我可以帮你的吗?" }, { "role": "user", "content": "你还记得我叫什么吗?" } ], "stream": False } response = requests.post(url, headers=headers, json=data) # 检查请求是否成功 if response.status_code == 200: # 记得一定要使用UserCustomBot.result=''来给结果赋值 print(response.json()['message']['content']) else: print(f"请求失败,状态码:{response.status_code}\t{response.json()}") ``` ### 多种 type 的预制模型 我们在这里演示了一些预训练模型的使用! #### title_work 标题和描述生成器 使用案例 ``` package org.example; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import top.lingyuzhao.utils.StrUtils; import java.io.IOException; public class Main4 { public static void main(String[] args) throws IOException { // 构建请求体 JSONObject jsonObject1 = new JSONObject(); jsonObject1.put("stream", false); // 设置消息历史 JSONArray objects = jsonObject1.putArray("messages"); JSONObject jsonObject2 = objects.addObject(); jsonObject2.put("role", "user"); // 您应在这里设置战况 jsonObject2.put("content", "介绍\n" + "在数字内容创作与分享的过程中,我们经常会遇到需要将图片转换为不同格式的情况。无论是为了优化网页加载速度选择更高效的WEBP格式,还是为了保持图像透明背景而选用PNG格式,一个强大且易用的图像格式转换工具都是不可或缺的。今天,我们要向大家介绍的就是这样一个高效解决所有图像格式转换需求的神器!\n" + "\n" + "一、免费便捷的网页端服务\n" + "访问我们的在线工具,无需下载任何软件,只需通过简单的几步操作,您就可以将图片迅速转换为您所需的任何格式,包括但不限于JPG、PNG、WEBP、JPEG和GIF。无论您是专业的设计师,还是偶尔需要处理图片的学生,这个工具都能满足您的各种需求,而且完全免费!\n" + "\n" + "二、灵活多样的API接入方案\n" + "对于那些希望通过程序自动完成图片格式转换任务的用户,我们也提供了功能强大的API接口。虽然这是付费服务,但别担心,通过每日登录自动签到,您可以在商城中获得资产(一种可抵扣人民币的代币),从而大幅度降低使用成本。此外,详尽的API文档和技术支持将确保您快速上手,享受无缝对接的体验。\n" + "\n" + "三、为什么选择我们?\n" + "用户体验优先:简洁直观的操作界面,让每一个人都能轻松上手。\n" + "\n" + "多样化的格式支持:涵盖几乎所有主流图像格式,一站式解决所有转换需求。\n" + "\n" + "安全可靠:我们承诺对所有上传的数据进行严格保护,确保您的隐私不被侵犯。\n" + "\n" + "持续更新优化:基于用户的反馈不断改进产品,力求提供最好的服务体验。\n" + "\n" + "具有完整的支持:我们提供了一个专门的交流群,您可以加入来咨询相关事务!\n" + "\n" + "API调用教程\n" + "API 链接:https://shop.lingyuzhao.top/product/15"); try (CloseableHttpClient httpClient = HttpClients.createDefault()) { HttpPost httpPost = new HttpPost("https://api.get.lingyuzhao.top:8081/api/chat/?id=您的服务id&sk=您的服务sk&model=model02&type=title_work"); httpPost.setEntity(new StringEntity(jsonObject1.toString(), ContentType.APPLICATION_JSON)); try (CloseableHttpResponse execute = httpClient.execute(httpPost)) { JSONObject jsonObject = JSONObject.parseObject(EntityUtils.toString(execute.getEntity())); if (execute.getStatusLine().getStatusCode() != 200) { System.out.println("请求失败: " + jsonObject); } else { String string = jsonObject.getJSONObject("message").getString("content"); // 去除思考数据 String[] strings = StrUtils.splitBy(string, "</think>"); System.out.println(strings[strings.length - 1].trim()); } } } } } ``` #### skill_choices 技能决策器 使用案例 ```python import requests # 设置您的id和sk server_id = 53 server_sk = "8641027902716764418" url = f"https://api.get.lingyuzhao.top:8081/api/chat/?id={server_id}&sk={server_sk}&type=skill_choices" headers = { "Content-Type": "application/json" } data = { # 请确保这里是 model02 "model": "model02", "messages": [ { "role": "user", "content": "我的血量剩余 20,对方剩余血量40,现在轮到我出招了,请你帮我选择" } ], "stream": False, "tools": [ { "type": "function", "function": { # 填写技能信息 "name": "m1", # 填写技能描述 "description": "对 对方 造成 10 伤害", "parameters": {} }, }, { "type": "function", "function": { # 填写技能信息 "name": "m2", # 填写技能描述 "description": "对 对方 造成 30 伤害,但自己会损失 10 血量", "parameters": {} } }, { "type": "function", "function": { # 填写技能信息 "name": "m3", # 填写技能描述 "description": "给自己回复 10 血量", "parameters": {} } } ] } response = requests.post(url, headers=headers, json=data) if response.status_code == 200: json = response.json() print(json) res = json['message'] if 'tool_calls' not in res: print(f"推荐调用:{res['content']}") else: print(f"推荐调用:{res['tool_calls'][0]['function']['name']}") ``` ------ ***操作记录*** 作者:[zhao](https://www.lingyuzhao.top//index.html?search=4 "zhao") 操作时间:2025-03-27 18:28:38 星期四 【时区:UTC 8】 事件描述备注:保存/发布 中国 天津 天津市 [](如果不需要此记录可以手动删除,每次保存都会自动的追加记录)