41 lines
839 B
TypeScript
41 lines
839 B
TypeScript
export interface SpellCheckRequest {
|
|
user_input_text: string
|
|
auto_correct: boolean
|
|
custom_vocab: string[]
|
|
}
|
|
|
|
export interface DifyRequest {
|
|
inputs: {
|
|
user_input_text: string
|
|
auto_correct: boolean
|
|
custom_vocab: string[]
|
|
}
|
|
query: string
|
|
response_mode: string
|
|
}
|
|
|
|
export function checkAndCorrectSpelling(
|
|
user_input_text: string,
|
|
auto_correct: boolean,
|
|
custom_vocab: string[]
|
|
) {
|
|
const requestBody: DifyRequest = {
|
|
inputs: {
|
|
user_input_text,
|
|
auto_correct,
|
|
custom_vocab
|
|
},
|
|
query: '1',
|
|
response_mode: 'streaming'
|
|
}
|
|
|
|
return fetch('https://copilot.sino-bridge.com/v1/chat-messages', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Bearer app-Dmsx84IAGk7rVCko5MWptmK3'
|
|
},
|
|
body: JSON.stringify(requestBody)
|
|
})
|
|
}
|