I was following rather a complex tutorial https://github.com/tierrun/tier-vercel-openai/blob/main/src/components/app/GenerateSection.tsx but couldn't confirm if the onFinish
is working as expected.
So now I'm doing a simple logging check using onFinish
.
const {
completion,
setCompletion,
input,
setInput,
isLoading,
handleInputChange,
handleSubmit,
} = useCompletion({
api: "/api/generate2",
body: {
model: "gpt-4",
},
onFinish: (input: string, completion: string) => {
console.log(`input: ${input}, completion: ${completion}`);
}});
The code above successfully generates the completion
and I can render it through html, however, even after the completion, this simple console.log using onFinish
isn't working.
Can someone point out how to verify onFinish
is actually working?