调用报错id变量未定义
- Dominant language
- TypeScript
- Stars
- 292
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
当我在vue中使用如下的代码进行智能体的调用时候,出现报错。具体情况如下:
1. 代码:
[CozeTest.txt](https://github.com/user-attachments/files/23181207/CozeTest.txt)
2. 错误的现象:
2.1 从浏览器的调试上看,网络请求的响应都是正常的,响应如下:
[Untitled-1.json](https://github.com/user-attachments/files/23181208/Untitled-1.json)
对应的代码是:
```
*/ async createAndPoll(params, options) {
if (!params.user_id) params.user_id = uuid();
const { conversation_id, ...rest } = params;
const apiUrl = `/v3/chat${conversation_id ? `?conversation_id=${conversation_id}` : ''}`;
const payload = {
...rest,
additional_messages: handleAdditionalMessages(params.additional_messages),
shortcut_command: params.shortcut_command ? {
...params.shortcut_command,
parameters: handleParameters(params.shortcut_command.parameters)
} : void 0,
stream: false
};
const result = await this._client.post(apiUrl, payload, false, options);
const chatId = result.data.id;
const conversationId = result.data.conversation_id;
let chat;
while(true){
await sleep(100);
chat = await this.retrieve(conversationId, chatId);
if ('completed' === chat.status || 'failed' === chat.status || 'requires_action' === chat.status) break;
}
const messageList = await this.messages.list(conversationId, chatId);
return {
chat,
messages: messageList
};
}
```
也就是 `const chatId = result.data.id;` 出现错误
Contributor guide
Research direction
Start by reviewing the createAndPoll method and the attached CozeTest.txt code alongside Untitled-1.json. Reproduce the Vue call and inspect the response at the point where const chatId = result.data.id is evaluated. Done means the reported error is explained and the affected call works with a verified regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100