# 【已售罄】一价全享DeepSeek、QwQ、Qwen 等 码本 AI 混合大模型
*码本服务项目*
码本 server 以一个实惠的价格即可获得包括DeepSeek、QwQ 和 Qwen在内的多种 顶尖 模型 的调用,支持多语言,以及 openAI ollama 协议。
> 该服务暂时售罄,请等待我们升级机房后再次售卖
## 目录
[TOC]
## 介绍
我们为您提供了一个免费的在线网页版解决方案,并支持通过API直接接入我们的服务!
不仅如此,我们的服务还支持丰富多样的角色定制,为您的项目带来前所未有的灵活性和功能性。
只需一次性支付,即可畅享包括 DeepSeek、QwQ 和 Qwen 在内的多种顶级语言模型的调用权限
## 使用指南
我们支持多端使用,支持 qq机器人,web聊天,API 等方法接入!

### qq 机器人使用
我们使用 cat_neko 模型类型制作了一个机器人,使用手机 qq 扫描下面图片的二维码就可以打开AI对话啦!

当然,您完全可以切换她的模型风格和模型参数,具体的使用方法请参阅:https://www.lingyuzhao.top/b/Article/-3439099015597393#4.%20%E5%86%85%E7%BD%AE%E6%8C%87%E4%BB%A4%20-%20qq%E6%8C%87%E4%BB%A4
### 网页端使用
访问 LY码本录 网站后,您会在右下角发现一个机器人图标。这个图标代表了集成了 码本AI模型的语言助手,能够满足您的各种需求。

您也可以直接访问[ AI 应用广场](/toolsPage/botApps.html " AI 应用广场"),在网页使用!
### 集成至您的系统
对于那些有远大理想和创新思维的开发者、领航者或AI爱好者来说,即使缺乏搭建模型所需的资源,也可以利用我们的API服务。我们的API设计与 ollama 完全兼容,包括 chat 和内容生成接口,使得集成到现有的知识系统变得简单快捷。
#### 获取 API 访问权限
若您希望使用我们的API,请点击 [20元/200万token](https://shop.lingyuzhao.top/product/17) 或者 [30元/500万token](https://shop.lingyuzhao.top/product/18) 以及 [70元/2千万token](https://shop.lingyuzhao.top/product/19) 加入我们,开启全新的体验!
### API 格式详解
> 我们的 API 就是指向的一个链接,链接的格式如下所示
```shell
https://api.get.lingyuzhao.top:8081/api/chat/generate?id=您的id&sk=您的服务sk&type=您的模型类型&model=模型编号
```
#### model 参数
其中 `model` 参数的取值如下,此参数可以让您的模型被优化,搭配 type 参数使用!
> 这是一个可选参数
> 带有 `think` 后缀则会思考后回复 速度较慢
> 带有 `no_think` 后缀则会直接回复,速度快
> 带有 `network` 后缀则会使用爬虫搜索网络,可能无法准确搜索到信息
> 带有 `network_by_url` 后缀则会使用 API 搜索网络,比较精确,需要再提问的时候直接告诉模型搜索,比如 “帮我搜索一下xxxx”
| 模型名字 | 图像支持 | 语言支持| 函数支持 | 深度思考切换 | 描述 |
|--------------------|--------|--------|--------|------------------------------------|
| model01 | × | √ | √ | √ | 适合精确回复 |
| model02 | × | √ | √ | √ | 适合快速回复 |
| model01_no_think | × | √ | √ | √ | 不需要思考的model01 |
| model02_no_think | × | √ | √ | √ | 不需要思考的model02 |
| model01_think | × | √ | √ | √ | 适合深度思考 |
| model02_think | × | √ | √ | √ | 适合快速思考回复 |
| model03 | √ | √ | × | × | 适合图像处理与情绪感知 |
| model04 | × | √ | × |× | 适合深度思考,基于qwq |
| model05 | × | √ | × | × | 适合快速回复 |
| model01_network | × | √ | × | √ | 可以联网但不能访问链接 |
| model02_network | × | √ | √ | √ | 可以联网但不能访问链接 |
| model01_network_no_think | × | √ | × | √ | 可以联网但不能访问链接 非思考 |
| model02_network_no_think | × | √ | √ | √ | 可以联网但不能访问链接 非思考 |
| model01_network_think | × | √ | × | √ | 可以联网但不能访问链接 思考 |
| model02_network_think | × | √ | √ | √ | 可以联网但不能访问链接 思考 |
| model01_network_by_url | × | √ | × | √ | 可以访问链接和共享回忆 |
| model02_network_by_url | × | √ | √ | √ | 可以访问链接和共享回忆 |
| model01_network_by_url_no_think | × | √ | × | √ | 可以访问链接和共享回忆 非思考 |
| model02_network_by_url_no_think | × | √ | √ | √ | 可以访问链接和共享回忆 非思考 |
| model01_network_by_url_think | × | √ | × | √ | 可以访问链接和共享回忆 思考 |
| model02_network_by_url_think | × | √ | √ | √ | 可以访问链接和共享回忆 思考 |
#### 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 | 支持 |
| sexy_girl | 角色 | 一个20岁左右的人类小姑娘 | model04 | 支持 |
| ai_person | 角色 | 一个更像人类的AI | model01 | 支持 |
| anonymity | 功能 | 懂哥模型 | model01 | 支持 |
| keyword | 功能 | 关键字提取大师 | model02 | 支持 |
| network | 功能 | 赋予大模型联网能力 | model01_network | 不支持 |
| title_work | 功能 | 为文章生成标题和描述 | model02 | 支持 |
| skill_choices | 功能 | 为用户进行技能决策之类的事情,适合作为游戏NPC | model02 | 不支持 |
| shell_command | 功能 | 专注于处理Windows和Linux的命令 | model02 | 不支持 |
#### 直接使用 curl 来调用!
##### 非流的调用
```shell
# 在这里要写您的 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
}'
```
下面是回复数据
```json
{
"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
}
```
##### 流的调用
```shell
# 在这里要写您的 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
}'
```
下面是回复数据
```json
{"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 调用
##### 导入依赖
```xml
<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>
```
##### 非流式
```java
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()));
}
}
}
}
```
下面是回复数据
```json
{
"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
}
```
##### 流式
```java
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()));
}
}
}
}
```
如果您需要一个更全的示例,处理流式消息,那么这是一个交互式的,体现出流式的有趣!
```java
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"));
}
}
}
}
}
}
}
```
### 函数调用示例
```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}&type=skill_choices"
headers = {
"Content-Type": "application/json"
}
data = {
# 请确保这里是支持函数的模型
"model": "model01_no_think",
"messages": [
{
"role": "user",
"content": "给 public@lingyuzhao.top 发送一封邮件"
}
],
"stream": False,
"tools": [
{
"type": "function",
"function": {
# 填写技能信息
"name": "m1",
# 填写技能描述
"description": "查询指定地点的天气",
"parameters": {
"properties": {
"p1": {"type": "string", "description": "The city and country, e.g., London, UK"},
},
"required": ["location"],
}
},
},
{
"type": "function",
"function": {
# 填写技能信息
"name": "send",
# 填写技能描述
"description": "给某个邮箱发送一个邮件",
"parameters": {
"properties": {
"p1": {"type": "string", "description": "目标邮箱的地址"},
},
"required": ["Email"],
}
}
}
]
}
def send(p1):
# ...这里写邮件发送逻辑...
return "邮件发送成功 至:" + p1
def m1(p1):
# ...这里写天气查询逻辑...
return "天气查询成功 ,查询地点:" + p1
functions = {
"send": send,
"m1": m1
}
response = requests.post(url, headers=headers, json=data)
function_name = ''
function_params = ''
if response.status_code == 200:
json = response.json()
print(json)
res = json['message']
if 'tool_calls' not in res:
function_name = res['content']
else:
function_name = res['tool_calls'][0]['function']['name']
function_params = res['tool_calls'][0]['function']['arguments']['p1']
print(functions[function_name](function_params))
```
### 多轮对话模型调用示例
多轮对话可以将您之前的对话记住,这能够实现用户对话的连贯性!!
#### curl 调用 非流
```python
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 调用 非流 交互的
```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调用 流式 交互的
```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
import json
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 = "model02"
# 设置您的模型类型
model_type = "none"
# 设置您的服务 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}",
)
stream = True
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
# 在这里输入您的句子
"content": "你好呀, 你是谁",
}
],
model=model_name,
stream=stream
)
if stream:
for chunk in chat_completion:
print(chunk.choices[0].delta.content, end='')
else:
# 打印回复内容整个对象
print(chat_completion)
# 提取出文字
print(chat_completion.choices[0].message.content)
```
#### python 调用 非流式
```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()}")
```
#### Spring AI 完全兼容
您可以查阅 https://www.lingyuzhao.top/b/Article/-2142109884372635 了解到相关详情!
### 多种 type 的预制模型
我们在这里演示了一些预训练模型的使用!
#### title_work 标题和描述生成器 使用案例
```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 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 = {
# 请确保这里是 支持函数的模型
"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']}")
```
### 切换模型思考模式
在混合模型中,有一些 model 是支持切换模型的思考模式的,我们在这里展示了如何设置模型的思考模式!
#### 连接 API 服务器的时候设置是否需要深度思考
您只需要将您的 model 参数后缀加上 `_no_think` 或者 `_think` 就可以了,相当于是切换到直接回复与深度思考的两种模型!
```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 = "none"
# 设置您的服务 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}",
)
stream = False
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
# 在这里输入您的句子 TODO /think 代表使用深度思考 /no_think 代表不使用深度思考
"content": "/think 你好呀, 你是谁",
}
],
model=model_name,
stream=stream
)
if stream:
for chunk in chat_completion:
print(chunk.choices[0].delta.content, end='')
else:
# 打印回复内容整个对象
print(chat_completion)
# 提取出文字
print(chat_completion.choices[0].message.content)
```
#### 动态设置是否需要深度思考
> 在历史消息中,如果包含 /no_think 则本次回复也不再深度思考
```java
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 查询资料
# 设置您的模型名字 确保这里没有 think 后缀 用于后面动态设置
model_name = "model01"
# 设置您的模型类型
model_type = "none"
# 设置您的服务 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}",
)
stream = False
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
# 在这里输入您的句子 TODO /think 代表使用深度思考 /no_think 代表不使用深度思考
"content": "/think 你好呀, 你是谁",
}
],
model=model_name,
stream=stream
)
if stream:
for chunk in chat_completion:
print(chunk.choices[0].delta.content, end='')
else:
# 打印回复内容整个对象
print(chat_completion)
# 提取出文字
print(chat_completion.choices[0].message.content)
```
------
***操作记录***
作者:[zhao](https://www.lingyuzhao.top//index.html?search=4 "zhao")
操作时间:2025-08-26 21:13:03 星期二 【时区:UTC 8】
事件描述备注:保存/发布
中国 天津市 天津
[](如果不需要此记录可以手动删除,每次保存都会自动的追加记录)