Skip to content

Commit

Permalink
handle corner case that llm returns data with extra response field
Browse files Browse the repository at this point in the history
Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
  • Loading branch information
ruanyl committed Jun 6, 2024
1 parent 671023f commit ded29bc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/plugins/vis_type_vega/public/text_to_vega.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ export class Text2Vega {
const res = await this.http.post('/api/llm/text2vega', {
body: JSON.stringify({ query }),
});
const result = res.body.inference_results[0].output[0].dataAsMap;
let result = res.body.inference_results[0].output[0].dataAsMap;
// sometimes llm returns {response: <schema>} instead of <schema>
if (result.response) {
result = JSON.parse(result.response);
}
// need to escape field: geo.city -> field: geo\\.city
escapeField(result, 'encoding');
return result;
}
Expand Down

0 comments on commit ded29bc

Please sign in to comment.