Spaces:
Running
Running
File size: 769 Bytes
a231872 9598ec0 a231872 9598ec0 a231872 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
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
@api_view(['GET'])
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)
|