diff options
| author | Paul Buetow <paul@buetow.org> | 2025-09-17 22:49:13 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-09-17 22:49:13 +0300 |
| commit | d059ae333fa1c89cb58d7fb56ead79cdba15d5db (patch) | |
| tree | ae65ad59c8590f71232a6abefee312b72ddf6d3e /internal/lsp | |
| parent | 88103657fb230bb41217a06aa5602ae23e7acb8b (diff) | |
chore(version): bump to v0.11.1 (gpt-5 defaults, timeouts, global stats, editor fix)v0.11.1
Diffstat (limited to 'internal/lsp')
| -rw-r--r-- | internal/lsp/handlers_codeaction.go | 12 | ||||
| -rw-r--r-- | internal/lsp/handlers_completion.go | 4 | ||||
| -rw-r--r-- | internal/lsp/handlers_document.go | 2 | ||||
| -rw-r--r-- | internal/lsp/handlers_utils.go | 10 | ||||
| -rw-r--r-- | internal/lsp/llm_request_opts_test.go | 31 |
5 files changed, 49 insertions, 10 deletions
diff --git a/internal/lsp/handlers_codeaction.go b/internal/lsp/handlers_codeaction.go index 9bc3f51..e5e61ef 100644 --- a/internal/lsp/handlers_codeaction.go +++ b/internal/lsp/handlers_codeaction.go @@ -174,7 +174,7 @@ func (s *Server) resolveCodeAction(ca CodeAction) (CodeAction, bool) { case "rewrite": sys := s.promptRewriteSystem user := renderTemplate(s.promptRewriteUser, map[string]string{"instruction": payload.Instruction, "selection": payload.Selection}) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) defer cancel() messages := []llm.Message{{Role: "system", Content: sys}, {Role: "user", Content: user}} opts := s.llmRequestOpts() @@ -199,7 +199,7 @@ func (s *Server) resolveCodeAction(ca CodeAction) (CodeAction, bool) { } diagList := b.String() user := renderTemplate(s.promptDiagnosticsUser, map[string]string{"diagnostics": diagList, "selection": payload.Selection}) - ctx, cancel := context.WithTimeout(context.Background(), 12*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 22*time.Second) defer cancel() messages := []llm.Message{{Role: "system", Content: sys}, {Role: "user", Content: user}} opts := s.llmRequestOpts() @@ -215,7 +215,7 @@ func (s *Server) resolveCodeAction(ca CodeAction) (CodeAction, bool) { case "document": sys := s.promptDocumentSystem user := renderTemplate(s.promptDocumentUser, map[string]string{"selection": payload.Selection}) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) defer cancel() messages := []llm.Message{{Role: "system", Content: sys}, {Role: "user", Content: user}} opts := s.llmRequestOpts() @@ -242,7 +242,7 @@ func (s *Server) resolveCodeAction(ca CodeAction) (CodeAction, bool) { sys := s.promptRewriteSystem // Reuse rewrite user template with a fixed instruction user := renderTemplate(s.promptRewriteUser, map[string]string{"instruction": "Simplify and improve the code while preserving behavior. Return only the improved code.", "selection": payload.Selection}) - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) defer cancel() messages := []llm.Message{{Role: "system", Content: sys}, {Role: "user", Content: user}} opts := s.llmRequestOpts() @@ -293,7 +293,7 @@ func (s *Server) resolveCodeAction(ca CodeAction) (CodeAction, bool) { sys = s.promptRewriteSystem user = renderTemplate(s.promptRewriteUser, map[string]string{"instruction": action.Instruction, "selection": payload.Selection}) } - ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) defer cancel() messages := []llm.Message{{Role: "system", Content: sys}, {Role: "user", Content: user}} opts := s.llmRequestOpts() @@ -610,7 +610,7 @@ func (s *Server) generateGoTestFunction(funcCode string) string { if s.llmClient != nil { sys := s.promptGoTestSystem user := renderTemplate(s.promptGoTestUser, map[string]string{"function": funcCode}) - ctx, cancel := context.WithTimeout(context.Background(), 8*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 18*time.Second) defer cancel() messages := []llm.Message{{Role: "system", Content: sys}, {Role: "user", Content: user}} opts := s.llmRequestOpts() diff --git a/internal/lsp/handlers_completion.go b/internal/lsp/handlers_completion.go index 9ef62f1..6142a30 100644 --- a/internal/lsp/handlers_completion.go +++ b/internal/lsp/handlers_completion.go @@ -72,7 +72,7 @@ func (s *Server) logCompletionContext(p CompletionParams, above, current, below, } func (s *Server) tryLLMCompletion(p CompletionParams, above, current, below, funcCtx, docStr string, hasExtra bool, extraText string) ([]CompletionItem, bool) { - ctx, cancel := context.WithTimeout(context.Background(), 6*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 12*time.Second) defer cancel() inlinePrompt := lineHasInlinePrompt(current) @@ -243,7 +243,7 @@ func (s *Server) tryProviderNativeCompletion(current string, p CompletionParams, prov = s.llmClient.Name() } logging.Logf("lsp ", "completion path=codex provider=%s uri=%s", prov, path) - ctx2, cancel2 := context.WithTimeout(context.Background(), 8*time.Second) + ctx2, cancel2 := context.WithTimeout(context.Background(), 15*time.Second) defer cancel2() // Debounce and throttle prior to provider-native call diff --git a/internal/lsp/handlers_document.go b/internal/lsp/handlers_document.go index 9a12948..3897885 100644 --- a/internal/lsp/handlers_document.go +++ b/internal/lsp/handlers_document.go @@ -154,7 +154,7 @@ func (s *Server) detectAndHandleChat(uri string) { lineIdx := i lastIdx := j go func(prompt string, remove int) { - ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 25*time.Second) defer cancel() // Build messages with history and context_mode aware extras. pos := Position{Line: lineIdx, Character: lastIdx + 1} diff --git a/internal/lsp/handlers_utils.go b/internal/lsp/handlers_utils.go index 43bfdc8..c0ec7c3 100644 --- a/internal/lsp/handlers_utils.go +++ b/internal/lsp/handlers_utils.go @@ -24,7 +24,15 @@ var ( func (s *Server) llmRequestOpts() []llm.RequestOption { opts := []llm.RequestOption{llm.WithMaxTokens(s.maxTokens)} if s.codingTemperature != nil { - opts = append(opts, llm.WithTemperature(*s.codingTemperature)) + temp := *s.codingTemperature + if s.llmClient != nil { + prov := strings.ToLower(strings.TrimSpace(s.llmClient.Name())) + model := strings.ToLower(strings.TrimSpace(s.llmClient.DefaultModel())) + if prov == "openai" && strings.HasPrefix(model, "gpt-5") { + temp = 1.0 + } + } + opts = append(opts, llm.WithTemperature(temp)) } return opts } diff --git a/internal/lsp/llm_request_opts_test.go b/internal/lsp/llm_request_opts_test.go new file mode 100644 index 0000000..f4d2ef3 --- /dev/null +++ b/internal/lsp/llm_request_opts_test.go @@ -0,0 +1,31 @@ +package lsp + +import ( + "context" + "testing" + + "codeberg.org/snonux/hexai/internal/llm" +) + +type fakeClient struct{ name, model string } + +func (f fakeClient) Chat(_ context.Context, _ []llm.Message, _ ...llm.RequestOption) (string, error) { + return "", nil +} +func (f fakeClient) Name() string { return f.name } +func (f fakeClient) DefaultModel() string { return f.model } + +func TestLlmRequestOpts_Gpt5_ForcesTemp1(t *testing.T) { + s := newTestServer() + one := 0.2 + s.codingTemperature = &one + s.llmClient = fakeClient{name: "openai", model: "gpt-5.0"} + opts := s.llmRequestOpts() + var got llm.Options + for _, o := range opts { + o(&got) + } + if got.Temperature != 1.0 { + t.Fatalf("expected temp 1.0 for gpt-5, got %v", got.Temperature) + } +} |
