Skip to content

Commit

Permalink
Fix tongyi api headers
Browse files Browse the repository at this point in the history
  • Loading branch information
wong2 committed Dec 20, 2023
1 parent a850753 commit f4c1795
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app/bots/qianwen/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ function extractVariable(variableName: string, html: string) {
}

export async function getCsrfToken() {
const html = await ofetch('https://qianwen.aliyun.com', { parseResponse: (t) => t })
const html = await ofetch('https://tongyi.aliyun.com/qianwen/', { parseResponse: (t) => t })
return extractVariable('csrfToken', html)
}
8 changes: 4 additions & 4 deletions src/app/bots/qianwen/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { requestHostPermissions } from '~app/utils/permissions'
import { uuid } from '~utils'
import { ChatError, ErrorCode } from '~utils/errors'
import { parseSSEResponse } from '~utils/sse'
import { AbstractBot, SendMessageParams } from '../abstract-bot'
import { requestHostPermission } from '~app/utils/permissions'
import { ChatError, ErrorCode } from '~utils/errors'
import { createConversation, getCsrfToken } from './api'
import { uuid } from '~utils'

function generateMessageId() {
return uuid().replace(/-/g, '')
Expand All @@ -19,7 +19,7 @@ export class QianwenWebBot extends AbstractBot {
private conversationContext?: ConversationContext

async doSendMessage(params: SendMessageParams) {
if (!(await requestHostPermission('https://qianwen.aliyun.com/'))) {
if (!(await requestHostPermissions(['https://qianwen.aliyun.com/', 'https://tongyi.aliyun.com/']))) {
throw new ChatError('Missing qianwen.aliyun.com permission', ErrorCode.MISSING_HOST_PERMISSION)
}

Expand Down
4 changes: 2 additions & 2 deletions src/rules/qianwen.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
{
"header": "origin",
"operation": "set",
"value": "https://qianwen.aliyun.com"
"value": "https://tongyi.aliyun.com"
},
{
"header": "referer",
"operation": "set",
"value": "https://qianwen.aliyun.com/"
"value": "https://tongyi.aliyun.com/"
}
]
},
Expand Down

0 comments on commit f4c1795

Please sign in to comment.