feat(sdk): typed errors, enums, and KB model config for the CLI
Adds the client-library surface the agent-first CLI builds on: - named server error-code constants + typed *APIError from non-2xx responses, - MessageSearchMode / AgentMode / KBSelectionMode and model type/source enumerators so the CLI validates flags against the server vocabulary, - SetKBModelConfig for binding embedding/chat models to a knowledge base.
This commit is contained in:
@@ -65,7 +65,11 @@ func (c *Client) InitializeByKB(ctx context.Context, kbID string, config *Initia
|
||||
return parseResponse(resp, nil)
|
||||
}
|
||||
|
||||
// UpdateKBConfig updates the model configuration for a knowledge base
|
||||
// UpdateKBConfig updates the model configuration for a knowledge base.
|
||||
//
|
||||
// Deprecated: the PUT /initialization/config endpoint binds KBModelConfigRequest
|
||||
// (fields llmModelId / embeddingModelId), not InitializationConfig, so this
|
||||
// method sends a shape the server rejects. Use SetKBModelConfig instead.
|
||||
func (c *Client) UpdateKBConfig(ctx context.Context, kbID string, config *InitializationConfig) error {
|
||||
resp, err := c.doRequest(ctx, http.MethodPut, fmt.Sprintf("/api/v1/initialization/config/%s", kbID), config, nil)
|
||||
if err != nil {
|
||||
@@ -74,6 +78,27 @@ func (c *Client) UpdateKBConfig(ctx context.Context, kbID string, config *Initia
|
||||
return parseResponse(resp, nil)
|
||||
}
|
||||
|
||||
// KBModelConfig points a knowledge base at already-registered models. Field
|
||||
// names match the server's KBModelConfigRequest (PUT
|
||||
// /initialization/config/:kbId). LLMModelID is required server-side;
|
||||
// EmbeddingModelID is optional (omitted when RAG indexing is disabled).
|
||||
type KBModelConfig struct {
|
||||
LLMModelID string `json:"llmModelId"`
|
||||
EmbeddingModelID string `json:"embeddingModelId,omitempty"`
|
||||
}
|
||||
|
||||
// SetKBModelConfig binds a knowledge base to already-registered models via PUT
|
||||
// /initialization/config/:kbId. Register models first with CreateModel; the
|
||||
// server rejects unknown model ids and refuses to change the embedding model of
|
||||
// a KB that already has documents.
|
||||
func (c *Client) SetKBModelConfig(ctx context.Context, kbID string, cfg *KBModelConfig) error {
|
||||
resp, err := c.doRequest(ctx, http.MethodPut, fmt.Sprintf("/api/v1/initialization/config/%s", kbID), cfg, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return parseResponse(resp, nil)
|
||||
}
|
||||
|
||||
// CheckOllamaStatus checks if Ollama is running and accessible
|
||||
func (c *Client) CheckOllamaStatus(ctx context.Context) (bool, error) {
|
||||
resp, err := c.doRequest(ctx, http.MethodGet, "/api/v1/initialization/ollama/status", nil, nil)
|
||||
|
||||
Reference in New Issue
Block a user