-
-
Notifications
You must be signed in to change notification settings - Fork 7
fix(resolution-search): resolve TypeError in webpack-runtime by refactoring utils and config #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a9df82a
c27136d
be9d110
eee1679
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,103 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { getSelectedModel } from '@/lib/actions/users' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { createOpenAI } from '@ai-sdk/openai' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { createGoogleGenerativeAI } from '@ai-sdk/google' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { createXai } from '@ai-sdk/xai'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export async function getModel(requireVision: boolean = false) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Check for specific API model override | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (process.env.SPECIFIC_API_MODEL) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const provider = process.env.SPECIFIC_API_MODEL.split(':')[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const modelId = process.env.SPECIFIC_API_MODEL.split(':').slice(1).join(':'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (provider === 'openai') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return createOpenAI({ apiKey: process.env.OPENAI_API_KEY })(modelId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (provider === 'google') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return createGoogleGenerativeAI({ apiKey: process.env.GEMINI_3_PRO_API_KEY })(modelId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if (provider === 'xai') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return createXai({ apiKey: process.env.XAI_API_KEY })(modelId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
5
to
21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Also, the override path bypasses SuggestionCentralize parsing/validation once, fail fast with a clear error, and optionally support a simple vision suffix or separate env var. export async function getModel(requireVision = false) {
const specific = process.env.SPECIFIC_API_MODEL;
if (specific) {
const idx = specific.indexOf(':');
if (idx <= 0 || idx === specific.length - 1) {
throw new Error(
`Invalid SPECIFIC_API_MODEL format. Expected "provider:modelId", got "${specific}".`
);
}
const provider = specific.slice(0, idx);
const modelId = specific.slice(idx + 1);
switch (provider) {
case 'openai':
return createOpenAI({ apiKey: process.env.OPENAI_API_KEY })(modelId);
case 'google':
return createGoogleGenerativeAI({ apiKey: process.env.GEMINI_3_PRO_API_KEY })(modelId);
case 'xai':
return createXai({ apiKey: process.env.XAI_API_KEY })(modelId);
default:
throw new Error(`Unsupported SPECIFIC_API_MODEL provider: ${provider}`);
}
}
// ... existing selectedModel logic
}Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this suggestion. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| const selectedModel = await getSelectedModel(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| const xaiApiKey = process.env.XAI_API_KEY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const gemini3ProApiKey = process.env.GEMINI_3_PRO_API_KEY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const awsAccessKeyId = process.env.AWS_ACCESS_KEY_ID; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const awsSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const awsRegion = process.env.AWS_REGION; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const bedrockModelId = process.env.BEDROCK_MODEL_ID || (requireVision ? 'anthropic.claude-3-5-sonnet-20241022-v2:0' : 'anthropic.claude-3-5-sonnet-20241022-v2:0'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const openaiApiKey = process.env.OPENAI_API_KEY; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
25
to
32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
requireVision ? 'anthropic.claude-3-5-sonnet-20241022-v2:0' : 'anthropic.claude-3-5-sonnet-20241022-v2:0'This is dead logic and makes it look like vision selection is implemented when it isn’t. SuggestionEither remove const bedrockModelId =
process.env.BEDROCK_MODEL_ID ?? 'anthropic.claude-3-5-sonnet-20241022-v2:0';(or) const bedrockModelId = process.env.BEDROCK_MODEL_ID ??
(requireVision
? 'anthropic.claude-3-5-sonnet-20241022-v2:0' // vision-capable
: 'anthropic.claude-3-5-haiku-20241022-v1:0');Reply with "@CharlieHelps yes please" if you'd like me to add a commit with this suggestion. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (selectedModel) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch (selectedModel) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| case 'Grok 4.2': | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (xaiApiKey) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const xai = createXai({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| apiKey: xaiApiKey, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseURL: 'https://api.x.ai/v1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return xai(requireVision ? 'grok-vision-beta' : 'grok-beta'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| case 'Gemini 3': | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (gemini3ProApiKey) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const google = createGoogleGenerativeAI({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| apiKey: gemini3ProApiKey, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return google(requireVision ? 'gemini-1.5-pro' : 'gemini-1.5-pro'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| case 'GPT-5.1': | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (openaiApiKey) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const openai = createOpenAI({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| apiKey: openaiApiKey, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return openai('gpt-4o'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
34
to
62
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: cat -n lib/utils/ai-model.tsRepository: QueueLab/QCX Length of output: 4119 🌐 Web query:
💡 Result: As of February 2026, the Vercel AI SDK xAI provider (
Example: import { xai } from "@ai-sdk/xai";
// text
const model = xai("grok-4-latest");
// vision (for image input in AI SDK docs)
const visionModel = xai.responses("grok-2-vision-latest");
``` ([ai-sdk.dev](https://ai-sdk.dev/providers/ai-sdk-providers/xai))
Citations:
- 1: https://ai-sdk.dev/providers/ai-sdk-providers/xai
- 2: https://ai-sdk.dev/providers/ai-sdk-providers/xai
- 3: https://ai-sdk.dev/providers/ai-sdk-providers/xai
- 4: https://ai-sdk.dev/providers/ai-sdk-providers/xai
- 5: https://ai-sdk.dev/providers/ai-sdk-providers/xai
---
🌐 Web query:
`Google Gemini 3 Pro current model ID 2026 ai-sdk gemini-1.5-pro`
💡 Result:
As of **February 4, 2026**, the **Gemini API** “Gemini 3 Pro” model ID you’d pass to an AI SDK is:
- **`gemini-3-pro-preview`** (Gemini 3 Pro Preview) [1][2]
(For the image-capable variant: **`gemini-3-pro-image-preview`**.) [1][2]
**Sources:** [1] [2]
---
🌐 Web query:
`OpenAI GPT-5.1 model ID 2026 gpt-4o current version`
💡 Result:
- **GPT‑5.1 (API) model ID (alias):** `gpt-5.1`
**Snapshot (versioned model ID):** `gpt-5.1-2025-11-13` (this is the only listed snapshot as of Feb 4, 2026). [1]
- **GPT‑4o (API) current model ID (alias):** `gpt-4o`
**Latest listed snapshot (versioned model ID):** `gpt-4o-2024-11-20` (newest date among the snapshots shown). [2]
**Sources:**
[1] https://platform.openai.com/docs/models/gpt-5.1/
[2] https://platform.openai.com/docs/models/gpt-4o
---
</details>
**Fix model ID mismatches in the user-facing labels and address structured-output safety.**
The labels "Grok 4.2", "Gemini 3", and "GPT-5.1" do not match the actual model IDs returned:
- **"Gemini 3"** (line 43) returns `gemini-1.5-pro`, which is outdated. Use `gemini-3-pro-preview` for the current Gemini 3 Pro model.
- **"GPT-5.1"** (line 51) returns `gpt-4o` instead of `gpt-5.1`. Users selecting "GPT-5.1" should receive the GPT-5.1 model, not GPT-4o.
- **"Grok 4.2"** (line 34) returns `grok-beta`, a generic beta version. Consider using `grok-4-latest` for consistency.
Additionally, the default fallback order (lines 62–84) prioritizes xAI (Grok) first. Per established guidance, structured-output flows using `generateObject` and `streamObject` must use OpenAI (`gpt-4o`), not xAI models which lack reliable structured-output support. Review whether this function is used in structured-output contexts and adjust the fallback order accordingly.
<details>
<summary>🤖 Prompt for AI Agents</summary>In |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Default behavior: Grok -> Gemini -> Bedrock -> OpenAI | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (xaiApiKey) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const xai = createXai({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| apiKey: xaiApiKey, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| baseURL: 'https://api.x.ai/v1', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return xai(requireVision ? 'grok-vision-beta' : 'grok-beta'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.warn('xAI API unavailable, falling back to next provider'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (gemini3ProApiKey) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const google = createGoogleGenerativeAI({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| apiKey: gemini3ProApiKey, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return google(requireVision ? 'gemini-1.5-pro' : 'gemini-1.5-pro'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.warn('Gemini 3 Pro API unavailable, falling back to next provider:', error); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
66
to
90
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, locate and examine the ai-model.ts file
find . -name "ai-model.ts" -type fRepository: QueueLab/QCX Length of output: 79 🏁 Script executed: # Search for calls to getModel to see if structured outputs are needed
rg "getModel\(" --context=3Repository: QueueLab/QCX Length of output: 4936 🏁 Script executed: # Search for streamObject and generateObject usage
rg "streamObject|generateObject" --context=2Repository: QueueLab/QCX Length of output: 3583 🏁 Script executed: cat -n lib/utils/ai-model.tsRepository: QueueLab/QCX Length of output: 4119 🌐 Web query:
💡 Result: Yes—both Notes / constraints from xAI’s docs:
🌐 Web query:
💡 Result: Model comparison (xAI API)
Using Structured Outputs from the Vercel AI SDK
Practical implication:
Sources: Citations:
Add Lines 62–84 prioritize xAI (grok-beta/grok-vision-beta) when available, but multiple call sites use Add a 🔧 Suggested safeguard for structured output-export async function getModel(requireVision: boolean = false) {
+export async function getModel(
+ requireVision: boolean = false,
+ requireStructuredOutput: boolean = false
+) {
// Check for specific API model override
if (process.env.SPECIFIC_API_MODEL) {
const provider = process.env.SPECIFIC_API_MODEL.split(':')[0];
const modelId = process.env.SPECIFIC_API_MODEL.split(':').slice(1).join(':');
@@
- const openaiApiKey = process.env.OPENAI_API_KEY;
+ const openaiApiKey = process.env.OPENAI_API_KEY;
+
+ if (requireStructuredOutput && openaiApiKey) {
+ const openai = createOpenAI({ apiKey: openaiApiKey });
+ return openai('gpt-4o');
+ }🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (awsAccessKeyId && awsSecretAccessKey) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const bedrock = createAmazonBedrock({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| bedrockOptions: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| region: awsRegion, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| credentials: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| accessKeyId: awsAccessKeyId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| secretAccessKey: awsSecretAccessKey, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return bedrock(bedrockModelId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+92
to
+103
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's locate and read the ai-model.ts file
fd -t f ai-model.tsRepository: QueueLab/QCX Length of output: 77 🏁 Script executed: # Read the ai-model.ts file with line numbers
cat -n lib/utils/ai-model.tsRepository: QueueLab/QCX Length of output: 4490 🏁 Script executed: # Check if there's any error handling around Bedrock initialization or other Bedrock usage in the codebase
rg -i bedrock -A 5 -B 5Repository: QueueLab/QCX Length of output: 10664 Add AWS region check to Bedrock initialization guard. Lines 92–103 check AWS credentials but not - if (awsAccessKeyId && awsSecretAccessKey) {
+ if (awsAccessKeyId && awsSecretAccessKey && awsRegion) {
const { createAmazonBedrock } = await import('@ai-sdk/amazon-bedrock');
const bedrock = createAmazonBedrock({
bedrockOptions: {
region: awsRegion,
credentials: {
accessKeyId: awsAccessKeyId,
secretAccessKey: awsSecretAccessKey,
},
},
});
return bedrock(bedrockModelId);
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| const openai = createOpenAI({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| apiKey: openaiApiKey, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| return openai('gpt-4o'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+107
to
+111
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Guard against missing provider keys before OpenAI fallback. Line 99-103 instantiates OpenAI even if 🛡️ Explicit guard for missing keys- const openai = createOpenAI({
- apiKey: openaiApiKey,
- });
- return openai('gpt-4o');
+ if (!openaiApiKey) {
+ throw new Error('No AI provider API key configured');
+ }
+ const openai = createOpenAI({ apiKey: openaiApiKey });
+ return openai('gpt-4o');🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: QueueLab/QCX
Length of output: 79
🏁 Script executed:
Repository: QueueLab/QCX
Length of output: 4490
Add API key validation for the
SPECIFIC_API_MODELoverride path.Lines 11–19 instantiate providers without validating required API keys. Unlike the fallback paths below (lines 33–110), this creates a consistency issue and allows opaque SDK auth failures. Add explicit checks before provider instantiation.
🛡️ Suggested guardrails for override path
if (process.env.SPECIFIC_API_MODEL) { const provider = process.env.SPECIFIC_API_MODEL.split(':')[0]; const modelId = process.env.SPECIFIC_API_MODEL.split(':').slice(1).join(':'); if (provider === 'openai') { + if (!process.env.OPENAI_API_KEY) { + throw new Error('SPECIFIC_API_MODEL=openai requires OPENAI_API_KEY'); + } const { createOpenAI } = await import('@ai-sdk/openai'); return createOpenAI({ apiKey: process.env.OPENAI_API_KEY })(modelId); } else if (provider === 'google') { + if (!process.env.GEMINI_3_PRO_API_KEY) { + throw new Error('SPECIFIC_API_MODEL=google requires GEMINI_3_PRO_API_KEY'); + } const { createGoogleGenerativeAI } = await import('@ai-sdk/google'); return createGoogleGenerativeAI({ apiKey: process.env.GEMINI_3_PRO_API_KEY })(modelId); } else if (provider === 'xai') { + if (!process.env.XAI_API_KEY) { + throw new Error('SPECIFIC_API_MODEL=xai requires XAI_API_KEY'); + } const { createXai } = await import('@ai-sdk/xai'); return createXai({ apiKey: process.env.XAI_API_KEY })(modelId); } }🤖 Prompt for AI Agents