@@ -2,11 +2,11 @@ package mistral
2
2
3
3
import (
4
4
// Packages
5
- "github.com/mutablelogic/go-client/pkg/client"
5
+ client "github.com/mutablelogic/go-client/pkg/client"
6
+ schema "github.com/mutablelogic/go-client/pkg/openai/schema"
6
7
7
8
// Namespace imports
8
9
. "github.com/djthorpe/go-errors"
9
- . "github.com/mutablelogic/go-client/pkg/openai/schema"
10
10
)
11
11
12
12
///////////////////////////////////////////////////////////////////////////////
@@ -19,12 +19,23 @@ type reqCreateEmbedding struct {
19
19
EncodingFormat string `json:"encoding_format,omitempty"`
20
20
}
21
21
22
+ ///////////////////////////////////////////////////////////////////////////////
23
+ // GLOBALS
24
+
25
+ const (
26
+ defaultEmbeddingModel = "mistral-embed"
27
+ )
28
+
22
29
///////////////////////////////////////////////////////////////////////////////
23
30
// API CALLS
24
31
25
32
// CreateEmbedding creates an embedding from a string or array of strings
26
- func (c * Client ) CreateEmbedding (content any ) (Embeddings , error ) {
33
+ func (c * Client ) CreateEmbedding (content any ) (schema. Embeddings , error ) {
27
34
var request reqCreateEmbedding
35
+ var response schema.Embeddings
36
+
37
+ // Set default model
38
+ request .Model = defaultEmbeddingModel
28
39
29
40
// Set the input, which is either a string or array of strings
30
41
switch v := content .(type ) {
@@ -33,15 +44,14 @@ func (c *Client) CreateEmbedding(content any) (Embeddings, error) {
33
44
case []string :
34
45
request .Input = v
35
46
default :
36
- return Embeddings {} , ErrBadParameter
47
+ return response , ErrBadParameter
37
48
}
38
49
39
- // Return the response
40
- var response Embeddings
50
+ // Request->Response
41
51
if payload , err := client .NewJSONRequest (request , client .ContentTypeJson ); err != nil {
42
- return Embeddings {} , err
52
+ return response , err
43
53
} else if err := c .Do (payload .Post (), & response , client .OptPath ("embeddings" )); err != nil {
44
- return Embeddings {} , err
54
+ return response , err
45
55
}
46
56
47
57
// Return success
0 commit comments