feat: add embeddings API + OpenAI/OpenAI-compat#127
feat: add embeddings API + OpenAI/OpenAI-compat#127evanmschultz wants to merge 4 commits intocharmbracelet:mainfrom
Conversation
|
Addresses issue #122 |
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestValidateEmbeddingCall(t *testing.T) { |
There was a problem hiding this comment.
For tests, especially when introducing new APIs, Fantasy uses charm.land/x/vcr to record requests & replay real data.
See https://github.com/charmbracelet/fantasy/tree/main/providertests/testdata/TestOpenAICommon/openai-o4-mini for example
I've got some captures for embeddings already done: cbca0e5#diff-2599f9d193307dc4e06a66ec239c05f98fdf3ee32363d9eb3ece3ca18256f79c
There was a problem hiding this comment.
Added VCR provider tests + captures.
embedding_test.go
Outdated
| t.Run("rejects both input and inputs", func(t *testing.T) { | ||
| input := "hello" | ||
| err := ValidateEmbeddingCall(EmbeddingCall{ | ||
| Input: &input, | ||
| Inputs: []string{"world"}, | ||
| }) | ||
| require.Error(t, err) | ||
| }) |
There was a problem hiding this comment.
It doesn't feel very intuitive to have runtime errors from this can throw an error. I wonder if exposing just Inputs would be good enough since inputs can have just 1 input. Or maybe prepending input into inputs. .
There was a problem hiding this comment.
EmbeddingCall now uses Inputs only.
|
Updated this PR to address review feedback:
Also merged latest
|
e3a1abf to
d1be510
Compare
|
@acheong08 |
Embedding Support
Summary:
Note:
I’m sorry I didn’t wait for a maintainer-approved discussion before opening this PR. I needed to use embeddings in a dependent project right now, and figured coming back to make changes would be less work than making my own dedicated thing that would then be replaced by this!
I am more than happy to make any changes to better meet your desired/needed scope, or design preferences. Please let me know if you want me to make any changes or even if embeddings are out of scope for Fantasy!
Thanks for maintaining this project! It is like living in a new world not needed dozen's of SDK's. lol