client

package
v1.59.5 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT

* ChatCLI - Command Line Interface for LLM interaction * Copyright (c) 2024 Edilson Freitas * License: MIT

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InstrumentedClient added in v1.57.1

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

InstrumentedClient wraps an LLMClient and records metrics for each call.

func NewInstrumentedClient added in v1.57.1

func NewInstrumentedClient(inner LLMClient, recorder MetricsRecorder, provider string) *InstrumentedClient

NewInstrumentedClient creates a new metrics-recording wrapper around an LLMClient.

func (*InstrumentedClient) GetModelName added in v1.57.1

func (c *InstrumentedClient) GetModelName() string

GetModelName delegates to the inner client.

func (*InstrumentedClient) SendPrompt added in v1.57.1

func (c *InstrumentedClient) SendPrompt(ctx context.Context, prompt string, history []models.Message, maxTokens int) (string, error)

SendPrompt delegates to the inner client and records metrics.

type LLMClient

type LLMClient interface {
	// GetModelName retorna o nome do modelo de linguagem utilizado pelo cliente.
	GetModelName() string

	// SendPrompt envia um prompt para o modelo de linguagem e retorna a resposta.
	// O contexto (ctx) pode ser usado para controlar o tempo de execução e cancelamento.
	// O histórico (history) contém as mensagens anteriores da conversa.
	// Retorna uma string com a resposta do modelo e um erro, caso ocorra.
	SendPrompt(ctx context.Context, prompt string, history []models.Message, maxTokens int) (string, error)
}

LLMClient define os métodos que um cliente LLM deve implementar

type LLMError

type LLMError struct {
	Code    int
	Message string
}

LLMError representa um erro personalizado para o cliente LLM

func (*LLMError) Error

func (e *LLMError) Error() string

Error implementa a interface de erro para LLMError

type MetricsRecorder added in v1.57.1

type MetricsRecorder interface {
	RecordRequest(provider, model, status string, duration time.Duration)
	RecordError(provider, model, errorType string)
}

MetricsRecorder is the interface for recording LLM call metrics. Implemented by the server-side metrics adapter to avoid importing metrics/ here.

type MockLLMClient

type MockLLMClient struct {
	Response string
	Err      error
}

MockLLMClient é um mock que implementa a interface LLMClient

func (*MockLLMClient) GetModelName

func (m *MockLLMClient) GetModelName() string

func (*MockLLMClient) SendPrompt

func (m *MockLLMClient) SendPrompt(ctx context.Context, prompt string, history []models.Message, maxTokens int) (string, error)

Jump to

Keyboard shortcuts

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