tencentcloud

package module
v0.0.0-...-20b2a55 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 5

README

Tencent Cloud Hunyuan Embedding

English | 简体中文

A Tencent Cloud Hunyuan embedding implementation for Eino that implements the Embedder interface. This enables seamless integration with Eino's embedding system for text embedding capabilities.

Features

  • Implements github.com/cloudwego/eino/components/embedding.Embedder
  • Easy integration with Eino's rag workflow
  • Built-in token usage tracking
  • Automatic batch processing for large text arrays
  • Built-in callback support

Installation

go get github.com/cloudwego/eino-ext/components/embedding/tencentcloud

Quick Start

package main

import (
    "context"
    "fmt"
    "os"
    
    "github.com/cloudwego/eino-ext/components/embedding/tencentcloud"
)

func main() {
    ctx := context.Background()
    
    // Create embedder config
    cfg := &tencentcloud.EmbeddingConfig{
        SecretID:  os.Getenv("TENCENTCLOUD_SECRET_ID"),
        SecretKey: os.Getenv("TENCENTCLOUD_SECRET_KEY"),
        Region:    "ap-guangzhou",
    }

    // Create the embedder
    embedder, err := tencentcloud.NewEmbedder(ctx, cfg)
    if err != nil {
        panic(err)
    }

    // Get embeddings for texts
    embeddings, err := embedder.EmbedStrings(ctx, []string{"hello world", "bye world"})
    if err != nil {
        panic(err)
    }

    fmt.Printf("Embeddings: %v\n", embeddings)
}

Configuration

The embedder can be configured using the EmbeddingConfig struct:

type EmbeddingConfig struct {
    SecretID  string // Tencent Cloud Secret ID
    SecretKey string // Tencent Cloud Secret Key
    Region    string // Tencent Cloud Region (e.g. "ap-hongkong")
}

Features Details

Automatic Batch Processing

The embedder automatically handles batch processing for large text arrays. According to Tencent Cloud's API limitations, each request can process up to 200 texts. The embedder will automatically split larger arrays into appropriate batches.

Token Usage Tracking

The embedder tracks token usage through Eino's callback system. Token usage information includes:

  • Prompt tokens
  • Total tokens
Callbacks Support

The embedder fully supports Eino's callback system, enabling:

  • Error tracking
  • Start/End event monitoring
  • Token usage statistics

Examples

See the examples directory for complete usage examples.

For More Details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Embedder

type Embedder struct {
	// contains filtered or unexported fields
}

Embedder is a Tencent Cloud embedding client

func NewEmbedder

func NewEmbedder(ctx context.Context, config *EmbeddingConfig) (*Embedder, error)

NewEmbedder creates a new Tencent Cloud embedding client

func (*Embedder) EmbedStrings

func (e *Embedder) EmbedStrings(ctx context.Context, texts []string, opts ...embedding.Option) (
	embeddings [][]float64, err error,
)

func (*Embedder) GetType

func (e *Embedder) GetType() string

func (*Embedder) IsCallbacksEnabled

func (e *Embedder) IsCallbacksEnabled() bool

type EmbeddingConfig

type EmbeddingConfig struct {
	SecretID  string
	SecretKey string
	Region    string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL