Skip to content

Commit 80c68f5

Browse files
committed
fix: clean up presentation of 'citation' in structured model response
Signed-off-by: Nick Mitchell <[email protected]>
1 parent e6e8390 commit 80c68f5

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

pdl-live-react/src/view/detail/kind/Model.tsx

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,30 @@ export default function ModelItems({
3535
? "yaml"
3636
: "plaintext"
3737

38+
// Ugh, some of this logic may be specific to Granite LLM
3839
const meta = Array.isArray(json)
3940
? json.flatMap(({ meta }, idx) =>
40-
Object.entries(meta).map(([k, v]) => (
41-
<Result
42-
key={k + "." + idx}
43-
term={capitalizeAndUnSnakeCase(k)}
44-
result={typeof v === "object" ? stringify(v) : v}
45-
lang={typeof v === "object" ? "yaml" : undefined}
46-
/>
47-
)),
41+
Object.entries(meta)
42+
.map(([k, v]) => {
43+
if (
44+
k === "citation" &&
45+
v &&
46+
typeof v === "object" &&
47+
"snippet" in v
48+
) {
49+
return [k, v.snippet]
50+
} else {
51+
return [k, v]
52+
}
53+
})
54+
.map(([k, v]) => (
55+
<Result
56+
key={k + "." + idx}
57+
term={capitalizeAndUnSnakeCase(String(k))}
58+
result={typeof v === "object" ? stringify(v) : v}
59+
lang={typeof v === "object" ? "yaml" : undefined}
60+
/>
61+
)),
4862
)
4963
: undefined
5064

0 commit comments

Comments
 (0)