Gage-Technologies / tei-go

Golang client for Huggingface's Text Embedding Inference server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:Apache License 2.0


Languages

Language:Go 94.8%Language:Shell 5.2%