File size: 1,230 Bytes
a2ff264
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from backend.services.DataReader import DataReader
from backend.services.ChunkGenerator import ChunkGenerator
from backend.services.QuestionGenerator import QuestionGenerator
from backend.models.AIParamModel import AIParam
from backend.models.AIResponseModel import AIResult


class TextReaderQuestionGenerator:
    def __init__(self):
        self.reader = DataReader()
        self.chunker = ChunkGenerator()
        self.qgen = QuestionGenerator()
        
        
    async def textreader_question_generator(self, text: str) -> dict:
        ai_param = AIParam()
        if len(text) <= 100:
            print("Text length is less than 100 characters.")
            all_questions = []
            questions = self.qgen.generate_questions_advance(text, ai_param)
            all_questions.append({
                "questions": questions
            })
                
            return  all_questions
        else:
            print("Text length is less than 100 characters.")
            all_questions = []
            questions = self.qgen.generate_questions_advance(text, ai_param)
            all_questions.append({
                "questions": questions
            })
                
            return  all_questions