Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/app/api/chat-rooms/[id]/messages/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {NextRequest, NextResponse} from "next/server";
import prisma, {Prisma} from "@/lib/prisma";
import {auth} from "@/auth";
import {decrypt} from "@/lib/encryption";
import {currentDeploymentEnv} from "@/lib/current-deployment-env";
import {ChatOpenAI} from "@langchain/openai";
import {ChatAnthropic} from "@langchain/anthropic";
Expand Down Expand Up @@ -90,7 +89,7 @@ export async function POST(

let apiKey: string
if (currentDeploymentEnv === 'local') {
apiKey = decrypt(llmProvider.apiKey)
apiKey = llmProvider.apiKey
} else if (currentDeploymentEnv === 'cloud') {
Comment on lines 91 to 93

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a comment here explaining why encryption is disabled in the local environment. This will help future developers understand the reasoning behind this conditional logic and potential security implications.

      apiKey = llmProvider.apiKey // Encryption disabled in local environment due to IV error

switch (llmProvider.providerId) {
case 'openai':
Expand Down
3 changes: 1 addition & 2 deletions src/app/api/llm-providers/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {NextRequest, NextResponse} from "next/server";
import prisma from "@/lib/prisma";
import {LLMProvider} from "@/app/api/llm-providers/route";
import {encrypt} from '@/lib/encryption'

export interface LLMProviderPatchRequest {
apiKey?: string
Expand All @@ -19,7 +18,7 @@ export async function PATCH(
const body: LLMProviderPatchRequest = await req.json()

// API key encryption
if (body.apiKey) body.apiKey = encrypt(body.apiKey)
if (body.apiKey) body.apiKey = body.apiKey

Comment on lines 20 to 22

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a comment explaining why encryption is bypassed here. This is important for maintainability and understanding the code's behavior in different environments.

Suggested change
// API key encryption
if (body.apiKey) body.apiKey = encrypt(body.apiKey)
if (body.apiKey) body.apiKey = body.apiKey
if (body.apiKey) body.apiKey = body.apiKey // Encryption bypassed due to IV error in local LLMs

const llmProvider = await prisma.lLMProvider.update({
where: {id},
Expand Down