Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support batches api #746

Merged
merged 20 commits into from
Jun 13, 2024
Merged

feat: support batches api #746

merged 20 commits into from
Jun 13, 2024

Conversation

eiixy
Copy link
Contributor

@eiixy eiixy commented May 17, 2024

support batches api #724

Copy link

codecov bot commented May 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.78%. Comparing base (774fc9d) to head (5f89cb3).
Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #746      +/-   ##
==========================================
+ Coverage   98.46%   98.78%   +0.32%     
==========================================
  Files          24       25       +1     
  Lines        1364     1237     -127     
==========================================
- Hits         1343     1222     -121     
+ Misses         15        9       -6     
  Partials        6        6              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@animalnots
Copy link

can this be looked into and merged, since it's quite a useful cost effective feature

@animalnots animalnots mentioned this pull request Jun 7, 2024
@sashabaranov
Copy link
Owner

@eiixy thank you so much for the PR and sorry for such a long review!

}

// CreateBatchWithUploadFile — API call to Create batch with upload file.
func (c *Client) CreateBatchWithUploadFile(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need this method. Do you think it would be used in >90% of cases when people use batches?

An alternative would be to have a README example of how to upload file and create a batch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think providing this method would reduce complexity, and I have provided an example: https://github.com/eiixy/monorepo/blob/master/example/openai/main.go

}

// ListBatch API call to List batch.
func (c *Client) ListBatch(ctx context.Context, after *string, limit *int) (response ListBatchResponse, err error) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the Pagination struct here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request parameters provided by openai are inconsistent with the Pagination structure
https://platform.openai.com/docs/api-reference/batch/list

batch.go Outdated

const BatchEndpointChatCompletions BatchEndpoint = "/v1/chat/completions"
const BatchEndpointCompletions BatchEndpoint = "/v1/completions"
const BatchEndpointEmbeddings BatchEndpoint = "/v1/embeddings"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly:

type BatchEndpoint string

const (
	BatchEndpointChatCompletions BatchEndpoint = "/v1/chat/completions"
	BatchEndpointCompletions     BatchEndpoint = "/v1/completions"
	BatchEndpointEmbeddings      BatchEndpoint = "/v1/embeddings"
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok~

@sashabaranov sashabaranov merged commit 99cc170 into sashabaranov:master Jun 13, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants