Skip to content

Commit

Permalink
feat: add space-separated-values
Browse files Browse the repository at this point in the history
  • Loading branch information
cabreraalex committed Sep 29, 2023
1 parent 81e9a84 commit b11ee98
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
3 changes: 2 additions & 1 deletion backend/zeno_backend/routers/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@
"code-generation",
"image-classification",
"image-segmentation",
"openai-chat-markdown",
"openai-chat",
"space-separated-values",
"text-classification",
"openai-chat-markdown",
]


Expand Down
6 changes: 4 additions & 2 deletions frontend/src/lib/components/instance-views/views/viewMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ import ImageClassification from './views/ImageClassification.svelte';
import ImageSegmentation from './views/ImageSegmentation.svelte';
import OpenAiChat from './views/OpenAIChat.svelte';
import OpenAiChatMarkdown from './views/OpenAIChatMarkdown.svelte';
import SpaceSeparatedValues from './views/SpaceSeparatedValues.svelte';
import TextClassification from './views/TextClassification.svelte';

// MUST update /backend/zeno_backend/routers/sdk.py when adding new views
export const viewMap: Record<string, ComponentType> = {
'audio-transcription': AudioTranscription,
chatbot: Chatbot,
'code-generation': Codegen,
'image-classification': ImageClassification,
'image-segmentation': ImageSegmentation,
'openai-chat-markdown': OpenAiChatMarkdown,
'openai-chat': OpenAiChat,
'space-separated-values': SpaceSeparatedValues,
'text-classification': TextClassification,
'openai-chat-markdown': OpenAiChatMarkdown
chatbot: Chatbot
};

export const optionsMap: Record<string, ComponentType> = {
Expand Down
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>

0 comments on commit b11ee98

Please sign in to comment.