-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correct streaming interruptions
- Loading branch information
Showing
15 changed files
with
242 additions
and
50 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
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 @@ | ||
import { nanoid } from 'nanoid' | ||
import type { types } from '~~/utils/types' | ||
|
||
export function usePersona() { | ||
const db = useIDB() | ||
|
||
const personaList = useState<types.Persona[]>('personaList', () => []) | ||
|
||
async function initPersonaList() { | ||
personaList.value = await db.table('personas').toArray() | ||
if (!personaList.value.length) { | ||
await createPersona({ | ||
id: nanoid(), | ||
title: 'Golem', | ||
instructions: 'You are Golem, a large language model based assistant. Answer as concisely as possible.', | ||
}) | ||
} | ||
} | ||
|
||
async function createPersona(persona: types.Persona) { | ||
const newPersona = { | ||
...persona, | ||
id: nanoid(), | ||
} | ||
await db.table('personas').add(newPersona) | ||
personaList.value.push(newPersona) | ||
await updatePersonaList() | ||
} | ||
|
||
async function deletePersona(personaId: string) { | ||
await db.table('personas').delete(personaId) | ||
personaList.value = personaList.value.filter(p => p.id !== personaId) | ||
await updatePersonaList() | ||
} | ||
|
||
async function updatePersona(personaId: string, update: Partial<types.Persona>) { | ||
const persona = personaList.value.find(p => p.id === personaId) | ||
if (persona) { | ||
await db.table('personas').put({ ...persona, ...update }) | ||
} | ||
await updatePersonaList() | ||
} | ||
|
||
async function updatePersonaList() { | ||
personaList.value = await db.table('personas').toArray() | ||
} | ||
|
||
return { | ||
initPersonaList, | ||
personaList, | ||
createPersona, | ||
deletePersona, | ||
updatePersona, | ||
} | ||
} |
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,34 @@ | ||
<script lang="ts" setup> | ||
const { personaList } = usePersona() | ||
function onCreatePersona() {} | ||
</script> | ||
|
||
<template> | ||
<div p-4> | ||
<div | ||
font-bold font-title | ||
text-14px sm:text-22px | ||
text-color mb-2 flex items-center | ||
> | ||
<div> | ||
Personas | ||
</div> | ||
</div> | ||
<div | ||
max-h-100 overflow-y-auto overflow-x-hidden w-full p-2 | ||
rounded-2 mt-6 | ||
class="light:bg-gray-1/50 dark:bg-dark-3 dark:shadow-dark" shadow shadow-inset | ||
> | ||
{{ personaList }} | ||
</div> | ||
<div flex items-center children:grow gap-3 mt-2> | ||
<UButton | ||
secondary icon="i-tabler-plus" | ||
@click="onCreatePersona" | ||
> | ||
New persona | ||
</UButton> | ||
</div> | ||
</div> | ||
</template> |
Oops, something went wrong.