Switch LLM provider to DeepSeek v4 Pro
- Create shared openai client (src/lib/openai.ts) pointing to api.deepseek.com - Replace all gpt-4o-mini model references with deepseek-v4-pro - Refactor 3 API routes to use shared client instead of inline OpenAI() calls - Add OPENAI_BASE_URL env var for endpoint configuration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
cef29d40bd
commit
4e83ce95cd
@@ -1,5 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import OpenAI from "openai";
|
||||
import { openai } from "@/lib/openai";
|
||||
import { generateAllWeeklySummaries } from "@/lib/engines/summary-generator";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
@@ -18,8 +18,6 @@ export async function POST(req: Request) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
|
||||
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
||||
|
||||
try {
|
||||
const results = await generateAllWeeklySummaries(openai);
|
||||
const succeeded = results.filter((r) => r.success).length;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { auth } from "@clerk/nextjs/server";
|
||||
import { NextResponse } from "next/server";
|
||||
import OpenAI from "openai";
|
||||
import { openai } from "@/lib/openai";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { processReflection } from "@/lib/engines/reflection-analyzer";
|
||||
import { computeStateUpdate } from "@/lib/engines/progress-tracker";
|
||||
@@ -49,7 +49,6 @@ export async function POST(req: Request) {
|
||||
);
|
||||
}
|
||||
|
||||
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
||||
|
||||
// Process reflection through LLM #2
|
||||
const reflection = await processReflection(
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { auth } from "@clerk/nextjs/server";
|
||||
import { NextResponse } from "next/server";
|
||||
import OpenAI from "openai";
|
||||
import { openai } from "@/lib/openai";
|
||||
import { generateDailyTask } from "@/lib/engines/task-selector";
|
||||
|
||||
export async function POST() {
|
||||
const { userId } = await auth();
|
||||
if (!userId) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
|
||||
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
||||
|
||||
try {
|
||||
const result = await generateDailyTask(userId, openai);
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ export async function analyzeReflection(
|
||||
|
||||
try {
|
||||
const response = await openai.chat.completions.create({
|
||||
model: "gpt-4o-mini",
|
||||
model: "deepseek-v4-pro",
|
||||
messages: [
|
||||
{ role: "system", content: REFLECTION_PROMPT },
|
||||
{
|
||||
|
||||
@@ -106,7 +106,7 @@ export async function generateWeeklySummary(
|
||||
|
||||
try {
|
||||
const response = await openai.chat.completions.create({
|
||||
model: "gpt-4o-mini",
|
||||
model: "deepseek-v4-pro",
|
||||
messages: [
|
||||
{ role: "system", content: SUMMARY_PROMPT },
|
||||
{
|
||||
|
||||
@@ -123,7 +123,7 @@ export async function generateTask(
|
||||
|
||||
try {
|
||||
const response = await openai.chat.completions.create({
|
||||
model: "gpt-4o-mini",
|
||||
model: "deepseek-v4-pro",
|
||||
messages: [
|
||||
{ role: "system", content: TASK_PROMPT },
|
||||
{
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import OpenAI from "openai";
|
||||
|
||||
const baseURL = process.env.OPENAI_BASE_URL || "https://api.deepseek.com";
|
||||
|
||||
export const openai = new OpenAI({
|
||||
apiKey: process.env.OPENAI_API_KEY,
|
||||
baseURL,
|
||||
});
|
||||
+1
-1
@@ -43,7 +43,7 @@ export async function llmSafetyCheck(
|
||||
): Promise<SafetyResult> {
|
||||
try {
|
||||
const response = await openai.chat.completions.create({
|
||||
model: "gpt-4o-mini",
|
||||
model: "deepseek-v4-pro",
|
||||
messages: [
|
||||
{ role: "system", content: SELF_REVIEW_PROMPT },
|
||||
{ role: "user", content: text },
|
||||
|
||||
Reference in New Issue
Block a user