Skip to content

Commit

Permalink
Migrate from Vercel Redis to Redis standalone client
Browse files Browse the repository at this point in the history
  • Loading branch information
KastanDay committed Dec 19, 2024
1 parent 5e59e97 commit 5a92142
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ai_ta_backend/service/project_service.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os

import redis
import requests
from injector import inject

Expand All @@ -23,6 +24,8 @@ def __init__(self, sql_db: SQLDatabase, posthog_service: PosthogService, sentry_
self.posthog = posthog_service
self.sentry = sentry_service

self.redis_client = redis.Redis.from_url(os.environ['REDIS_URL'], db=0)

def generate_json_schema(self, project_name: str, project_description: str | None) -> None:
# Generate metadata schema using project_name and project_description
json_schema = generate_schema_from_project_description(project_name, project_description)
Expand Down Expand Up @@ -93,8 +96,7 @@ def create_project(self, project_name: str, project_description: str | None, pro
llm_val[row['providerName']] = row['providerBodyNoModels']

# Insert the pre-assigned API keys into Redis
set_llm_url = str(os.environ['KV_REST_API_URL']) + f"/set/{redis_key}"
set_response = requests.post(set_llm_url, headers=headers, data=json.dumps(llm_val))
self.redis_client.set(redis_key, json.dumps(llm_val))

# Check the response status
if set_response.status_code == 200:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ boto3==1.28.79
qdrant-client==1.7.3
supabase==2.5.3
minio==7.2.12
"redis[hiredis]"

# Logging
posthog==3.1.0
Expand Down

0 comments on commit 5a92142

Please sign in to comment.