Commit Graph

48 Commits

Author SHA1 Message Date
saileshd1402
45aa99607b Make "Content" field in "ChatCompletionMessage" omitempty (#926) 2025-01-31 19:05:29 +00:00
Trevor Creech
9823a8bbbd Chat Completion API: add ReasoningEffort and new o1 models (#928)
* add reasoning_effort param

* add o1 model

* fix lint
2025-01-31 18:57:57 +00:00
Tim Misiak
af5355f5b1 Fix ID field to be optional (#911)
The ID field is not always present for streaming responses. Without omitempty, the entire ToolCall struct will be missing.
2024-12-08 13:12:05 +00:00
Sander Mack-Crane
9fe2c6ce1f Completion API: add Store and Metadata parameters (#878) 2024-10-15 21:16:57 +01:00
Julio Martins
7c145ebb4b add jailbreak filter result, add ContentFilterResults on output (#864)
* add jailbreak filter result

* add content filter results on completion output

* add profanity content filter
2024-10-03 20:19:48 +01:00
Winston Liu
bac7d59361 fix MaxCompletionTokens typo (#862)
* fix spelling error

* fix lint

* Update chat.go

* Update chat.go
2024-10-03 20:17:16 +01:00
Alex Philipp
7f80303cc3 Fix max_completion_tokens (#860)
The json tag is incorrect, and results in an error from the API when using the o1 model.  

I didn't modify the struct field name to maintain compatibility if anyone else had started using it, but it wouldn't work for them either.
2024-09-26 13:26:22 +03:00
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
Quest Henkart
194a03e763 Add refusal (#844)
* add custom marshaller, documentation and isolate tests

* fix linter

* add missing field
2024-09-11 21:24:49 +01:00
eiixy
a3bd2569ac Improve handling of JSON Schema in OpenAI API Response Context (#819)
* feat: add jsonschema.Validate and jsonschema.Unmarshal

* fix Sanity check

* remove slices.Contains

* fix Sanity check

* add SchemaWrapper

* update api_integration_test.go

* update method 'reflectSchema' to support 'omitempty' in JSON tag

* add GenerateSchemaForType

* update json_test.go

* update `Warp` to `Wrap`

* fix Sanity check

* fix Sanity check

* update api_internal_test.go

* update README.md

* update README.md

* remove jsonschema.SchemaWrapper

* remove jsonschema.SchemaWrapper

* fix Sanity check

* optimize code formatting
2024-08-24 18:06:08 +01:00
Grey Baker
d86425a5cf Allow structured outputs via function calling (#828) 2024-08-16 18:41:39 +01:00
eiixy
dd7f5824f9 fix: fullURL endpoint generation (#817) 2024-08-16 18:11:38 +01:00
Tyler Gannon
6439e1fcc9 Make reponse format JSONSchema optional (#820) 2024-08-07 20:40:45 +01:00
eiixy
623074c14a feat: Support Structured Outputs (#813)
* feat: Support Structured Outputs

* feat: Support Structured Outputs

* update imports

* add integration test

* update JSON schema comments
2024-08-07 14:47:48 +01:00
Luca Giannini
727944c478 feat: ParallelToolCalls to ChatCompletionRequest with helper functions (#787)
* added ParallelToolCalls to ChatCompletionRequest with helper functions

* added tests for coverage

* changed ParallelToolCalls to any
2024-07-12 11:31:11 +01:00
Liu Shuang
6af32202d1 feat: support stream_options (#736)
* feat: support stream_options

* fix lint

* fix lint
2024-05-07 16:42:24 +04:00
CaoPengFlying
e8b347891b fix:fix open ai original validation. modify Tool's Function to pointer (#664)
Co-authored-by: caopengfei1 <caopengfei1@tal.com>
2024-02-19 16:26:04 +04:00
Danai Antoniou
f10955ce09 Log probabilities for chat completion output tokens (#625)
* Add logprobs

* Logprobs pointer

* Move toplogporbs

* Create toplogprobs struct

* Remove pointers
2024-01-09 20:50:56 +04: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
Simone Vellei
78862a2798 fix: add missing fields in tool_calls (#558) 2023-11-09 18:05:03 +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
Simone Vellei
a20eb08b79 fix: use pointer for ChatCompletionResponseFormat (#544) 2023-11-08 06:30:05 +09:00
Simone Vellei
1ad6b6f53d Feat Support tools and tools choice new fileds (#526)
* feat: support tools and tools choice new fileds

* fix: use value not pointers
2023-11-07 19:53:24 +04:00
Simone Vellei
6d9c3a6365 Feat Support chat completion response format and seed new fields (#525)
* feat: support chat completion response format

* fix linting error

* fix

* fix linting

* Revert "fix linting"

This reverts commit 015c6ad62aad561218b693225f58670b5619dba8.

* Revert "fix"

This reverts commit 7b2ffe28c3e586b629d23479ec1728bf52f0c66f.

* Revert "fix linting error"

This reverts commit 29960423784e296cb6d22c5db8f8ccf00cac59fd.

* chore: add seed new parameter

* fix
2023-11-07 18:25:21 +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
ZeroDeng
1153eb2595 Add support for azure openai new version API (2023-07-01-preview) (#451) 2023-07-20 19:25:58 +03:00
Savannah Ostrowski
1876e0c207 update to json.RawMessage (#441) 2023-07-15 13:33:55 +09:00
渡邉祐一 / Yuichi Watanabe
181fc2ade9 docs: explanation about LogitBias. (129) (#426) 2023-07-09 12:11:39 +03: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
渡邉祐一 / Yuichi Watanabe
f1b66967a4 refactor: refactoring http request creation and sending (#395)
* refactoring http request creation and sending

* fix lint error

* increase the test coverage of client.go

* refactor: Change the style of HTTPRequestBuilder.Build func to one-argument-per-line.
2023-06-22 13:57:52 +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
Alex Wormuth
ac25f318ba add items, which is required for array type (#373)
* add items, which is required for array type

* use JSONSchemaDefine directly
2023-06-16 17:11:50 +04:00
Ccheers
2bd65aa720 feat(chat): support function call api (#369)
* feat(chat): support function call api

* rename struct & add const ChatMessageRoleFunction
2023-06-15 12:49:54 +04:00
渡邉祐一 / Yuichi Watanabe
61ba5f3369 move request_builder into internal pkg (#304) (#329)
* move request_builder into internal pkg (#304)

* add some test for internal.RequestBuilder

* add a test for openai.GetEngine
2023-05-31 12:01:42 +04: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
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
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
Constantine A
c5fe8742cc add "name" property for ChatCompletionMessage (#123) 2023-03-06 10:52:56 +04:00
Alexander Baranov
9eea94730a rename internally 2023-03-04 15:29:42 +04:00
fishcg
d1a81205bf Add chat message role const (#111) 2023-03-03 13:07:09 +04:00
Afeyer
39ca4e9488 Implement chat completion streaming (#101)
* Implement chat completion streaming

* Optimize the implementation of chat completion stream

* Fix linter error
2023-03-03 09:52:02 +04:00
bestgopher
58d99eb220 refactor: use http.NewRequestWithContext instead of http.NewRequest (#97) 2023-03-02 10:27:09 +04:00
Parham Negahdar
de9a632138 Add the rest of the Chat Completion fields (#92)
Per https://platform.openai.com/docs/api-reference/chat/create
2023-03-02 10:06:24 +04:00
sashabaranov
c8261c5638 Add chat completions (#90) 2023-03-02 00:47:25 +04:00