-
Notifications
You must be signed in to change notification settings - Fork 3
/
client.go
31 lines (27 loc) · 937 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package vertexai
import (
"context"
"net/http"
)
// Client is the interface for the Vertex AI client for PaLM
type Client interface {
TextGeneration(ctx context.Context, req TextGenerationRequest) (*TextGenerationResponse, error)
ChatGeneration(ctx context.Context, req ChatGenerationRequest) (*ChatGenerationResponse, error)
TextEmbedding(ctx context.Context, req TextEmbeddingRequest) (*TextEmbeddingResponse, error)
}
type client struct {
clientConfig clientConfig
requestBuilder requestBuilder
httpClient httpClient
tokenizer tokenizer
}
// New creates a new client for the Vertex AI client for PaLM
// key is the oauth key of the Google Service account for authentication
func New(key string) (Client, error) {
return &client{
clientConfig: newClientConfig(setAuthToken(key)),
requestBuilder: newRequestBuilder(),
httpClient: http.DefaultClient,
tokenizer: &defaultTokenizer{},
}, nil
}