Skip to content

Conversation

@hotyoyo
Copy link

@hotyoyo hotyoyo commented Dec 18, 2025

Summary

This PR centralizes all AI model configurations into a single file and fixes critical bugs where invalid model names were being used.

Problem

The codebase had several issues:

  1. Invalid model names: gpt-5-mini and gpt-5.2 do not exist and would cause API failures
  2. Scattered model configurations: Model names were hardcoded across 8+ files, making updates difficult
  3. No single source of truth: Changes required modifying multiple files

Solution

Created src/lib/models.ts with:

  • CHAT_MODELS - Chat completion models (GPT-4o, GPT-4o-mini)
  • EMBEDDING_MODELS - Text embedding models (Ada-002)
  • TRANSCRIPTION_MODELS - Audio transcription models
  • DEFAULT_MODELS - Preset configurations for common use cases
  • TypeScript types for type safety

Changes

File Change
src/lib/models.ts New centralized model configuration
src/app/api/AIAssistant/services/webSearchAgent.ts Fix gpt-5-minigpt-4o-mini
src/app/api/AIAssistant/route.ts Fix gpt-5.2gpt-4o
src/app/api/predictive-document-analysis/services/analysisEngine.ts Fix gpt-5.2gpt-4o
src/app/api/predictive-document-analysis/services/referenceExtractor.ts Fix gpt-5.2gpt-4o
src/app/api/predictive-document-analysis/utils/embeddings.ts Use centralized constants
src/app/api/uploadDocument/route.ts Use centralized constants
src/app/api/study-agent/chat/route.ts Use centralized constants
src/app/api/study-agent/speech-to-text/route.ts Use centralized constants

Usage Example

import { DEFAULT_MODELS, CHAT_MODELS } from "~/lib/models";

// Use default presets
const chat = new ChatOpenAI({
  modelName: DEFAULT_MODELS.ANALYSIS, // gpt-4o
});

// Or specific models
const embeddings = new OpenAIEmbeddings({
  model: DEFAULT_MODELS.EMBEDDING, // text-embedding-ada-002
});

Benefits

  • Bug fix: Prevents API failures from invalid model names
  • Maintainability: Single place to update model versions
  • Type safety: TypeScript types for model selections
  • Documentation: Clear descriptions of each model"s use case

Breaking Changes

None - This is a refactor with bug fixes. All existing functionality is preserved.

- Create src/lib/models.ts with centralized model configuration
- Fix invalid model name 'gpt-5-mini' -> 'gpt-4o-mini' in webSearchAgent.ts
- Fix invalid model name 'gpt-5.2' -> 'gpt-4o' in route.ts, analysisEngine.ts, referenceExtractor.ts
- Replace all hardcoded model names with DEFAULT_MODELS constants
- Add CHAT_MODELS, EMBEDDING_MODELS, and TRANSCRIPTION_MODELS exports
- Add TypeScript types for model selections

This change improves maintainability by providing a single source of truth
for all AI model configurations and fixes API calls that would fail due to
non-existent model names.
@vercel
Copy link

vercel bot commented Dec 18, 2025

@hotyoyo is attempting to deploy a commit to the Timothy Lin's projects Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Dec 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
pdr-ai-v2 Ready Ready Preview, Comment Dec 19, 2025 7:28pm

@Deodat-Lawson
Copy link
Owner

Good idea. I still want to keep everything updated to be using GPT 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants