Skip to content

Commit

Permalink
feat: ๐Ÿ—๏ธ add check for undefined text in tracePromptResult
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Dec 20, 2024
1 parent 5725842 commit e17d55b
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions packages/core/src/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1052,18 +1052,20 @@ export function tracePromptResult(
const { text } = resp || {}

// try to sniff the output type
const language = JSON5TryParse(text)
? "json"
: XMLTryParse(text)
? "xml"
: /^(-|\*|#+|```)\s/im.test(text)
? "markdown"
: "text"
trace.detailsFenced(`๐Ÿ”  output`, text, language)
if (language === "markdown")
trace.appendContent(
"\n\n" + HTMLEscape(prettifyMarkdown(text)) + "\n\n"
)
if (text !== undefined) {
const language = JSON5TryParse(text)
? "json"
: XMLTryParse(text)
? "xml"
: /^(-|\*|#+|```)\s/im.test(text)
? "markdown"
: "text"
trace.detailsFenced(`๐Ÿ”  output`, text, language)
if (language === "markdown")
trace.appendContent(
"\n\n" + HTMLEscape(prettifyMarkdown(text)) + "\n\n"
)
}
}

export function appendUserMessage(
Expand Down

0 comments on commit e17d55b

Please sign in to comment.