Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cookbook/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,7 @@ def aiproperties(self, request, pk):
ai_response = completion(**ai_request)

response_text = ai_response.choices[0].message.content

response_text = re.sub(r"^```(?:json)?\s*\n?(.*?)\n?```\s*$", r"\1", response_text.strip(), flags=re.DOTALL)
return Response(json.loads(response_text), status=status.HTTP_200_OK)
except LitellmTimeout:
response = {
Expand Down Expand Up @@ -2812,6 +2812,8 @@ def post(self, request, *args, **kwargs):
}
return Response(RecipeFromSourceResponseSerializer(context={'request': request}).to_representation(response), status=status.HTTP_400_BAD_REQUEST)
response_text = ai_response.choices[0].message.content

response_text = re.sub(r"^```(?:json)?\s*\n?(.*?)\n?```\s*$", r"\1", response_text.strip(), flags=re.DOTALL)

try:
data_json = json.loads(response_text)
Expand Down