Skip to content

Commit 5176de9

Browse files
authored
fix: stale modelSlug (#100)
1. fix: remove definition of `currentConversation` as it is not used (to fix the following error when running `npm run build:prd:chrome` ```bash > webapp@0.0.0 build:prd:chrome > bash -c 'source ./scripts/build-prd-chrome.sh' 🧩 Start building Chrome Extension ... 📦 Version: 2.16.0 📦 Monorepo Revision: 9fc435 📦 Beta Build: false 📦 API Endpoint: https://app.paperdebugger.com ❌ Failed to build Chrome Extension, please check logs/build.log > webapp@0.0.0 build > tsc -b && npm run _build:default && npm run _build:background && npm run _build:intermediate && npm run _build:settings && npm run _build:popup src/views/settings/setting-text-input.tsx(32,13): error TS6133: 'currentConversation' is declared but its value is never read. ``` 2. fix: change matching from substring to exact, to prevent `gpt-4.1-mini` from matching to `gpt-4.0` (edit: typo, should be `gpt-4.1`), making the method more robust to the order of supported models defined. 3. [edit] refactor: use IsCustom and not redefine logic in NewAIClientV2
1 parent 9fc435f commit 5176de9

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

internal/services/toolkit/client/client_v2.go

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,33 @@ func NewAIClientV2(
6363
logger *logger.Logger,
6464
) *AIClientV2 {
6565
database := db.Database("paperdebugger")
66+
67+
llmProvider := &models.LLMProviderConfig{
68+
APIKey: cfg.OpenAIAPIKey,
69+
}
70+
71+
var baseUrl string
72+
var apiKey string
73+
var modelSlug string
6674

67-
if cfg.InferenceBaseURL != "" && cfg.InferenceAPIKey != "" {
68-
oaiClient := openai.NewClient(
69-
option.WithBaseURL(cfg.InferenceBaseURL+"/openrouter"),
70-
option.WithAPIKey(cfg.InferenceAPIKey),
71-
)
72-
CheckOpenAIWorksV2(oaiClient, cfg.InferenceBaseURL+"/openrouter", "openai/gpt-5-nano", logger)
75+
// User specified their own API key, use the OpenAI-compatible endpoint
76+
if llmProvider != nil && llmProvider.IsCustom() {
77+
baseUrl = cfg.OpenAIBaseURL
78+
apiKey = cfg.OpenAIAPIKey
79+
modelSlug = "gpt-5-nano"
80+
// Use the default inference endpoint
7381
} else {
74-
oaiClient := openai.NewClient(
75-
option.WithBaseURL(cfg.OpenAIBaseURL),
76-
option.WithAPIKey(cfg.OpenAIAPIKey),
77-
)
78-
CheckOpenAIWorksV2(oaiClient, cfg.OpenAIBaseURL, "gpt-5-nano", logger)
82+
baseUrl = cfg.InferenceBaseURL + "/openrouter"
83+
apiKey = cfg.InferenceAPIKey
84+
modelSlug = "openai/gpt-5-nano"
7985
}
8086

87+
oaiClient := openai.NewClient(
88+
option.WithBaseURL(baseUrl),
89+
option.WithAPIKey(apiKey),
90+
)
91+
CheckOpenAIWorksV2(oaiClient, baseUrl, modelSlug, logger)
92+
8193
toolRegistry := initializeToolkitV2(db, projectService, cfg, logger)
8294
toolCallHandler := handler.NewToolCallHandlerV2(toolRegistry)
8395

webapp/_webapp/src/views/settings/setting-text-input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function createSettingsTextInput<K extends SettingKey>(settingKey: K) {
2929
password = false,
3030
}: SettingsTextInputProps) {
3131
const { settings, isUpdating, updateSettings } = useSettingStore();
32-
const { currentConversation, setCurrentConversation } = useConversationStore();
32+
const { setCurrentConversation } = useConversationStore();
3333
const [value, setValue] = useState<string>("");
3434
const [originalValue, setOriginalValue] = useState<string>("");
3535
const [isEditing, setIsEditing] = useState<boolean>(false);
@@ -59,7 +59,7 @@ export function createSettingsTextInput<K extends SettingKey>(settingKey: K) {
5959
// try to find a model that matches the current slug
6060
const currentSlugLower = latest.modelSlug.toLowerCase();
6161
const matchingModel = response.models.find(m =>
62-
currentSlugLower.includes(m.name.toLowerCase())
62+
currentSlugLower === m.name.toLowerCase()
6363
);
6464
// fall back to the first model in the list
6565
const newSlug = matchingModel?.slug ?? response.models[0].slug;

0 commit comments

Comments
 (0)