MCPcopy Create free account
hub / github.com/PatchMon/PatchMon / GetCompletion

Method GetCompletion

server-source-code/internal/ai/service.go:150–168  ·  view source on GitHub ↗

GetCompletion returns a command completion suggestion.

(settings *models.Settings, input, context string)

Source from the content-addressed store, hash-verified

148
149// GetCompletion returns a command completion suggestion.
150func (s *Service) GetCompletion(settings *models.Settings, input, context string) (string, error) {
151 if len(input) < 2 {
152 return "", nil
153 }
154 prompt := `Current command being typed: "` + input + `"
155Complete this command. Only respond with the remaining text to add, nothing else.`
156
157 response, err := s.callAI(settings, prompt, &callOptions{
158 maxTokens: 100,
159 temperature: 0.3,
160 }, systemPromptCompletion, context, nil)
161 if err != nil {
162 return "", err
163 }
164 // Clean up: remove quotes, newlines
165 trimmed := strings.TrimSpace(response)
166 trimmed = regexp.MustCompile(`^["']|["']$`).ReplaceAllString(trimmed, "")
167 return trimmed, nil
168}
169
170func (s *Service) callAI(settings *models.Settings, prompt string, opts *callOptions, systemPrompt, context string, history []Message) (string, error) {
171 if s.enc == nil {

Callers 1

CompleteMethod · 0.80

Calls 1

callAIMethod · 0.95

Tested by

no test coverage detected