Skip to content

Commit 61a6e13

Browse files
authored
Merge pull request #628 from thecodacus/console-error-fox-due-to-duplicate-keys-in-model-selector
chore: console error fix due to duplicate keys and logs cleanup
2 parents 5563044 + 7ba7345 commit 61a6e13

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

app/components/chat/BaseChat.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
147147
return () => clearInterval(interval);
148148
}, [PROVIDER_LIST]);
149149

150-
console.log(transcript);
150+
useEffect(() => {
151+
console.log(transcript);
152+
}, [transcript]);
151153
useEffect(() => {
152154
// Load API keys from cookies on component mount
153155
try {

app/components/chat/ModelSelector.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ export const ModelSelector = ({
121121
>
122122
{[...modelList]
123123
.filter((e) => e.provider == provider?.name && e.name)
124-
.map((modelOption) => (
125-
<option key={modelOption.name} value={modelOption.name}>
124+
.map((modelOption, index) => (
125+
<option key={index} value={modelOption.name}>
126126
{modelOption.label}
127127
</option>
128128
))}

app/utils/constants.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Cookies from 'js-cookie';
22
import type { ModelInfo, OllamaApiResponse, OllamaModel } from './types';
33
import type { ProviderInfo } from '~/types/model';
4+
import { createScopedLogger } from './logger';
45

56
export const WORK_DIR_NAME = 'project';
67
export const WORK_DIR = `/home/${WORK_DIR_NAME}`;
@@ -10,6 +11,8 @@ export const PROVIDER_REGEX = /\[Provider: (.*?)\]\n\n/;
1011
export const DEFAULT_MODEL = 'claude-3-5-sonnet-latest';
1112
export const PROMPT_COOKIE_KEY = 'cachedPrompt';
1213

14+
const logger = createScopedLogger('Constants');
15+
1316
const PROVIDER_LIST: ProviderInfo[] = [
1417
{
1518
name: 'Anthropic',
@@ -383,8 +386,8 @@ async function getOllamaModels(): Promise<ModelInfo[]> {
383386
provider: 'Ollama',
384387
maxTokenAllowed: 8000,
385388
}));
386-
} catch (e) {
387-
console.error('Error getting Ollama models:', e);
389+
} catch (e: any) {
390+
logger.warn('Failed to get Ollama models: ', e.message || '');
388391
return [];
389392
}
390393
}
@@ -471,8 +474,8 @@ async function getLMStudioModels(): Promise<ModelInfo[]> {
471474
label: model.id,
472475
provider: 'LMStudio',
473476
}));
474-
} catch (e) {
475-
console.error('Error getting LMStudio models:', e);
477+
} catch (e: any) {
478+
logger.warn('Failed to get LMStudio models: ', e.message || '');
476479
return [];
477480
}
478481
}
@@ -491,7 +494,7 @@ async function initializeModelList(): Promise<ModelInfo[]> {
491494
}
492495
}
493496
} catch (error: any) {
494-
console.warn(`Failed to fetch apikeys from cookies:${error?.message}`);
497+
logger.warn(`Failed to fetch apikeys from cookies: ${error?.message}`);
495498
}
496499
MODEL_LIST = [
497500
...(

0 commit comments

Comments
 (0)