From 1b0c1e22a636ff85e2c8168001119f710acb5653 Mon Sep 17 00:00:00 2001 From: Junyi Hou Date: Thu, 8 Jan 2026 00:07:44 +0800 Subject: [PATCH 1/8] support gpt 5.2 --- internal/api/chat/list_supported_models_v2.go | 34 +++++++++++++++++- internal/api/user/list_prompts.go | 35 +++++++++---------- .../services/toolkit/client/completion_v2.go | 8 +++++ .../_webapp/src/views/chat/footer/index.tsx | 2 +- .../chat/footer/toolbar/prompt-selection.tsx | 8 +++++ .../src/views/settings/setting-item-input.tsx | 2 +- .../views/settings/setting-item-select.tsx | 2 +- 7 files changed, 68 insertions(+), 23 deletions(-) diff --git a/internal/api/chat/list_supported_models_v2.go b/internal/api/chat/list_supported_models_v2.go index 7c37a7b..5a7cfa4 100644 --- a/internal/api/chat/list_supported_models_v2.go +++ b/internal/api/chat/list_supported_models_v2.go @@ -27,12 +27,20 @@ func (s *ChatServerV2) ListSupportedModels( var models []*chatv2.SupportedModel if strings.TrimSpace(settings.OpenAIAPIKey) == "" { models = []*chatv2.SupportedModel{ + { + Name: "GPT-5.1", + Slug: "openai/gpt-5.1", + TotalContext: 400000, + MaxOutput: 128000, + InputPrice: 125, // $1.25 + OutputPrice: 1000, // $10.00 + }, { Name: "GPT-4.1", Slug: "openai/gpt-4.1", TotalContext: 1050000, MaxOutput: 32800, - InputPrice: 200, + InputPrice: 200, // $2.00 OutputPrice: 800, }, { @@ -78,6 +86,30 @@ func (s *ChatServerV2) ListSupportedModels( } } else { models = []*chatv2.SupportedModel{ + { + Name: "GPT-5.2 Pro", + Slug: openai.ChatModelGPT5_2Pro, + TotalContext: 400000, + MaxOutput: 128000, + InputPrice: 2100, // $21.00 + OutputPrice: 16800, // $168.00 + }, + { + Name: "GPT-5.2", + Slug: openai.ChatModelGPT5_2, + TotalContext: 400000, + MaxOutput: 128000, + InputPrice: 175, // $1.75 + OutputPrice: 1400, // $14.00 + }, + { + Name: "GPT-5.1", + Slug: openai.ChatModelGPT5_1, + TotalContext: 400000, + MaxOutput: 128000, + InputPrice: 125, // $1.25 + OutputPrice: 1000, // $10.00 + }, { Name: "GPT-4.1", Slug: openai.ChatModelGPT4_1, diff --git a/internal/api/user/list_prompts.go b/internal/api/user/list_prompts.go index 5611238..cae3ec1 100644 --- a/internal/api/user/list_prompts.go +++ b/internal/api/user/list_prompts.go @@ -3,13 +3,10 @@ package user import ( "context" "sort" - "time" "paperdebugger/internal/api/mapper" "paperdebugger/internal/libs/contextutil" userv1 "paperdebugger/pkg/gen/api/user/v1" - - "google.golang.org/protobuf/types/known/timestamppb" ) var defaultPrompts = []*userv1.Prompt{ @@ -21,22 +18,22 @@ var defaultPrompts = []*userv1.Prompt{ // Content: "Suggest context-aware academic paper writing enhancements for selected text.", // IsUserPrompt: false, // }, - { - Id: "2", - CreatedAt: timestamppb.New(time.Time{}), - UpdatedAt: timestamppb.New(time.Time{}), - Title: "Review (Powered by XtraMCP)", - Content: "Review my paper and identify issues", - IsUserPrompt: false, - }, - { - Id: "3", - CreatedAt: timestamppb.New(time.Time{}), - UpdatedAt: timestamppb.New(time.Time{}), - Title: "Find Relevant Papers (Powered by XtraMCP)", - Content: "Find me relevant papers to read", - IsUserPrompt: false, - }, + // { + // Id: "2", + // CreatedAt: timestamppb.New(time.Time{}), + // UpdatedAt: timestamppb.New(time.Time{}), + // Title: "Review (Powered by XtraMCP)", + // Content: "Review my paper and identify issues", + // IsUserPrompt: false, + // }, + // { + // Id: "3", + // CreatedAt: timestamppb.New(time.Time{}), + // UpdatedAt: timestamppb.New(time.Time{}), + // Title: "Find Relevant Papers (Powered by XtraMCP)", + // Content: "Find me relevant papers to read", + // IsUserPrompt: false, + // }, // { // Id: "4", // CreatedAt: timestamppb.New(time.Time{}), diff --git a/internal/services/toolkit/client/completion_v2.go b/internal/services/toolkit/client/completion_v2.go index e7e5b7b..79f1569 100644 --- a/internal/services/toolkit/client/completion_v2.go +++ b/internal/services/toolkit/client/completion_v2.go @@ -98,6 +98,14 @@ func (a *AIClientV2) ChatCompletionStreamV2(ctx context.Context, callbackStream } reasoning_content += s // fmt.Print(s) + } else if field, ok := delta.JSON.ExtraFields["reasoning"]; ok && field.Raw() != "null" { + var s string + err := json.Unmarshal([]byte(field.Raw()), &s) + if err != nil { + // fmt.Println(err) + } + reasoning_content += s + // fmt.Print(s) } else { if !is_answering { is_answering = true diff --git a/webapp/_webapp/src/views/chat/footer/index.tsx b/webapp/_webapp/src/views/chat/footer/index.tsx index 0cfc947..2baee18 100644 --- a/webapp/_webapp/src/views/chat/footer/index.tsx +++ b/webapp/_webapp/src/views/chat/footer/index.tsx @@ -101,7 +101,7 @@ export function PromptInput() { return (
{/* Only show one popup at a time - priority: prompts > actions > model selection */} - {prompts.length > 0 && } + {prompt.startsWith("/") && } {prompts.length === 0 && actions.length > 0 && } {prompts.length === 0 && actions.length === 0 && showModelSelection && ( diff --git a/webapp/_webapp/src/views/chat/footer/toolbar/prompt-selection.tsx b/webapp/_webapp/src/views/chat/footer/toolbar/prompt-selection.tsx index 79d7c28..a4f7774 100644 --- a/webapp/_webapp/src/views/chat/footer/toolbar/prompt-selection.tsx +++ b/webapp/_webapp/src/views/chat/footer/toolbar/prompt-selection.tsx @@ -35,5 +35,13 @@ export function PromptSelection({ prompts }: PromptSelectionProps) { inputRef.current?.focus(); }, [setPrompt, inputRef]); + if (prompts.length === 0) { + return ( +
+
No prompts found
+
+ ); + } + return ; } diff --git a/webapp/_webapp/src/views/settings/setting-item-input.tsx b/webapp/_webapp/src/views/settings/setting-item-input.tsx index 54f2583..634799d 100644 --- a/webapp/_webapp/src/views/settings/setting-item-input.tsx +++ b/webapp/_webapp/src/views/settings/setting-item-input.tsx @@ -21,7 +21,7 @@ export const SettingItemInput = ({ }: SettingItemInputProps) => (
-

{label}

+

{label}

(
-

{label}

+

{label}

{description}