fix(openrouter): respect the requesting user's saved model config

generatePostText ignored the userId it received and always read an
arbitrary row via getAnyOpenrouterConfig() (LIMIT 1, no ORDER BY),
so a model chosen and saved in Settings could be shadowed by another
stale config row. Now it prefers the requesting user's own config,
falling back to the most recently updated shared one. Also swap the
retired anthropic/claude-3.5-sonnet default for a live OpenRouter slug.
This commit is contained in:
Claude committed 2026-07-14 05:49:31 +00:00
1 parent b00d88f6b0
commit 09b4e597ae
7 files changed
+11 -10

No files matched your search

+3 -2
View File
@@ -18,8 +18,9 @@ export class OpenRouterService {
private baseUrl = "https://openrouter.ai/api/v1/chat/completions";
async generatePostText(productInfo: ProductInfo, userId: string, modelOverride?: string): Promise<GeneratedText[]> {
// Get any available OpenRouter configuration (shared across all users)
const config = await storage.getAnyOpenrouterConfig();
// Prefer the requesting user's own configuration; fall back to the most
// recently saved shared configuration if this user hasn't set one up.
const config = (await storage.getOpenrouterConfig(userId)) || (await storage.getAnyOpenrouterConfig());
if (!config) {
throw new Error('Configuration OpenRouter non trouvée. Veuillez demander à un administrateur de configurer OpenRouter dans les Paramètres.');