Skip to content

Commit 6d2842e

Browse files
committed
feat: add system prompt command
1 parent 6b32fb7 commit 6d2842e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

app/stores/assistant.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const useAssistantStore = defineStore('assistant', () => {
2+
const system = ref('')
3+
4+
return {
5+
system,
6+
}
7+
})

app/utils/assistant.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
interface DefineSystemPromptOptions {
2+
system: MaybeRef<string> | (() => Promise<MaybeRef<string>>)
3+
}
4+
5+
export function defineAssistantContext(options: DefineSystemPromptOptions) {
6+
const store = storeToRefs(useAssistantStore())
7+
const system = typeof options.system === 'function' ? options.system() : Promise.resolve(options.system)
8+
9+
async function setup() {
10+
store.system.value = unref(await system)
11+
}
12+
13+
setup()
14+
}

0 commit comments

Comments
 (0)