Commit Graph

296 Commits

Author SHA1 Message Date
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
xuanming.zhang
c9615e0cbe Added support for createImage Azure models (#608) 2024-01-03 17:42:57 +06:00
mikeb26
a09cb0c528 Add completion-with-tool example (#598)
As a user of this go SDK it was not immediately intuitive to me how to
correctly utilize the function calling capability of GPT4
(https://platform.openai.com/docs/guides/function-calling). While the
aformentioned link provides a helpful example written in python, I
initially tripped over how to correclty translate the specification of
function arguments when usingthis go SDK.

To make it easier for others in the future this commit adds a
completion-with-tool example showing how to correctly utilize the
function calling capability of GPT4 using this SDK end-to-end in a
CreateChatCompletion() sequence.
2023-11-26 12:45:28 +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
Alexander Baranov
7260991327 Update PULL_REQUEST_TEMPLATE.md (#606) 2023-11-24 13:36:10 +04:00
pjuhasz
f87909596f Add canary-tts to speech models (#603)
Co-authored-by: Peter Juhasz <juhasz.peter@uhusystems.com>
2023-11-24 11:34:25 +04:00
Albert Putra Purnama
a130cfee26 Add missing response fields for pagination (#584) 2023-11-18 11:01:06 +04:00
Albert Putra Purnama
9efad284d0 Updates the tool call struct (#595) 2023-11-18 10:59:01 +04:00
Charlie Revett
4fd904c292 Add File purposes as constants (#577)
* Add purposes.

* Formatting.
2023-11-18 10:55:58 +04:00
Charlie Revett
18465723f7 Add missing struct properties. (#579) 2023-11-15 20:25:18 +04:00
Ccheers
3220f19ee2 feat(runapi): add RunStepList response args https://platform.openai.com/docs/api-reference/runs/listRunSteps (#573) 2023-11-15 20:23:41 +04:00
Liron Levin
464b85b6d7 Pagination fields are missing from assistants list beta API (#571)
curl "https://api.openai.com/v1/assistants?order=desc&limit=20" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "OpenAI-Beta: assistants=v1"
{
  "object": "list",
  "data": [],
  "first_id": null,
  "last_id": null,
  "has_more": false
}
2023-11-15 20:22:39 +04:00
Donnie Flood
71848ccf69 feat: support direct bytes for file upload (#568)
* feat: support direct bytes for file upload

* add test for errors

* add coverage
2023-11-15 20:08:48 +04:00
Donnie Flood
fe67abb97e fix: add beta assistant header to CreateMessage call (#566) 2023-11-15 20:06:57 +04:00
Chris Hua
515de0219d feat: initial TTS support (#528)
* feat: initial TTS support

* chore: lint, omitempty

* chore: dont use pointer in struct

* fix: add mocked server tests to speech_test.go

Co-authored-by: Lachlan Laycock <supagroova@gmail.com>

* chore: update imports

* chore: fix lint

* chore: add an error check

* chore: ignore lint

* chore: add error checks in package

* chore: add test

* chore: fix test

---------

Co-authored-by: Lachlan Laycock <supagroova@gmail.com>
2023-11-13 18:35:34 +04:00
Urjit Singh Bhatia
b7cac703ac Feat/messages api (#546)
* fix test server setup:
- go map access is not deterministic
- this can lead to a route: /foo/bar/1 matching /foo/bar before matching /foo/bar/1 if the map iteration go through /foo/bar first since the regex match wasn't bound to start and end anchors
- registering handlers now converts * in routes to .* for proper regex matching
- test server route handling now tries to fully match the handler route

* add missing /v1 prefix to fine-tuning job cancel test server handler

* add create message call

* add messages list call

* add get message call

* add modify message call, fix return types for other message calls

* add message file retrieve call

* add list message files call

* code style fixes

* add test for list messages with pagination options

* add beta header to msg calls now that #545 is merged

* Update messages.go

Co-authored-by: Simone Vellei <henomis@gmail.com>

* Update messages.go

Co-authored-by: Simone Vellei <henomis@gmail.com>

* add missing object details for message, fix tests

* fix merge formatting

* minor style fixes

---------

Co-authored-by: Simone Vellei <henomis@gmail.com>
2023-11-13 18:33:26 +04:00
Ikko Eltociear Ashimine
9fefd50e12 Fix typo in chat_test.go (#564)
requetsts -> requests
2023-11-12 15:10:00 +04:00
Kyle Bolton
35495ccd36 Add json:"metadata,omitempty" to RunRequest struct (#561)
Metadata is an optional field per the api spec
https://platform.openai.com/docs/api-reference/runs/createRun
2023-11-12 15:09:40 +04:00
Simone Vellei
d6f3bdcdac Feat implement Run APIs (#560)
* chore: first commit

* add apis

* chore: add tests

* feat add apis

* chore: add api and tests

* chore: add tests

* fix

* trigger build

* fix

* chore: formatting code

* chore: add pagination type
2023-11-09 23:17:30 +04:00
Simone Vellei
78862a2798 fix: add missing fields in tool_calls (#558) 2023-11-09 18:05:03 +04:00
Urjit Singh Bhatia
8127072553 fix test server setup: (#549)
* fix test server setup:
- go map access is not deterministic
- this can lead to a route: /foo/bar/1 matching /foo/bar before matching /foo/bar/1 if the map iteration go through /foo/bar first since the regex match wasn't bound to start and end anchors
- registering handlers now converts * in routes to .* for proper regex matching
- test server route handling now tries to fully match the handler route

* add missing /v1 prefix to fine-tuning job cancel test server handler
2023-11-09 12:20:39 +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
bc89139c1d Feat Implement threads API (#536)
* feat: implement threads API

* fix

* add tests

* fix

* trigger£

* trigger

* chore: add beta header
2023-11-09 12:05:44 +04:00
渡邉祐一 / Yuichi Watanabe
08c167fecf test: fix compile error in api integration test (#548) 2023-11-08 13:21:51 +04:00
Simone Vellei
a2d2bf6851 Fix Refactor assistant api (#545)
* fix: refactor assistant API

* fix

* trigger build

* fix: use AssistantDeleteResponse
2023-11-08 13:20:20 +04:00
Mike Cutalo
a0159ad2b0 Support new fields for /v1/images/generation API (#530)
* add support for new image/generation api

* fix one lint

* add revised_prompt to response

* fix lints

* add CreateImageQualityStandard
2023-11-08 16:16:22 +09: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
3063e676bf Feat Implement assistants API (#535)
* chore: implement assistants API

* fix

* fix

* chore: add tests

* fix tests

* fix linting
2023-11-07 19:20:59 +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
Carson Kahn
d07833e19b Doc ways to improve reproducability besides Temp (#532) 2023-11-07 13:27:29 +04:00
Simon Klee
0664105387 lint: fix linter warnings reported by golangci-lint (#522)
- Fix #519
2023-11-07 13:23:06 +04:00
Eli Bendersky
9e0232f941 Fix typo in README: AdaEmbeddingV2 (#516)
Copy-pasting the old sample caused compilation errors
2023-11-07 00:27:08 +04:00
Simon Klee
6c52952b69 feat(completion): add constants for new GPT models (#520)
Added constants for new GPT models including `gpt-4-1106-preview`,
`gpt-4-vision-preview` and `gpt-3.5-turbo-1106`.

The models were announced in the following blog post: https://openai.com/blog/new-models-and-developer-products-announced-at-devday
2023-11-07 00:22:48 +04:00
Alexander Baranov
c47ddfc1a1 Update README.md (#511) 2023-10-10 21:22:45 +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
Simone Vellei
533935e4fc fix: use any for n_epochs (#499)
* fix: use custom marshaler for n_epochs

* chore: use any for n_epochs
2023-10-06 13:32:21 +04:00
e. alvarez
84f77a0acd Add DotProduct Method and README Example for Embedding Similarity Search (#492)
* Add DotProduct Method and README Example for Embedding Similarity Search

- Implement a DotProduct() method for the Embedding struct to calculate the dot product between two embeddings.
- Add a custom error type for vector length mismatch.
- Update README.md with a complete example demonstrating how to perform an embedding similarity search for user queries.
- Add unit tests to validate the new DotProduct() method and error handling.

* Update README to focus on Embedding Semantic Similarity
2023-10-02 18:39:10 +04:00
Brendan Martin
0d5256fb82 added delete fine tune model endpoint (#497) 2023-09-25 12:08:45 +04:00
Simone Vellei
8e4b7963a3 Chore Support base64 embedding format (#485)
* chore: support base64 embedding format

* fix: add sizeOfFloat32

* chore: refactor base64 decoding

* chore: add tests

* fix linting

* fix test

* fix return error

* fix: use smaller slice for tests

* fix [skip ci]

* chore: refactor test to consider CreateEmbeddings response

* trigger build

* chore: remove named returns

* chore: refactor code to simplify the understanding

* chore: tests have been refactored to match the encoding format passed by request

* chore: fix tests

* fix

* fix
2023-09-11 17:44:46 +04:00
NullpointerW
3589837b22 Update OpenAPI file return struct (#486)
* 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

* update file return struct

---------

Co-authored-by: W <825708370@qq.com>
2023-09-07 14:52:47 +04:00
Simone Vellei
25da859c18 Chore Deprecate legacy fine tunes API (#484)
* chore: add deprecation message

* chore: use new fine tuning API in README example
2023-08-31 14:14:39 +04:00
Simone Vellei
a2ca01bb6d feat: implement new fine tuning job API (#479)
* feat: implement new fine tuning job API

* fix: export ListFineTuningJobEventsParameter

* fix: lint errors

* fix: test errors

* fix: code test coverage

* fix: code test coverage

* fix: use any

* chore: use url.Values
2023-08-29 16:04:27 +04:00
渡邉祐一 / Yuichi Watanabe
a14bc103f4 docs: Add Contributing Guidelines (#463) 2023-08-09 13:07:14 +09:00
ZeroDeng
34569895f6 Compatible with the 2023-07-01-preview API interface of Azure Openai, when content interception is triggered, the error message will contain innererror (#460)
* Compatible with Azure Openai's 2023-07-01-preview version API interface about the error information returned by the intercepted interface

* Compatible with the 2023-07-01-preview API interface of Azure Openai, when content interception is triggered, the error message will contain innererror.InnerError struct is only valid for Azure OpenAI Service.
2023-08-09 13:05:39 +09:00
渡邉祐一 / Yuichi Watanabe
71a24931db docs: add Frequently Asked Questions to README.md (#462)
* docs: add Frequently Asked Questions to README.md

* Update README.md

Co-authored-by: Alexander Baranov <677093+sashabaranov@users.noreply.github.com>

---------

Co-authored-by: Alexander Baranov <677093+sashabaranov@users.noreply.github.com>
2023-07-31 04:58:49 +09: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