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