Commit Graph

350 Commits

Author SHA1 Message Date
Rich Coggins
a18c18d5e8 Update README.md with Azure OpenAI Embeddings example (#318) 2023-05-22 08:18:31 +04:00
Tom Hennessy
faae8b4b4b Update README.md (#319)
Added in `unofficial` to the README to make it clear it's not official.
2023-05-22 08:17:16 +04:00
Takahiro Ikeuchi
b62a325b0a Azure OpenAI API version 2023-05-15 (#316)
* chore(config.go): update Azure API version to 2023-05-15 to use the latest version available

* chore(api_internal_test.go): update Azure API version to 2023-05-15 to match the latest version
2023-05-19 12:04:16 -07:00
JoyShi
21eef5bc8d Move form_builder into internal pkg. (#311)
* Move form_uilder into internal pkg.

* Fix import of audio.go

* Reorganize.

* Fix import.

* Fix

---------

Co-authored-by: JoyShi <joy.shi@sap.com>
2023-05-16 13:38:09 -07:00
xuanming.zhang
83d03fca52 Adjust the azure model deployment name call corresponding to README (#309) 2023-05-14 21:29:28 -07:00
GargantuaX
be253c2d63 change azure engine config to modelMapper (#306)
* change azure engine config to azure modelMapper config

* Update go.mod

* Revert "Update go.mod"

This reverts commit 78d14c58f2a9ce668da43f6adbe20b60afcfe0d7.

* lint fix

* add test

* lint fix

* lint fix

* lint fix

* opt

* opt

* opt

* opt
2023-05-11 01:30:24 +04:00
Hoani Bryson
5f4ff3ebfa Add Readme example to example_test.go (#298)
* Add speech to text example in docs

* Add caption formats for audio transcription

* Add caption example to README

* Address sanity check errors

* Add tests for decodeResponse

* Use typechecker for audio response format

* Decoding response refactors

* Migrated examples to example_test.go

* Add some executable examples

* Update error docs

* Avoid linting example files which break conventions

* Restore README examples

* Enable linting for example_test
2023-05-08 20:16:01 +04:00
Semenchenko Kirill
39abb5a4be add missing error processing for audio (#301)
Co-authored-by: Kirill Semenchenko <smoreg@mc2soft.ru>
2023-05-04 22:30:14 +04:00
Quest Henkart
a24581dce2 maintain underlying error structs to allow for type conversion (#293)
* maintain underlying error structs to allow for type conversion and
defensive error checking

* allow Error.Is for Azure responses

* update readme, add tests to ensure type conversion

* fix whitespacing

* read me

* add import to readme example
2023-05-03 22:48:59 +04:00
Yuki Bobier
24aa2005cc test: remove httpbin dependency (#297)
Replace the use of external httpbin service in TestRequestError
with a local HTTP server using the net/http/httptest package.
This change improves test reliability by eliminating the dependency
on an external service.
2023-05-03 20:20:32 +04:00
Juan
104c0c0b63 Azure openai list models (#290)
* feat(models): include flow for azure openai endpoint

* feat(models): include flow for azure openai endpoint

* feat(models): include flow for azure openai endpoint

* chore(fullURL): update logic to run in fullURL function

* chore(fullURL): update based on pr comments to use c.config.APIVersion
2023-05-03 13:02:35 +04:00
quzard
1b8feae0b6 Do not return when not present (#294) 2023-05-02 21:41:21 +04:00
sashabaranov
af9ff51077 fix expected error message (#289) 2023-05-01 02:41:40 +04:00
xuanming.zhang
67aef196d2 Fix OpenAI or Azure returns an undefined error message return (#283)
* Fix OpenAI or Azure returns an undefined error message return

* Fix: OpenAI or Azure returns an undefined error message return
#280

* Fix: OpenAI or Azure returns an undefined error message return
#280

* Fix: OpenAI or Azure returns an undefined error message return
#280

Handle long line

* Fix: OpenAI or Azure returns an undefined error message return
#280

Add unit test ErrorResponse nil pointer check

* Fix: OpenAI or Azure returns an undefined error message return
#280

Add unit test ErrorResponse nil pointer check

---------

Co-authored-by: zhangxm <xuanming_zhang@qingsongchou.com>
2023-05-01 01:21:15 +04:00
Liu Shuang
cacd976a0c feat: RequestError print status code (#285) 2023-05-01 01:18:43 +04:00
刘丹冰
2f008f7054 fix:model param type, add moderation Model Name const. (#270)
* add ImageEditRequest.ResponseFormat

* add ImageEditRequest/ImageVariRequest.ResponseFormat

* complete image_test

* delete var prompt param

* fix:model param type, add  moderation Model Name const.

* rename ModerationText001

---------

Co-authored-by: Aceld <liudanbing@tal.com>
2023-04-20 14:10:19 +01:00
biubiu7
c2b58e77ed Fixing missing OrgId assignment issue in the ChatCompletionStream (#268)
* Update client.go

* Add test

---------

Co-authored-by: panjiajia <panjiajia@haoshuo.com>
2023-04-20 14:08:29 +01:00
Hoani Bryson
ecdea45b67 Adds support for audio captioning with Whisper (#267)
* Add speech to text example in docs

* Add caption formats for audio transcription

* Add caption example to README

* Address sanity check errors

* Add tests for decodeResponse

* Use typechecker for audio response format

* Decoding response refactors
2023-04-20 14:07:04 +01:00
Liu Shuang
d6ab1b3a4f fix: chat stream resp error (#259) 2023-04-19 13:05:00 +01:00
刘丹冰
3b10c032b6 add ImageVariRequest/ImageEditRequest.ResponseFormat (#264)
* add ImageEditRequest.ResponseFormat

* add ImageEditRequest/ImageVariRequest.ResponseFormat

* complete image_test

* delete var prompt param

---------

Co-authored-by: Aceld <liudanbing@tal.com>
2023-04-18 11:23:29 +02:00
Stephen Young
061c97ef7e Implement Unmarshaller interface. Resolves #244 (#248) 2023-04-14 20:09:40 +02:00
sashabaranov
d94c5e7edd Test request builder + streams (#242)
* test request builder + streams

* provide prompt to test
2023-04-09 18:46:58 +04:00
sashabaranov
9a1ecf5f4a Add more tests (#241)
* add form builder tests

* lint

* add client tests

* lint

* add non-existent file test
2023-04-09 18:36:15 +04:00
Rich Coggins
334ee6dbdd Update README.md with Azure OpenAI ChatGPT example (#239)
Co-authored-by: coggsflod <richard.coggins@officedepot.com>
2023-04-08 22:42:55 +04:00
sashabaranov
33ca1dac95 Add files api tests (#238)
* drop support for downloading files

* use form builder to submit files

* update doc

* add form builder tests
2023-04-08 20:13:59 +04:00
sashabaranov
4dc1edac38 add embeddings tests (#237) 2023-04-08 19:49:27 +04:00
sashabaranov
89219e31b2 Update readme (#236)
* Update readme

* update ci names
2023-04-08 19:34:03 +04:00
sashabaranov
226ff328e2 Add form builder (#235)
* add form builder

* cover VariImage

* test for closing errors

* simplify tests

* add audio api test coverage

* don't leak authToken when printed

* rename api->client

* fix test
2023-04-08 19:26:26 +04:00
harry
2f3700f4c5 to fix v1.5.8 Usage return (#223)
* add ChatCompletionStream Usage return

* ChatCompletionStreamResponse will bot return Usage

* remove the Usage field from the response, it would not be there anyway.

---------

Co-authored-by: lihang <nasa.li@deepres.com>
2023-04-04 16:10:54 +04:00
ttys3
8677fb4bb4 feat: add azure openai support (#214)
* feat: add azure openai support

* chore: refine config

* chore: make config options like the python one

* chore: adjust config struct field order

* test: fix tests

* style: make the linter happy

* fix: support Azure API Key authentication in sendRequest

* chore: check error in CreateChatCompletionStream

* chore: pass tests

* chore: try pass tests again

* chore: change ClientConfig back due to this lib does not like WithXxx config style

* chore: revert fix to CreateChatCompletionStream() due to cause tests not pass

* chore: at least add some comment about the required fields

* chore: re order ClientConfig fields

* chore: add DefaultAzure()

* chore: set default api_version the same as py one "2023-03-15-preview"

* style: fixup typo

* test: add api_internal_test.go

* style: make lint happy

* chore: add constant AzureAPIKeyHeader

* chore: use AzureAPIKeyHeader for api-key header, fix azure base url auto trim suffix /

* test: add TestAzureFullURL, TestRequestAuthHeader and TestOpenAIFullURL

* test: simplify TestRequestAuthHeader

* test: refine TestOpenAIFullURL

* chore: refine comments

* feat: DefaultAzureConfig
2023-04-04 12:05:20 +04:00
NullpointerW
bee0656174 CompletionBatchingRequestSupport (#220)
* completionBatchingRequestSupport

* lint fix

* fix Run test fail

* fix TestClientReturnsRequestBuilderErrors fail

* fix Codecov  check

* ignore TestClientReturnsRequestBuilderErrors lint

* fix lint again

* lint again*2

* replace checkPromptType  implementation

* remove nil check

---------

Co-authored-by: W <825708370@qq.com>
2023-04-03 11:05:33 +04:00
harry
b542086cbb add ChatCompletionStream Usage return (#215)
Co-authored-by: lihang <nasa.li@deepres.com>
2023-04-01 20:06:22 +04:00
rex posadas
8e3a04664e Refactor/internal testing (#194)
* added NoError check

* corrected NoError

* has error checks

* replace more checks

* Used checks test helper

* Used checks test helper

* remove duplicate import

* fixed lint issues regarding length of messages

---------

Co-authored-by: Rex Posadas <rposadas@redwoodlogistics.com>
2023-03-24 21:55:25 +04:00
rex posadas
479dab3b69 fixed typo (#196) 2023-03-23 23:18:11 +04:00
Élison Gomes
dbb7829a9f fix: added defer to close audio file (#195)
Co-authored-by: Élison Gomes <elisongomes@users.noreply.github.com>
2023-03-23 23:17:35 +04:00
Jo
2ebb265e71 refactor: Refactor endpoint and model compatibility check (#180)
* Add model check for chat stream

* Sync model checks

* Fix typo

* Fix functino

* refactor: Refactor endpoint and model compatibility check

* apply review suggestions

* minor fix

* invert return boolean flag

* fix test
2023-03-22 17:46:08 +04:00
kotaro.yamazaki
428839400a Update README.md to rename the image file created to example.png (#192) 2023-03-22 16:04:09 +04:00
sashabaranov
eb68a72bcc simplify unmarshal (#191)
* simplify unmarshal

* simplify unmarshalError

* rename errorAccumulate -> defaultErrorAccumulator

* update converage
2023-03-22 09:56:05 +04:00
Liu Shuang
a5a945ad14 fix: stream return EOF when openai return error (#184)
* fix: stream return EOF when openai return error

* perf: add error accumulator

* fix: golangci-lint

* fix: unmarshal error possibly null

* fix: error accumulator

* test: error accumulator use interface and add test code

* test: error accumulator add test code

* refactor: use stream reader to re-use stream code

* refactor: stream reader use generics
2023-03-22 09:32:47 +04:00
itegel
aa149c1bf8 add optional params for audio api, e.g. prompt (#183)
* Compatible with the situation where the mask is empty in CreateEditImage.

* Fix the test for the unnecessary removal of the mask.png file.

* add image variation implementation

* fix image variation bugs

* fix ci-lint problem with max line character limit

* add offitial doc link

* just for codeball test

* fix lint problem

* add optional params for audio api, e.g. prompt

* add comment for new args in translation
2023-03-20 14:02:19 +04:00
Ryuichi Maeda
d529d13ba1 Add readme example of ChatGPT streaming completion (#177) 2023-03-19 18:01:51 +04:00
sashabaranov
a6b35c3ab5 Check for Stream parameter usage (#174)
* check for stream:true usage

* lint
2023-03-18 19:31:54 +04:00
Felix Yan
34f3a118df Correct typos in api_test.go (#172) 2023-03-17 22:58:34 +04:00
sashabaranov
a8acb5f63b Add tests (#171)
* test models listing

* remove non-needed method

* test for .streamFinished

* add more error tests

* improve stream testing

* fix typo
2023-03-16 19:10:27 +04:00
Qihang Hu
fd44d3665e add readme exmaple: chatgpt support context (#166) 2023-03-16 10:46:18 +04:00
Constantine A
3c8be76770 Added an example of image generation using DALL-E (#168)
* add "name" property for ChatCompletionMessage

* added a comment to the "Name" property

* Added an example of image generation using DALL-E

---------

Co-authored-by: Contantine A <avdeev@embria.com>
2023-03-16 10:44:31 +04:00
sashabaranov
abffeceb71 Check for GPT-4 models (#169)
* add chat gpt4 model support (#158)

* remove check for gpt4 for CreateCompletion

* test for model check

---------

Co-authored-by: aeieli <aeliieli@gmail.com>
2023-03-16 10:43:41 +04:00
sashabaranov
c34bc77f1a Add testable request builder (#162)
* Add testable request builder

* improve tests
2023-03-15 13:16:33 +04:00
sashabaranov
53d195cf5a add testable json marshaller (#161) 2023-03-15 12:16:47 +04:00
sashabaranov
ba77a6476e Update README.md (#160) 2023-03-15 11:47:36 +04:00