Commit Graph

18 Commits

Author SHA1 Message Date
Ivan Timofeev
9add1c3486 add max_completions_tokens for o1 series models (#857)
* add max_completions_tokens for o1 series models

* add validation for o1 series models validataion + beta limitations
2024-09-20 21:40:24 +01:00
Grey Baker
d86425a5cf Allow structured outputs via function calling (#828) 2024-08-16 18:41:39 +01:00
Radosław Kintzi
03caea89b7 Add support for multi part chat messages (and gpt-4-vision-preview model) (#580)
* Add support for multi part chat messages

OpenAI has recently introduced a new model called gpt-4-visual-preview,
which now supports images as input. The chat completion endpoint accepts
multi-part chat messages, where the content can be an array of structs
in addition to the usual string format.

This commit introduces new structures and constants to represent
different types of content parts. It also implements the json.Marshaler
and json.Unmarshaler interfaces on ChatCompletionMessage.

* Add ImageURLDetail and ChatMessagePartType types

* Optimize ChatCompletionMessage deserialization

* Add ErrContentFieldsMisused error
2023-11-24 17:17:00 +04:00
Ikko Eltociear Ashimine
9fefd50e12 Fix typo in chat_test.go (#564)
requetsts -> requests
2023-11-12 15:10:00 +04:00
Gabriel Burt
e3e065deb0 Add SystemFingerprint and chatMsg.ToolCallID field (#543)
* fix ToolChoiche typo

* add tool_call_id to ChatCompletionMessage

* add /chat system_fingerprint response field

* check empty ToolCallID JSON marshaling

and add omitempty for tool_call_id

* messages also required; don't omitempty

* add Type to ToolCall, required by the API

* fix test, omitempty for response_format ptr

* fix casing of role values in comments
2023-11-09 12:08:43 +04:00
Simon Klee
0664105387 lint: fix linter warnings reported by golangci-lint (#522)
- Fix #519
2023-11-07 13:23:06 +04:00
Liu Shuang
b77d01edca Support get http header and x-ratelimit-* headers (#507)
* feat: add headers to http response

* feat: support rate limit headers

* fix: go lint

* fix: test coverage

* refactor streamReader

* refactor streamReader

* refactor: NewRateLimitHeaders to newRateLimitHeaders

* refactor: RateLimitHeaders Resets filed

* refactor: move RateLimitHeaders struct
2023-10-10 19:29:41 +04:00
Simone Vellei
8e165dc9aa Feat Add headers to openai responses (#506)
* feat: add headers to http response

* chore: add test

* fix: rename to httpHeader
2023-10-09 19:41:54 +04:00
Yu
62dc817b39 feat: make finish reason nullable in json marshal (#449) 2023-07-28 13:06:48 +09:00
ryomak
9c99f3626f replace deprecated FunctionDefine in chat_test.go (#416) 2023-06-29 09:41:22 +09:00
James MacWhyte
0ca4ea4867 move json schema to directory/package (#407)
* move json schema to directory/package

* added jsonschema to README
2023-06-24 20:22:11 +04:00
Chris Hua
f22da8a7ed feat: allow more input types to functions, fix tests (#377)
* feat: use json.rawMessage, test functions

* chore: lint

* fix: tests

the ChatCompletion mock server doesn't actually run otherwise. N=0
is the default request but the server will treat it as n=1

* fix: tests should default to n=1 completions

* chore: add back removed interfaces, custom marshal

* chore: lint

* chore: lint

* chore: add some tests

* chore: appease lint

* clean up JSON schema + tests

* chore: lint

* feat: remove backwards compatible functions

for illustrative purposes

* fix: revert params change

* chore: use interface{}

* chore: add test

* chore: add back FunctionDefine

* chore: /s/interface{}/any

* chore: add back jsonschemadefinition

* chore: testcov

* chore: lint

* chore: remove pointers

* chore: update comment

* chore: address CR

added test for compatibility as well

---------

Co-authored-by: James <jmacwhyte@MacBooger-II.local>
2023-06-21 16:58:27 +04:00
Rich Coggins
646989cc5b Improve (#356) to support registration of wildcard URLs (#359)
* Improve (#356) to support registration of wildcard URLs

* Add TestAzureChatCompletions & TestAzureChatCompletionsWithCustomDeploymentName

* Remove TestAzureChatCompletionsWithCustomDeploymentName

---------

Co-authored-by: coggsflod <richard.coggins@officedepot.com>
2023-06-14 18:19:18 +04:00
渡邉祐一 / Yuichi Watanabe
b616090e69 refactoring tests with mock servers (#30) (#356) 2023-06-12 17:40:26 +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
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
sashabaranov
a6b35c3ab5 Check for Stream parameter usage (#174)
* check for stream:true usage

* lint
2023-03-18 19:31:54 +04:00
sashabaranov
34e1e10b5f add chatgpt logic tests (#135)
* add chatgpt logic tests

* lint
2023-03-08 19:50:41 +04:00