-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from projectatomic/feat/model-playground
feat: model playground
- Loading branch information
Showing
13 changed files
with
239 additions
and
9 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
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
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
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,37 @@ | ||
<script lang="ts"> | ||
import NavPage from '/@/lib/NavPage.svelte'; | ||
import Tab from '/@/lib/Tab.svelte'; | ||
import Route from '/@/Route.svelte'; | ||
import MarkdownRenderer from '/@/lib/MarkdownRenderer.svelte'; | ||
import type { ModelInfo } from '@shared/models/IModelInfo'; | ||
import { studioClient } from '../utils/client'; | ||
import { onMount } from 'svelte'; | ||
import ModelPlayground from './ModelPlayground.svelte'; | ||
export let modelId: string; | ||
let model: ModelInfo | undefined = undefined; | ||
onMount(async () => { | ||
model = await studioClient.getModelById(modelId); | ||
}) | ||
</script> | ||
|
||
<NavPage title="{model?.name || ''}"> | ||
<svelte:fragment slot="tabs"> | ||
<Tab title="Summary" url="{modelId}" /> | ||
<Tab title="Playground" url="{modelId}/playground" /> | ||
</svelte:fragment> | ||
<svelte:fragment slot="content"> | ||
<Route path="/" breadcrumb="Summary" > | ||
<div class="flex flex-row w-full"> | ||
<div class="flex-grow p-5"> | ||
<MarkdownRenderer source="{model?.description}"/> | ||
</div> | ||
</div> | ||
</Route> | ||
<Route path="/playground" breadcrumb="Playground"> | ||
<ModelPlayground model={model} /> | ||
</Route> | ||
|
||
</svelte:fragment> | ||
</NavPage> |
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
<script lang="ts"> | ||
import type { ModelInfo } from "@shared/models/IModelInfo"; | ||
import { router } from "tinro"; | ||
export let object: ModelInfo; | ||
function openDetails() { | ||
router.goto(`/models/${object.id}`); | ||
} | ||
</script> | ||
|
||
<div class="text-sm text-gray-700"> | ||
<button class="text-sm text-gray-700" on:click="{() => openDetails()}"> | ||
{object.name} | ||
</div> | ||
</button> |
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,55 @@ | ||
<script lang="ts"> | ||
import type { ModelInfo } from '@shared/models/IModelInfo'; | ||
import type { ModelResponseChoice } from '@shared/models/IModelResponse'; | ||
import Button from '../lib/button/Button.svelte'; | ||
import { onMount } from 'svelte'; | ||
import { studioClient } from '../utils/client'; | ||
export let model: ModelInfo | undefined; | ||
let prompt = ''; | ||
let result: ModelResponseChoice | undefined = undefined; | ||
let inProgress = false; | ||
onMount(() => { | ||
if (!model) { | ||
return; | ||
} | ||
studioClient.startPlayground(model.id); | ||
}); | ||
async function askPlayground() { | ||
if (!model) { | ||
return; | ||
} | ||
inProgress = true; | ||
result = undefined; | ||
const res = await studioClient.askPlayground(model.id, prompt) | ||
inProgress = false; | ||
if (res.choices.length) { | ||
result = res.choices[0]; | ||
} | ||
} | ||
</script> | ||
|
||
<div class="m-4 w-full flew flex-col"> | ||
<div class="mb-2">Prompt</div> | ||
<textarea | ||
bind:value={prompt} | ||
rows="4" | ||
class="w-full p-2 outline-none text-sm bg-charcoal-800 rounded-sm text-gray-700 placeholder-gray-700" | ||
placeholder="Type your prompt here"></textarea> | ||
|
||
<div class="mt-4 text-right"> | ||
<Button inProgress={inProgress} on:click={() => askPlayground()}>Send Request</Button> | ||
</div> | ||
|
||
{#if result} | ||
<div class="mt-4 mb-2">Output</div> | ||
<textarea | ||
readonly | ||
disabled | ||
rows="20" | ||
bind:value={result.text} | ||
class="w-full p-2 outline-none text-sm bg-charcoal-800 rounded-sm text-gray-700 placeholder-gray-700"></textarea> | ||
{/if} | ||
</div> |
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
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
Oops, something went wrong.