Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 23 additions & 11 deletions internal/services/toolkit/client/client_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,33 @@ func NewAIClientV2(
logger *logger.Logger,
) *AIClientV2 {
database := db.Database("paperdebugger")

llmProvider := &models.LLMProviderConfig{
APIKey: cfg.OpenAIAPIKey,
}

var baseUrl string
var apiKey string
var modelSlug string

if cfg.InferenceBaseURL != "" && cfg.InferenceAPIKey != "" {
oaiClient := openai.NewClient(
option.WithBaseURL(cfg.InferenceBaseURL+"/openrouter"),
option.WithAPIKey(cfg.InferenceAPIKey),
)
CheckOpenAIWorksV2(oaiClient, cfg.InferenceBaseURL+"/openrouter", "openai/gpt-5-nano", logger)
// User specified their own API key, use the OpenAI-compatible endpoint
if llmProvider != nil && llmProvider.IsCustom() {
baseUrl = cfg.OpenAIBaseURL
apiKey = cfg.OpenAIAPIKey
modelSlug = "gpt-5-nano"
// Use the default inference endpoint
} else {
oaiClient := openai.NewClient(
option.WithBaseURL(cfg.OpenAIBaseURL),
option.WithAPIKey(cfg.OpenAIAPIKey),
)
CheckOpenAIWorksV2(oaiClient, cfg.OpenAIBaseURL, "gpt-5-nano", logger)
baseUrl = cfg.InferenceBaseURL + "/openrouter"
apiKey = cfg.InferenceAPIKey
modelSlug = "openai/gpt-5-nano"
}

oaiClient := openai.NewClient(
option.WithBaseURL(baseUrl),
option.WithAPIKey(apiKey),
)
CheckOpenAIWorksV2(oaiClient, baseUrl, modelSlug, logger)

toolRegistry := initializeToolkitV2(db, projectService, cfg, logger)
toolCallHandler := handler.NewToolCallHandlerV2(toolRegistry)

Expand Down
4 changes: 2 additions & 2 deletions webapp/_webapp/src/views/settings/setting-text-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function createSettingsTextInput<K extends SettingKey>(settingKey: K) {
password = false,
}: SettingsTextInputProps) {
const { settings, isUpdating, updateSettings } = useSettingStore();
const { currentConversation, setCurrentConversation } = useConversationStore();
const { setCurrentConversation } = useConversationStore();
const [value, setValue] = useState<string>("");
const [originalValue, setOriginalValue] = useState<string>("");
const [isEditing, setIsEditing] = useState<boolean>(false);
Expand Down Expand Up @@ -59,7 +59,7 @@ export function createSettingsTextInput<K extends SettingKey>(settingKey: K) {
// try to find a model that matches the current slug
const currentSlugLower = latest.modelSlug.toLowerCase();
const matchingModel = response.models.find(m =>
currentSlugLower.includes(m.name.toLowerCase())
currentSlugLower === m.name.toLowerCase()
);
// fall back to the first model in the list
const newSlug = matchingModel?.slug ?? response.models[0].slug;
Expand Down