fix: build error without OPENAI_API_KEY

This commit is contained in:
DIYgod 2023-05-09 02:17:24 +01:00
parent 848c30635a
commit e1468a3f55
No known key found for this signature in database
1 changed files with 11 additions and 6 deletions

View File

@ -10,16 +10,21 @@ import prisma from "~/lib/prisma.server"
import { cacheGet } from "~/lib/redis.server"
import { NextServerResponse, getQuery } from "~/lib/server-helper"
const model = new OpenAI({
openAIApiKey: process.env.OPENAI_API_KEY,
modelName: "gpt-3.5-turbo",
temperature: 0.3,
maxTokens: 400,
})
let model: OpenAI | undefined
if (process.env.OPENAI_API_KEY) {
model = new OpenAI({
openAIApiKey: process.env.OPENAI_API_KEY,
modelName: "gpt-3.5-turbo",
temperature: 0.3,
maxTokens: 400,
})
}
const chains = new Map<string, AnalyzeDocumentChain>()
const getOriginalSummary = async (cid: string, lang: string) => {
if (!model) return
try {
let { content } = await (await fetch(toGateway(`ipfs://${cid}`))).json()