Merge branch 'main' into recipes

This commit is contained in:
Sam Becker 2025-02-19 19:33:46 -06:00
commit 3feb35cef9
2 changed files with 7 additions and 4 deletions

View File

@ -10,7 +10,7 @@ import {
import { removeBase64Prefix } from '@/utility/image';
import { cleanUpAiTextResponse } from '@/photo/ai';
const redis = Redis.fromEnv();
const redis = HAS_REDIS_STORAGE ? Redis.fromEnv() : undefined;
const RATE_LIMIT_IDENTIFIER = 'openai-image-query';
const RATE_LIMIT_MAX_QUERIES_PER_HOUR = 100;
@ -20,7 +20,7 @@ const openai = AI_TEXT_GENERATION_ENABLED
? createOpenAI({ apiKey: process.env.OPENAI_SECRET_KEY })
: undefined;
const ratelimit = HAS_REDIS_STORAGE
const ratelimit = redis
? new Ratelimit({
redis,
limiter: Ratelimit.slidingWindow(RATE_LIMIT_MAX_QUERIES_PER_HOUR, '1h'),

View File

@ -1,5 +1,8 @@
import { Redis } from '@upstash/redis';
import { HAS_REDIS_STORAGE } from '@/app/config';
const redis = Redis.fromEnv();
const redis = HAS_REDIS_STORAGE ? Redis.fromEnv() : undefined;
export const testRedisConnection = () => redis.get('test');
export const testRedisConnection = () => redis
? redis.get('test')
: Promise.reject(false);