Fixed grading ENCOA-274
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import asyncio
|
||||
import os
|
||||
from typing import Dict, Optional
|
||||
from uuid import uuid4
|
||||
|
||||
from ielts_be.configs.constants import GPTModels, TemperatureSettings
|
||||
from ielts_be.configs.constants import GPTModels, TemperatureSettings, FilePaths
|
||||
from ielts_be.helpers import TextHelper, ExercisesHelper, FileHelper
|
||||
from ielts_be.repositories import IFileStorage
|
||||
from ielts_be.services import ILLMService, IAIDetectorService
|
||||
@@ -54,19 +55,23 @@ class GradeWriting:
|
||||
})
|
||||
else:
|
||||
uuid = str(uuid4())
|
||||
name = attachment.split('/')[-1]
|
||||
name = attachment.split('%2F')[-1].split('?')[0]
|
||||
os.makedirs(f'./tmp/{uuid}/', exist_ok=True)
|
||||
out_path = f'./tmp/{uuid}/{name}'
|
||||
path = await self._file_storage.download_firebase_file(attachment, out_path)
|
||||
path = await self._file_storage.download_firebase_file(f'{FilePaths.WRITING_ATTACHMENTS}{name}', out_path)
|
||||
b64_image = await FileHelper.encode_image(path)
|
||||
messages.append(
|
||||
{
|
||||
"role": "user",
|
||||
"content": {
|
||||
"type": "image_url",
|
||||
"image_url": {
|
||||
"url": f"data:image/{name.split('.')[-1]};base64,{FileHelper.encode_image(path)}"
|
||||
}
|
||||
"content": [{
|
||||
"type": "image_url",
|
||||
"image_url": {
|
||||
"url": f"data:image/{name.split('.')[-1]};base64,{b64_image}"
|
||||
}
|
||||
}]
|
||||
}
|
||||
})
|
||||
)
|
||||
FileHelper.remove_directory(f'./tmp/{uuid}')
|
||||
|
||||
temperature = (
|
||||
TemperatureSettings.GRADING_TEMPERATURE
|
||||
|
||||
Reference in New Issue
Block a user