feat(llms): add transformRequestBody hook and improve prompt assembly (#480)
* feat(llms): add transformRequestBody hook and refine prompt handling * docs(website): document transformRequestBody usage * refactor(extension): keep function-valued config handling consistent in useAgent * feat: simplify `transformRequestBody` --------- Co-authored-by: Simon <10131203+gaomeng1900@users.noreply.github.com>
This commit is contained in:
@@ -146,6 +146,7 @@ function CopyButton({ text, label }: { text: string; label: string }) {
|
||||
function extractPrompt(rawRequest: unknown, role: 'system' | 'user'): string | null {
|
||||
const messages = (rawRequest as { messages?: { role: string; content?: unknown }[] })?.messages
|
||||
if (!messages) return null
|
||||
if (!Array.isArray(messages)) return null
|
||||
const msg =
|
||||
role === 'system'
|
||||
? messages.find((m) => m.role === role)
|
||||
|
||||
Reference in New Issue
Block a user