Spaces:
Running
Running
from rest_framework.decorators import api_view | |
from rest_framework.response import Response | |
from .engine import execute_prompt, bundle_function, propose_recipes, compute_reduced_prices | |
import json | |
def recipe_generate_route(request): | |
isLocal = False | |
try: | |
json_objs = compute_reduced_prices() | |
obj= json.loads(json_objs) | |
bundle_articles = bundle_function(obj[:10]) | |
result = execute_prompt(propose_recipes(bundle_articles), False) | |
except (FileNotFoundError, json.JSONDecodeError) as e: | |
return Response({'error': str(e)}, status=500) | |
except Exception as e: | |
print(f"An error occurred: {e}") | |
return Response({'error': 'Something went wrong'}, status=500) | |
return Response(result) | |