Skip to content

Commit

Permalink
fix choice renderting in trace
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Feb 1, 2025
1 parent 1f9a226 commit 0e07788
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion packages/core/src/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,12 @@ async function choicesToLogitBias(
]
})
)
trace.itemValue("choices", choices.join(", "))
trace.itemValue(
"choices",
choices
.map((c) => (typeof c === "string" ? c : JSON.stringify(c)))
.join(", ")
)
trace.itemValue("logit bias", JSON.stringify(logit_bias))
return logit_bias
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/think.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ describe("convertThinkToMarkdown", () => {
test("should convert <think> tags to <details> tags", () => {
const input = "<think>This is \na test</think>"
const expected =
"<details><summary>πŸ€” think</summary>This is \na test</details>"
"\n<details><summary>πŸ€” think</summary>This is \na test</details>\n"
const result = convertThinkToMarkdown(input)
assert.equal(result, expected)
})

test("should handle multiple <think> tags", () => {
const input = "<think>First</think> and <think>Second</think>"
const expected =
"<details><summary>πŸ€” think</summary>First</details> and <details><summary>πŸ€” think</summary>Second</details>"
"\n<details><summary>πŸ€” think</summary>First</details>\n and \n<details><summary>πŸ€” think</summary>Second</details>\n"
const result = convertThinkToMarkdown(input)
assert.equal(result, expected)
})

test("should handle <think> tags without closing tags", () => {
const input = "<think>This is a test"
const expected =
"<details><summary>πŸ€” thinking...</summary>This is a test</details>"
"\n<details><summary>πŸ€” thinking...</summary>This is a test</details>\n"
const result = convertThinkToMarkdown(input)
assert.equal(result, expected)
})
Expand Down

0 comments on commit 0e07788

Please sign in to comment.