Last active
October 13, 2023 09:02
-
-
Save GuillaumeDaviid/9eae2d0099f6409f157f30a75b9abc4e to your computer and use it in GitHub Desktop.
methode openai
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
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