-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[openai] Types match all minor versions
- Loading branch information
1 parent
78e4dcd
commit c2221f1
Showing
7 changed files
with
45 additions
and
23 deletions.
There are no files selected for viewing
23 changes: 0 additions & 23 deletions
23
definitions/npm/openai_v3.3.x/flow_v0.83.x-v0.200.x/test_openai_v3.3.x.js
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
definitions/npm/openai_v3.x.x/flow_v0.83.x-v0.200.x/test_openai_v3.x.x.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// @flow | ||
import { describe, it } from 'flow-typed-test'; | ||
import { Configuration, OpenAIApi } from 'openai'; | ||
|
||
describe('openai', () => { | ||
let openAIApi: OpenAIApi; | ||
|
||
it('constructs client', () => { | ||
const apiKey = "secret"; | ||
const configuration = new Configuration({ apiKey }); | ||
openAIApi = new OpenAIApi(configuration); | ||
|
||
// $FlowExpectedError[incompatible-call] valid configuration required | ||
const invalidConfiguration = new OpenAIApi({wrong: "type"}); | ||
|
||
// $FlowExpectedError[incompatible-call] string required | ||
const invalidApiKey = new OpenAIApi({apiKey: 1234}); | ||
}); | ||
|
||
it('constructs client with async api key', () => { | ||
const apiKey = Promise.resolve("secret"); | ||
const configuration = new Configuration({ apiKey }); | ||
openAIApi = new OpenAIApi(configuration); | ||
|
||
// $FlowExpectedError[incompatible-call] string required | ||
const invalidApiKey = new OpenAIApi({apiKey: Promise.resolve(1234)}); | ||
}); | ||
|
||
it('creates answer', () => { | ||
// $FlowExpectedError[prop-missing] requires model, question, examples, examples_context | ||
openAIApi.createAnswer({}); | ||
|
||
openAIApi.createAnswer({model: "davinci", question: "Who won the NBA championship in 2023?", examples:[], examples_context: "I am a basketball bot."}); | ||
}); | ||
|
||
it('creates chat completion', () => { | ||
openAIApi.createChatCompletion({model: "gpt-3.5-turbo", messages: [], functions: [{name: "hello-world"}]}); | ||
|
||
// $FlowExpectedError[prop-missing] requires role | ||
openAIApi.createChatCompletion({model: "gpt-3.5-turbo", messages: [{}]}); | ||
|
||
// $FlowExpectedError[prop-missing] requires messages | ||
openAIApi.createChatCompletion({model: "incomplete-request"}); | ||
}); | ||
}); |