chore: import upstream snapshot with attribution

This commit is contained in:
wehub-resource-sync
2026-07-13 13:34:48 +08:00
commit 77bb5bf71f
3762 changed files with 353249 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import JSON5 from 'json5'
import { jsonrepair } from 'jsonrepair'
import * as bp from '.botpress'
export type LLMInput = bp.interfaces.llm.actions.generateContent.input.Input
export type LLMOutput = bp.interfaces.llm.actions.generateContent.output.Output
export type LLMMessage = LLMInput['messages'][number]
export type LLMChoice = LLMOutput['choices'][number]
type PredictResponse = {
success: boolean
json: object
}
const tryParseJson = (str: string) => {
try {
return JSON5.parse(jsonrepair(str))
} catch {
return str
}
}
export const parseLLMOutput = (output: LLMOutput): PredictResponse => {
const mappedChoices: LLMChoice['content'][] = output.choices.map((choice) => choice.content)
const firstChoice = mappedChoices[0]!
return {
success: true,
json: tryParseJson(firstChoice as string),
}
}