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: add method convert str to embedding model enum #504

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

warjiang
Copy link

Describe the change
Use go-openai as part of my application, params passed to application may be string, but there is no method to convert model name to enum for embedding, so i add this helper method for convenient.

Describe your solution
Reuse the implementation of stringToEnum. If the target mapping is found in the stringToEnum mapping, use it directly. Otherwise, return the Unknown enumeration type.

Tests
ConvertStr2EmbeddingModel("text-embedding-ada-002") should return AdaEmbeddingV2

Additional context
Nop

Issue: #503

@codecov
Copy link

codecov bot commented Sep 29, 2023

Codecov Report

Merging #504 (d55b3d9) into master (0d5256f) will decrease coverage by 0.58%.
The diff coverage is 44.44%.

@@            Coverage Diff             @@
##           master     #504      +/-   ##
==========================================
- Coverage   97.46%   96.88%   -0.58%     
==========================================
  Files          18       18              
  Lines         827      835       +8     
==========================================
+ Hits          806      809       +3     
- Misses         15       20       +5     
  Partials        6        6              
Files Coverage Δ
embeddings.go 93.97% <44.44%> (-6.03%) ⬇️

@vvatanabe
Copy link
Collaborator

@warjiang How about the following approach?
#503 (comment)

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.

None yet

2 participants