Skip to content

useCompletion ​

シングルターンのテキスト生成で、結果は 1 つの文字列にストリーミングされます。

vue
<script setup lang="ts">
import { useCompletion } from 'vue-llm'

const { completion, input, handleSubmit, isLoading, stop } = useCompletion({
  provider: ai,
  model: 'gpt-4o-mini',
  system: 'You write concise product descriptions.',
})
</script>

<template>
  <form @submit.prevent="handleSubmit">
    <input v-model="input" placeholder="Product name">
  </form>
  <p>{{ completion }}</p>
</template>

complete(prompt?) は全文で解決されます。

ts
const text = await complete('Describe a mechanical keyboard')

オプション ​

オプション型説明
providerLLMProvider必須
modelstring必須
systemMaybeRefOrGetter<string>システムプロンプト
onFinish(completion, { finishReason, usage }) => void完了時に呼ばれる
onError(error) => voidエラーハンドラー

戻り値 ​

completion、input、status、error、isLoading、complete(prompt?)、handleSubmit(event?)、stop()、clearError()。

MIT ライセンスの下で公開されています。