Skip to content

Commit

Permalink
updated the file name and take from request; make it optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishankoradia committed Apr 25, 2024
1 parent 7ab0c1a commit 026a347
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions llm/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ def post(self, request, format=None):
openai.api_key = org.openai_key

request_file = request.data["file"]
file_name = (
request.data["filename"].strip()
if "filename" in request.data
else request_file.name
)

logger.info("Recognized file with name %s", file_name)

if "category_id" not in request.data:
return JsonResponse(
Expand All @@ -270,12 +277,12 @@ def post(self, request, format=None):

logger.info("Using Knowledge Category : %s", knowledge_cat)

logger.info("Uploading file %s", request_file.name)
logger.info("Uploading file %s", file_name)

# Create the file object
file = File.objects.create(
knowledge_category=knowledge_cat,
name=request_file.name,
name=file_name,
)

pdf_reader = PdfReader(request_file)
Expand Down

0 comments on commit 026a347

Please sign in to comment.