Skip to content

Commit

Permalink
fix: QianWenBot exception
Browse files Browse the repository at this point in the history
fix QianWenBot exception, but not fix Qianwen sign error.

Ref sunner#633
  • Loading branch information
chenjinya authored and sunner committed Nov 25, 2023
1 parent 6843a42 commit e852cdd
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/bots/QianWenBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ export default class QianWenBot extends Bot {
});

return new Promise((resolve, reject) => {
if (context.exception) {
reject(
new Error(
`${context.exception?.errorCode} ${context.exception?.errorMsg}`,
),
);
return;
}
try {
const source = new SSE("https://qianwen.aliyun.com/conversation", {
headers,
Expand Down Expand Up @@ -138,7 +146,10 @@ export default class QianWenBot extends Bot {
await axios
.post(
"https://qianwen.aliyun.com/addSession",
{ firstQuery: "ChatALL" }, // A hack to set session name
{
firstQuery: "ChatALL",
sessionType: "text_chat",
}, // A hack to set session name
{ headers: this.getRequestHeaders() },
)
.then((resp) => {
Expand All @@ -147,6 +158,14 @@ export default class QianWenBot extends Bot {
const userId = resp.data?.data?.userId;
const parentMsgId = "0";
context = { sessionId, parentMsgId, userId };
} else if (resp.data) {
context = {
exception: resp.data,
};
console.error(
"Error QianWen adding sesion resp:",
JSON.stringify(resp.data),
);
}
})
.catch((err) => {
Expand Down

1 comment on commit e852cdd

@vercel
Copy link

@vercel vercel bot commented on e852cdd Nov 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

chatall – ./

chatall-sunner.vercel.app
chatall-git-main-sunner.vercel.app
chatall-llm.vercel.app

Please sign in to comment.