Skip to content

Commit

Permalink
[KAN-101] gpt 기반 음식점 추천 데이터 redis batch
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkyoungdeok committed May 26, 2024
1 parent 0f61877 commit ef0e975
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions csv-to-gpt.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import os

import openai
import pymysql
Expand Down Expand Up @@ -80,12 +79,13 @@ def get_gpt_recommendations(user_data, restaurant_data):
def save_recommendations_to_redis(user_id, recommendations):
key = f"RECOMMENDATION:{user_id}"
redis_client.delete(key)
for recommendation in recommendations.split('\n'):
redis_client.rpush(key, recommendation)
redis_client.set(key, recommendations)
redis_client.expire(key, 3600 * 24 * 3)


def save_all_restaurants_to_redis(filtered_restaurants):
all_restaurant_ids = [str(restaurant[0]) for restaurant in filtered_restaurants]
all_restaurant_ids = [str(restaurant[0]) for restaurant in
filtered_restaurants]
recommendations_string = ','.join(all_restaurant_ids)
save_recommendations_to_redis(0, recommendations_string)

Expand Down

0 comments on commit ef0e975

Please sign in to comment.