Documentation
¶
Index ¶
- func ParseJSONResponse[T any](ctx context.Context, client Client, sessionID string, rawResponse string) (T, error)
- type Client
- type CopilotClient
- func (c *CopilotClient) AbortSession(ctx context.Context, sessionID string) error
- func (c *CopilotClient) CreateSession(ctx context.Context, title string, workDir string) (*SessionInfo, error)
- func (c *CopilotClient) DeleteSession(_ context.Context, sessionID string) error
- func (c *CopilotClient) GetMessages(_ context.Context, sessionID string) ([]Message, error)
- func (c *CopilotClient) SendPrompt(ctx context.Context, sessionID string, prompt string) (*PromptResponse, error)
- func (c *CopilotClient) Start(ctx context.Context) error
- func (c *CopilotClient) Stop() error
- type Message
- type MockClient
- func (m *MockClient) AbortSession(_ context.Context, _ string) error
- func (m *MockClient) CreateSession(_ context.Context, title string, _ string) (*SessionInfo, error)
- func (m *MockClient) DeleteSession(_ context.Context, sessionID string) error
- func (m *MockClient) GetMessages(_ context.Context, _ string) ([]Message, error)
- func (m *MockClient) GetPromptHistory() []PromptCall
- func (m *MockClient) SendPrompt(_ context.Context, sessionID string, prompt string) (*PromptResponse, error)
- func (m *MockClient) SetSessionResult(sessionID string, result string)
- type PromptCall
- type PromptResponse
- type SessionInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseJSONResponse ¶
func ParseJSONResponse[T any](ctx context.Context, client Client, sessionID string, rawResponse string) (T, error)
ParseJSONResponse attempts to parse a JSON response from LLM output. If the raw response is not valid JSON, it tries to extract JSON and optionally retries via the same session.
Types ¶
type Client ¶
type Client interface {
// CreateSession creates a new isolated LLM session in the given working directory.
CreateSession(ctx context.Context, title string, workDir string) (*SessionInfo, error)
// SendPrompt sends a prompt to the given session and waits for completion.
SendPrompt(ctx context.Context, sessionID string, prompt string) (*PromptResponse, error)
// GetMessages retrieves all messages from a session.
GetMessages(ctx context.Context, sessionID string) ([]Message, error)
// DeleteSession deletes a session.
DeleteSession(ctx context.Context, sessionID string) error
// AbortSession aborts a running prompt in a session.
AbortSession(ctx context.Context, sessionID string) error
}
Client abstracts LLM session operations for testability.
type CopilotClient ¶
type CopilotClient struct {
// contains filtered or unexported fields
}
CopilotClient wraps the GitHub Copilot SDK to implement Client.
func NewCopilotClient ¶
func NewCopilotClient(model string) *CopilotClient
NewCopilotClient creates a CopilotClient that uses the given model for all sessions.
func NewCopilotClientWithServer ¶
func NewCopilotClientWithServer(model, serverURL string) *CopilotClient
NewCopilotClientWithServer creates a CopilotClient that connects to a shared server.
func (*CopilotClient) AbortSession ¶
func (c *CopilotClient) AbortSession(ctx context.Context, sessionID string) error
func (*CopilotClient) CreateSession ¶
func (c *CopilotClient) CreateSession(ctx context.Context, title string, workDir string) (*SessionInfo, error)
func (*CopilotClient) DeleteSession ¶
func (c *CopilotClient) DeleteSession(_ context.Context, sessionID string) error
func (*CopilotClient) GetMessages ¶
func (*CopilotClient) SendPrompt ¶
func (c *CopilotClient) SendPrompt(ctx context.Context, sessionID string, prompt string) (*PromptResponse, error)
func (*CopilotClient) Start ¶
func (c *CopilotClient) Start(ctx context.Context) error
Start initializes the underlying Copilot SDK client.
func (*CopilotClient) Stop ¶
func (c *CopilotClient) Stop() error
Stop shuts down all sessions and the SDK client.
type MockClient ¶
type MockClient struct {
Sessions map[string]*SessionInfo
PromptResults map[string]string // sessionID -> response content
DefaultResult string
PromptHistory []PromptCall
CreateErr error
PromptErr error
MessagesResult []Message
// contains filtered or unexported fields
}
MockClient is a test double for Client.
func NewMockClient ¶
func NewMockClient() *MockClient
NewMockClient creates a new MockClient with sensible defaults.
func (*MockClient) AbortSession ¶
func (m *MockClient) AbortSession(_ context.Context, _ string) error
func (*MockClient) CreateSession ¶
func (m *MockClient) CreateSession(_ context.Context, title string, _ string) (*SessionInfo, error)
func (*MockClient) DeleteSession ¶
func (m *MockClient) DeleteSession(_ context.Context, sessionID string) error
func (*MockClient) GetMessages ¶
func (*MockClient) GetPromptHistory ¶
func (m *MockClient) GetPromptHistory() []PromptCall
GetPromptHistory returns all prompt calls made to this mock.
func (*MockClient) SendPrompt ¶
func (m *MockClient) SendPrompt(_ context.Context, sessionID string, prompt string) (*PromptResponse, error)
func (*MockClient) SetSessionResult ¶
func (m *MockClient) SetSessionResult(sessionID string, result string)
SetSessionResult pre-sets the result for a specific session ID.
type PromptCall ¶
PromptCall records a call to SendPrompt.
type PromptResponse ¶
type PromptResponse struct {
Content string
}
PromptResponse represents the result of a prompt.
type SessionInfo ¶
SessionInfo represents a created LLM session.