mirror of
https://github.com/massbug/judge4c.git
synced 2025-05-17 23:12:23 +00:00
refactor(actions): 优化 AI改进代码中的数据库查询
- 移除了不必要的 PrismaClient 实例化 - 更新了 problemId 字段的使用,使其与数据库结构保持一致
This commit is contained in:
parent
a89864e70e
commit
c8586c671c
@ -7,8 +7,7 @@ import {
|
|||||||
} from "@/types/ai-improve";
|
} from "@/types/ai-improve";
|
||||||
import { openai } from "@/lib/ai";
|
import { openai } from "@/lib/ai";
|
||||||
import { CoreMessage, generateText } from "ai";
|
import { CoreMessage, generateText } from "ai";
|
||||||
import { PrismaClient } from '@/generated/client';
|
import prisma from '@/generated/client';
|
||||||
const prisma = new PrismaClient();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用AI优化代码
|
* 调用AI优化代码
|
||||||
@ -25,7 +24,7 @@ export const optimizeCode = async (
|
|||||||
if (input.problemId) {
|
if (input.problemId) {
|
||||||
try {
|
try {
|
||||||
const problem = await prisma.problem.findUnique({
|
const problem = await prisma.problem.findUnique({
|
||||||
where: { problemId: input.problemId },
|
where: { id: input.problemId },
|
||||||
});
|
});
|
||||||
if (problem) {
|
if (problem) {
|
||||||
problemDetails = `
|
problemDetails = `
|
||||||
|
Loading…
Reference in New Issue
Block a user