Documentation
¶
Index ¶
- type AvailableModels
- type ChatOptions
- type ChatRequest
- type Client
- func (c *Client) Chat(ctx context.Context, chatRequest *ChatRequest) (<-chan StreamResponse, error)
- func (c *Client) ContextExists(ctx context.Context, name string) (bool, error)
- func (c *Client) CreateContext(ctx context.Context, name string, body io.Reader) error
- func (c *Client) CreatePattern(ctx context.Context, name string, body io.Reader) error
- func (c *Client) CreateSession(ctx context.Context, name string, body io.Reader) error
- func (c *Client) DeleteContext(ctx context.Context, name string) error
- func (c *Client) DeletePattern(ctx context.Context, name string) error
- func (c *Client) DeleteSession(ctx context.Context, name string) error
- func (c *Client) GetConfig(ctx context.Context) (*Config, error)
- func (c *Client) GetContextMetadata(ctx context.Context, name string) (*Context, error)
- func (c *Client) GetPatternMetadata(ctx context.Context, name string) (*Pattern, error)
- func (c *Client) GetSessionMetadata(ctx context.Context, name string) (*Session, error)
- func (c *Client) ListContexts(ctx context.Context) ([]string, error)
- func (c *Client) ListModels(ctx context.Context) (*AvailableModels, error)
- func (c *Client) ListPatterns(ctx context.Context) ([]string, error)
- func (c *Client) ListSessions(ctx context.Context) ([]string, error)
- func (c *Client) ListStrategies(ctx context.Context) ([]Strategy, error)
- func (c *Client) PatternExists(ctx context.Context, name string) (bool, error)
- func (c *Client) RenameContext(ctx context.Context, oldName string, newName string) error
- func (c *Client) RenamePattern(ctx context.Context, oldName string, newName string) error
- func (c *Client) RenameSession(ctx context.Context, oldName string, newName string) error
- func (c *Client) SessionExists(ctx context.Context, name string) (bool, error)
- func (c *Client) UpdateConfig(ctx context.Context, config *Config) error
- type Config
- type Context
- type Entity
- type EntityType
- type HTTPError
- type Option
- type Pattern
- type PromptRequest
- type Session
- type Strategy
- type StreamResponse
- type StreamResponseType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AvailableModels ¶
type AvailableModels struct {
Models []string `json:"models"` // Models is a list of model names.
Vendors map[string][]string `json:"vendors"` // Vendors maps vendor names to their models.
}
AvailableModels contains a list of available model names and their vendors.
type ChatOptions ¶
type ChatOptions struct {
Model string `json:"model"` // Model is the name of the model to use for the chat.
Temperature float64 `json:"temperature"` // Temperature controls the randomness of the model's responses.
TopP float64 `json:"topP"` // TopP is the nucleus sampling parameter for controlling diversity.
PresencePenalty float64 `json:"presencePenalty"` // PresencePenalty discourages repetition of tokens already present in the conversation.
FrequencyPenalty float64 `json:"frequencyPenalty"` // FrequencyPenalty discourages repetition of tokens based on their frequency in the conversation.
Raw bool `json:"raw"` // Raw indicates whether to return raw model output without processing.
Seed int `json:"seed"` // Seed is used for random number generation to ensure reproducibility.
ModelContextLength int `json:"modelContextLength"` // ModelContextLength is the maximum context length for the model.
}
type ChatRequest ¶
type ChatRequest struct {
Prompts []PromptRequest `json:"prompts"` // Prompts is a list of prompt requests to be processed.
Language string `json:"language"` // Language specifies the language for the chat.
ChatOptions ChatOptions `json:"chatOptions"` // ChatOptions contains various options for the chat session.
}
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a client for the Fabric API server.
func NewClient ¶
NewClient creates a new Client instance with the specified host and options. The Client will use the default HTTP client with a timeout of 60 seconds.
To set the API key, use the WithAPIKey option. To customize the HTTP client, use the WithHTTPClient option.
func (*Client) Chat ¶
func (c *Client) Chat(ctx context.Context, chatRequest *ChatRequest) (<-chan StreamResponse, error)
Chat initiates a chat session with the specified chat request.
func (*Client) ContextExists ¶
ContextExists checks if a context exists.
func (*Client) CreateContext ¶
CreateContext creates a new context.
func (*Client) CreatePattern ¶
CreatePattern creates a new pattern.
func (*Client) CreateSession ¶
CreateSession creates a new session.
func (*Client) DeleteContext ¶
DeleteContext deletes a context.
func (*Client) DeletePattern ¶
DeletePattern deletes a pattern.
func (*Client) DeleteSession ¶
DeleteSession deletes a session.
func (*Client) GetContextMetadata ¶
GetContextMetadata retrieves the metadata of a context.
func (*Client) GetPatternMetadata ¶
GetPatternMetadata retrieves the metadata of a pattern.
func (*Client) GetSessionMetadata ¶
GetSessionMetadata retrieves the metadata of a session.
func (*Client) ListContexts ¶
ListContexts retrieves the list of contexts.
func (*Client) ListModels ¶
func (c *Client) ListModels(ctx context.Context) (*AvailableModels, error)
ListNames retrieves a list of models.
func (*Client) ListPatterns ¶
ListPatterns retrieves the list of patterns.
func (*Client) ListSessions ¶
ListSessions retrieves the list of sessions.
func (*Client) ListStrategies ¶
ListStrategies retrieves a list of strategies.
func (*Client) PatternExists ¶
PatternExists checks if a pattern exists.
func (*Client) RenameContext ¶
RenameContext renames a context.
func (*Client) RenamePattern ¶
RenamePattern renames a pattern.
func (*Client) RenameSession ¶
RenameSession renames a session.
func (*Client) SessionExists ¶
SessionExists checks if a session exists.
type Config ¶
type Config struct {
Anthropic string `json:"anthropic"` // Anthropic API key.
DeepSeek string `json:"deepseek"` // DeepSeek API key.
Gemini string `json:"gemini"` // Gemini API key.
Grokai string `json:"grokai"` // Grokai API key.
Groq string `json:"groq"` // Groq API key.
LMStudio string `json:"lmstudio"` // LMStudio API key.
Mistral string `json:"mistral"` // Mistral API key.
Ollama string `json:"ollama"` // Ollama API key.
OpenAI string `json:"openai"` // OpenAI API key.
OpenRouter string `json:"openrouter"` // OpenRouter API key.
Silicon string `json:"silicon"` // Silicon API key.
}
Config holds configuration values for various LLM providers.
type Context ¶
type Context struct {
Name string `json:"name"` // Name of the context.
Content string `json:"content"` // Content is the text or data stored in the context.
}
Context represents a named context file with its content.
type Entity ¶
Entity is a type constraint for generic functions that operate on Pattern, Context, or Session types.
type EntityType ¶ added in v0.0.2
type EntityType string
const ( EntityTypeContext EntityType = "context" EntityTypePattern EntityType = "pattern" EntityTypeSession EntityType = "session" )
type Option ¶
type Option func(*Client)
Option represents a function that configures the Client using the functional options pattern.
func WithHTTPClient ¶
WithHTTPClient sets the HTTP client for the client.
type Pattern ¶
type Pattern struct {
Name string `json:"name"` // Name of the pattern.
Description string `json:"description"` // Description provides details about the pattern's purpose.
Pattern string `json:"pattern"` // Pattern is the actual prompt or template string.
}
Pattern represents a reusable prompt pattern with a name, description, and pattern string.
type PromptRequest ¶
type PromptRequest struct {
UserInput string `json:"userInput"` // UserInput is the input provided by the user for the prompt.
Vendor string `json:"vendor"` // Vendor is the name of the LLM vendor (e.g., OpenAI, Anthropic).
Model string `json:"model"` // Model is the name of the model to use for the prompt.
ContextName string `json:"contextName"` // ContextName is the name of the context to use.
PatternName string `json:"patternName"` // PatternName is the name of the pattern to use.
StrategyName string `json:"strategyName"` // StrategyName is the name of the strategy to use.
}
type Session ¶
type Session struct {
Name string `json:"name"` // Name of the session.
Messages []struct {
Role string `json:"role"` // Role is the sender's role (e.g., user, assistant).
Content string `json:"content"` // Content is the message text.
} `json:"messages"`
}
Session represents a chat session with a name and a list of messages.
type Strategy ¶
type Strategy struct {
Name string `json:"name"` // Name of the strategy.
Description string `json:"description"` // Description provides details about the strategy's purpose.
Pattern string `json:"pattern"` // Pattern is the pattern associated with the strategy.
}
Strategy represents a named strategy with a description and associated pattern.
type StreamResponse ¶
type StreamResponse struct {
Type string `json:"type"` // "content", "error", "complete"
Format string `json:"format"` // "markdown", "mermaid", "plain"
Content string `json:"content"` // The actual content
}
StreamResponse represents the chat's streaming response
type StreamResponseType ¶ added in v0.0.2
type StreamResponseType string
const ( StreamResponseTypeComplete StreamResponseType = "complete" StreamResponseTypeContent StreamResponseType = "content" StreamResponseTypeError StreamResponseType = "error" )