Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions docs/firmware-build.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
# esp32固件编译

## 第1步 配置环境
## 第1步 准备你的ota地址
如果你按照教程使用的是全模块部署,就应该会有ota地址。

此刻,请你用浏览器打开你的ota地址,例如我的ota地址
```
http://192.168.1.25:8002/xiaozhi/ota/
```

如果显示“OTA接口运行正常,websocket集群数量:X”。那就往下。

如果显示“OTA接口运行不正常”,大概是你还没在`智控台`配置`Websocket`地址。那就:

- 1、使用超级管理员登录智控台

- 2、顶部菜单点击`参数管理`

- 3、在列表中找到`server.websocket`项目,输入你的`Websocket`地址。例如我的就是

```
ws://192.168.1.25:8000/xiaozhi/v1/
```

配置完后,再使用浏览器刷新你的ota接口地址,看看是不是正常了。如果还不正常就,就再次确认一下Websocket是否正常启动,是否配置了Websocket地址。

## 第2步 配置环境
先按照这个教程配置项目环境[《Windows搭建 ESP IDF 5.3.2开发环境以及编译小智》](https://icnynnzcwou8.feishu.cn/wiki/JEYDwTTALi5s2zkGlFGcDiRknXf)

## 第2步 打开配置文件
## 第3步 打开配置文件
配置好编译环境后,下载虾哥iaozhi-esp32项目源码,

从这里下载虾哥[xiaozhi-esp32项目源码](https://github.com/78/xiaozhi-esp32)。

下载后,打开`xiaozhi-esp32/main/Kconfig.projbuild`文件。

## 第3步 修改OTA地址
## 第4步 修改OTA地址

找到`OTA_VERSION_URL`的`default`的内容,把`https://api.tenclass.net/xiaozhi/ota/`
改成你自己的地址,例如,我的接口地址是`http://192.168.1.25:8002/xiaozhi/ota/`,就把内容改成这个。
Expand Down
19 changes: 15 additions & 4 deletions main/xiaozhi-server/core/providers/llm/AliBL/AliBL.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
TAG = __name__
logger = setup_logging()


class LLMProvider(LLMProviderBase):
def __init__(self, config):
self.api_key = config["api_key"]
Expand All @@ -19,21 +20,25 @@ def response(self, session_id, dialogue):
# 处理dialogue
if self.is_No_prompt:
dialogue.pop(0)
logger.bind(tag=TAG).debug(f"【阿里百练API服务】处理后的dialogue: {dialogue}")
logger.bind(tag=TAG).debug(
f"【阿里百练API服务】处理后的dialogue: {dialogue}"
)

# 构造调用参数
call_params = {
"api_key": self.api_key,
"app_id": self.app_id,
"session_id": session_id,
"messages": dialogue
"messages": dialogue,
}
if self.memory_id != False:
# 百练memory需要prompt参数
prompt = dialogue[-1].get("content")
call_params["memory_id"] = self.memory_id
call_params["prompt"] = prompt
logger.bind(tag=TAG).debug(f"【阿里百练API服务】处理后的prompt: {prompt}")
logger.bind(tag=TAG).debug(
f"【阿里百练API服务】处理后的prompt: {prompt}"
)

responses = Application.call(**call_params)
if responses.status_code != HTTPStatus.OK:
Expand All @@ -44,9 +49,15 @@ def response(self, session_id, dialogue):
)
yield "【阿里百练API服务响应异常】"
else:
logger.bind(tag=TAG).debug(f"【阿里百练API服务】构造参数: {call_params}")
logger.bind(tag=TAG).debug(
f"【阿里百练API服务】构造参数: {call_params}"
)
yield responses.output.text

except Exception as e:
logger.bind(tag=TAG).error(f"【阿里百练API服务】响应异常: {e}")
yield "【LLM服务响应异常】"

def response_with_functions(self, session_id, dialogue, functions=None):
logger.bind(tag=TAG).info(f"阿里百练暂未实现完整的工具调用(function call)")
return self.response(session_id, dialogue)
51 changes: 27 additions & 24 deletions main/xiaozhi-server/core/providers/llm/fastgpt/fastgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,37 +21,36 @@ def response(self, session_id, dialogue):

# 发起流式请求
with requests.post(
f"{self.base_url}/chat/completions",
headers={"Authorization": f"Bearer {self.api_key}"},
json={
"stream": True,
"chatId": session_id,
"detail": self.detail,
"variables": self.variables,
"messages": [
{
"role": "user",
"content": last_msg["content"]
}
]
},
stream=True
f"{self.base_url}/chat/completions",
headers={"Authorization": f"Bearer {self.api_key}"},
json={
"stream": True,
"chatId": session_id,
"detail": self.detail,
"variables": self.variables,
"messages": [{"role": "user", "content": last_msg["content"]}],
},
stream=True,
) as r:
for line in r.iter_lines():
if line:
try:
if line.startswith(b'data: '):
if line[6:].decode('utf-8') == '[DONE]':
if line.startswith(b"data: "):
if line[6:].decode("utf-8") == "[DONE]":
break

data = json.loads(line[6:])
if 'choices' in data and len(data['choices']) > 0:
delta = data['choices'][0].get('delta', {})
if delta and 'content' in delta and delta['content'] is not None:
content = delta['content']
if '<think>' in content:
if "choices" in data and len(data["choices"]) > 0:
delta = data["choices"][0].get("delta", {})
if (
delta
and "content" in delta
and delta["content"] is not None
):
content = delta["content"]
if "<think>" in content:
continue
if '</think>' in content:
if "</think>" in content:
continue
yield content

Expand All @@ -62,4 +61,8 @@ def response(self, session_id, dialogue):

except Exception as e:
logger.bind(tag=TAG).error(f"Error in response generation: {e}")
yield "【服务响应异常】"
yield "【服务响应异常】"

def response_with_functions(self, session_id, dialogue, functions=None):
logger.bind(tag=TAG).info(f"fastgpt暂未实现完整的工具调用(function call)")
return self.response(session_id, dialogue)
4 changes: 4 additions & 0 deletions main/xiaozhi-server/core/providers/llm/gemini/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,7 @@ def response(self, session_id, dialogue):
yield f"JSON解码错误:{e}"
except Exception as e:
yield f"发生错误:{e}"

def response_with_functions(self, session_id, dialogue, functions=None):
logger.bind(tag=TAG).info(f"gemini暂未实现完整的工具调用(function call)")
return self.response(session_id, dialogue)