Files
copilot-toolbox-template334…/src/api/spell-check-system.ts
2026-01-16 06:29:38 +00:00

47 lines
1.2 KiB
TypeScript

export interface SpellCheckSystemRequest {
text_input: string
enable_error_category: boolean
enable_correction_suggestion: boolean
enable_batch_processing: boolean
}
export interface DifyRequest {
inputs: {
text_input: string
enable_error_category: boolean
enable_correction_suggestion: boolean
enable_batch_processing: boolean
}
query: string
response_mode: string
}
export interface SpellCheckResult {
error_word: string
context: string
suggestion: string
error_type?: string
}
export function detectSpellingErrors(params: SpellCheckSystemRequest) {
const requestBody: DifyRequest = {
inputs: {
text_input: params.text_input,
enable_error_category: params.enable_error_category,
enable_correction_suggestion: params.enable_correction_suggestion,
enable_batch_processing: params.enable_batch_processing
},
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-YOaqLN0ZBsMozXCoYJqogwiA'
},
body: JSON.stringify(requestBody)
})
}