Skip to content

Instantly share code, notes, and snippets.

@GuillaumeDaviid
Last active October 13, 2023 09:02
Show Gist options
  • Save GuillaumeDaviid/9eae2d0099f6409f157f30a75b9abc4e to your computer and use it in GitHub Desktop.
Save GuillaumeDaviid/9eae2d0099f6409f157f30a75b9abc4e to your computer and use it in GitHub Desktop.
methode openai
getDataFromOpenAI(text: string): Observable<string> {
return from(this.openai.createCompletion({
model: "text-davinci-003",
prompt: text,
max_tokens: 7
})).pipe(
filter(resp => !!resp && !!resp.data),
map(resp => resp.data),
filter((data: any) => data.choices && data.choices.length > 0 && data.choices[0].text),
map(data => data.choices[0].text)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment