diff --git a/backend/src/llm/openai.py b/backend/src/llm/openai.py index cd4fc147..a98c30ea 100644 --- a/backend/src/llm/openai.py +++ b/backend/src/llm/openai.py @@ -88,17 +88,8 @@ async def __upload_files(self, files: list[LLMFile]) -> list[str]: file_ids = [] for file in files: logger.info(f"Uploading file '{file.file_name}' to OpenAI") - if isinstance(file.file, (PathLike, str)): - file_path = Path(file.file) - with file_path.open("rb") as f: - file_bytes = f.read() - elif isinstance(file.file, bytes): - file_bytes = file.file - else: - logger.error(f"Unsupported file type for '{file.file_name}'") - continue - file = await client.files.create(file=(file.file_name, file_bytes), purpose="assistants") - # file = await client.files.create(file=(file.file_name, file.file), purpose="assistants") - file_ids.append(file.id) + file = (file.file_name, file.file) if isinstance(file.file, bytes) else file.file + response = await client.files.create(file=file, purpose="assistants") + file_ids.append(response.id) return file_ids