llm

package
v0.1.59 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package llm contains Core's LLM abstraction. Provider-specific model clients and API keys belong outside Core; Core can either receive an injected Client or call a generic internal completion endpoint through RemoteClient.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Complete(ctx context.Context, system, user string) (string, error)
}

Client 单轮 system+user → 文本完成。max_tokens 由实现侧决定。

调用方在持有 nil interface 时应走规则 fallback(详见 task.llmParse / skill.Benchmark)。 注意区分 typed nil:wire 处应用真 nil interface,不要把 (*concrete)(nil) 赋给本接口。

type OpenAIClient

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

OpenAIClient 调用任意 OpenAI 兼容接口(openai.com / Azure / 本地代理均可)。

自托管用户可通过 LLM_OPENAI_URL + LLM_OPENAI_API_KEY + LLM_OPENAI_MODEL 直接配置,无需私有代理服务。

func NewOpenAIClient

func NewOpenAIClient(baseURL, apiKey, model string) *OpenAIClient

NewOpenAIClient 返回 OpenAI 兼容 client。baseURL 为空时返回 nil(调用方走规则 fallback)。

baseURL 示例:

func (*OpenAIClient) Complete

func (c *OpenAIClient) Complete(ctx context.Context, system, user string) (string, error)

type RemoteClient

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

RemoteClient calls an internal LLM completion service. Core intentionally keeps provider-specific clients, keys, and model selection outside this repo.

func NewRemoteClient

func NewRemoteClient(endpoint, internalToken string) *RemoteClient

NewRemoteClient returns nil when endpoint is empty so callers can keep the rule-based fallback path.

func (*RemoteClient) Complete

func (c *RemoteClient) Complete(ctx context.Context, system, user string) (string, error)

Jump to

Keyboard shortcuts

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