|
1
|
// Package llm is the omnibus LLM gateway — any bot or service can use it to |
|
2
|
// call language models without depending on a specific provider's SDK. |
|
3
|
// |
|
4
|
// Usage: |
|
5
|
// |
|
6
|
// p, err := llm.New(llm.BackendConfig{Backend: "anthropic", APIKey: "sk-ant-..."}) |
|
7
|
// text, err := p.Summarize(ctx, prompt) |
|
8
|
// |
|
9
|
// Model discovery (if the provider implements ModelDiscoverer): |
|
10
|
// |
|
11
|
// if d, ok := p.(llm.ModelDiscoverer); ok { |
|
12
|
// models, err := d.DiscoverModels(ctx) |
|
13
|
// } |
|
14
|
package llm |
|
15
|
|
|
16
|
import "context" |
|
17
|
|
|
18
|
// Provider calls a language model to generate text. |
|
19
|
// All provider implementations satisfy this interface. |
|
20
|
type Provider interface { |
|
21
|
Summarize(ctx context.Context, prompt string) (string, error) |
|
22
|
} |
|
23
|
|
|
24
|
// ModelInfo describes a model returned by discovery. |
|
25
|
type ModelInfo struct { |
|
26
|
ID string `json:"id"` |
|
27
|
Name string `json:"name,omitempty"` |
|
28
|
Description string `json:"description,omitempty"` |
|
29
|
} |
|
30
|
|
|
31
|
// ModelDiscoverer can enumerate available models for a backend. |
|
32
|
// Providers that support live model listing implement this interface. |
|
33
|
type ModelDiscoverer interface { |
|
34
|
DiscoverModels(ctx context.Context) ([]ModelInfo, error) |
|
35
|
} |
|
36
|
|