-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add space-separated-values (#246)
- Loading branch information
1 parent
81e9a84
commit 9fe5ee0
Showing
3 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
frontend/src/lib/components/instance-views/views/views/SpaceSeparatedValues.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<script lang="ts"> | ||
import { resolveDataPoint } from '$lib/util/util'; | ||
import CircularProgress from '@smui/circular-progress'; | ||
export let entry: Record<string, number | string | boolean | { role: string; content: string }[]>; | ||
export let modelColumn: string; | ||
// Split each column by newlines then spaces. | ||
$: fetchData = (async () => { | ||
let response = await resolveDataPoint(entry); | ||
if (response instanceof Response) { | ||
response = await response.text(); | ||
} | ||
return response.split('\n').map((x) => x.split(' ')); | ||
})(); | ||
$: labelEntries = (entry['label'] + '').split('\n').map((x) => x.split(' ')); | ||
$: modelEntries = (entry[modelColumn] + '').split('\n').map((x) => x.split(' ')); | ||
</script> | ||
|
||
{#await fetchData} | ||
<CircularProgress style="height: 32px; width: 32px; margin-right:20px" indeterminate /> | ||
{:then data} | ||
<table id="example_table"> | ||
<tbody> | ||
{#each data as entry} | ||
<tr> | ||
<th>Data: </th> | ||
{#each entry as cell} | ||
<td>{cell}</td> | ||
{/each} | ||
</tr> | ||
{/each} | ||
{#each labelEntries as entry} | ||
<tr class="label"> | ||
<th>Label: </th> | ||
{#each entry as cell} | ||
<td>{cell}</td> | ||
{/each} | ||
</tr> | ||
{/each} | ||
{#if modelColumn} | ||
{#each modelEntries as entry} | ||
<tr> | ||
<th>Output: </th> | ||
{#each entry as cell} | ||
<td>{cell}</td> | ||
{/each} | ||
</tr> | ||
{/each} | ||
{/if} | ||
</tbody> | ||
</table> | ||
{/await} | ||
|
||
<style> | ||
#example_table { | ||
margin: 2.5px; | ||
border: 1px solid rgb(224, 224, 224); | ||
min-width: 350px; | ||
font-family: Arial, Helvetica, sans-serif; | ||
border-collapse: collapse; | ||
width: 100%; | ||
} | ||
#example_table td, | ||
#example_table th { | ||
border: 1px solid #ddd; | ||
padding: 8px; | ||
} | ||
#example_table tr.label { | ||
background-color: #f2f2f2; | ||
} | ||
</style> |