Skip to content

Golang client for Huggingface's Text Embedding Inference server

License

Notifications You must be signed in to change notification settings

Gage-Technologies/tei-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TEI (Text Embeddings Inference) Go Client

Go Report Card License

Overview

This client library is designed for Go developers who want to interact with the Text Embeddings Inference server. It handles the underlying HTTP requests and offers a simple API for embedding text.

Table of Contents

Installation

To install the package, you can run:

go get github.com/gage-technologies/tei-go

Usage

Here's a simple example to demonstrate how to use this library:

import "github.com/gage-technologies/tei-go/tei"

func main() {
	client := tei.NewClient("http://localhost:8080", nil, nil, time.Second*30)
	res, err := client.Embed("Hi there!", false)
	if err != nil {
		panic(err)
	}
	fmt.Println("Embedding: ", res[0])
}

Features

Timeouts

The client allows you to specify a timeout for HTTP requests.

Custom Headers

You can specify custom headers when creating a new client:

headers := map[string]string{"Authorization": "Bearer token"}
client := tei.NewClient("http://localhost:8080", headers, nil, time.Second*30)

Cookies

You can also specify cookies when creating a new client:

cookies := map[string]string{"session_id": "abc123"}
client := tei.NewClient("http://localhost:8080", nil, cookies, time.Second*30)

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details

About

Golang client for Huggingface's Text Embedding Inference server

Resources

License

Stars

Watchers

Forks

Packages

No packages published