Spaces:
Running
Running
luanpoppe
commited on
Commit
·
451f8a3
1
Parent(s):
5cb00b6
fix: .odt e axiom_instance
Browse files
_utils/langchain_utils/splitter_util.py
CHANGED
@@ -29,8 +29,12 @@ class SplitterUtils:
|
|
29 |
def load_odt_file(self, file_path: str):
|
30 |
textdoc = load(file_path)
|
31 |
all_paragraphs = textdoc.getElementsByType(P)
|
32 |
-
text =
|
33 |
-
|
|
|
|
|
|
|
|
|
34 |
|
35 |
|
36 |
class Splitter_Simple:
|
|
|
29 |
def load_odt_file(self, file_path: str):
|
30 |
textdoc = load(file_path)
|
31 |
all_paragraphs = textdoc.getElementsByType(P)
|
32 |
+
text = []
|
33 |
+
for p in all_paragraphs:
|
34 |
+
for node in p.childNodes:
|
35 |
+
if node.nodeType == node.TEXT_NODE:
|
36 |
+
text.append(node.data)
|
37 |
+
return "\n".join(text)
|
38 |
|
39 |
|
40 |
class Splitter_Simple:
|
gerar_documento/views.py
CHANGED
@@ -77,15 +77,15 @@ class GerarDocumentoView(AsyncAPIView):
|
|
77 |
class GerarDocumentoComPDFProprioView(AsyncAPIView):
|
78 |
parser_classes = [MultiPartParser]
|
79 |
serializer = {}
|
|
|
80 |
|
81 |
@extend_schema(
|
82 |
request=GerarDocumentoComPDFProprioSerializer,
|
83 |
)
|
84 |
async def post(self, request):
|
85 |
-
axiom_instance = Axiom()
|
86 |
print(f"\n\nDATA E HORA DA REQUISIÇÃO: {datetime.now()}")
|
87 |
-
axiom_instance.send_axiom("COMEÇOU NOVA REQUISIÇÃO")
|
88 |
-
axiom_instance.send_axiom(f"request.data: {request.data}")
|
89 |
serializer = GerarDocumentoComPDFProprioSerializer(data=request.data)
|
90 |
|
91 |
if serializer.is_valid(raise_exception=True):
|
@@ -93,13 +93,15 @@ class GerarDocumentoComPDFProprioView(AsyncAPIView):
|
|
93 |
obj = serializer.get_obj() # type: ignore
|
94 |
self.serializer = data
|
95 |
|
96 |
-
listaPDFs = handle_pdf_files_from_serializer(
|
|
|
|
|
97 |
|
98 |
-
resposta_llm = await gerar_documento(obj, listaPDFs, axiom_instance)
|
99 |
-
axiom_instance.send_axiom(f"resposta_llm: {resposta_llm}")
|
100 |
|
101 |
remove_pdf_temp_files(listaPDFs)
|
102 |
-
axiom_instance.send_axiom(
|
103 |
"PRÓXIMA LINHA ENVIA A RESPOSTA A QUEM FEZ A REQUISIÇÃO"
|
104 |
)
|
105 |
return Response({"resposta": resposta_llm})
|
|
|
77 |
class GerarDocumentoComPDFProprioView(AsyncAPIView):
|
78 |
parser_classes = [MultiPartParser]
|
79 |
serializer = {}
|
80 |
+
axiom_instance = Axiom()
|
81 |
|
82 |
@extend_schema(
|
83 |
request=GerarDocumentoComPDFProprioSerializer,
|
84 |
)
|
85 |
async def post(self, request):
|
|
|
86 |
print(f"\n\nDATA E HORA DA REQUISIÇÃO: {datetime.now()}")
|
87 |
+
self.axiom_instance.send_axiom("COMEÇOU NOVA REQUISIÇÃO")
|
88 |
+
self.axiom_instance.send_axiom(f"request.data: {request.data}")
|
89 |
serializer = GerarDocumentoComPDFProprioSerializer(data=request.data)
|
90 |
|
91 |
if serializer.is_valid(raise_exception=True):
|
|
|
93 |
obj = serializer.get_obj() # type: ignore
|
94 |
self.serializer = data
|
95 |
|
96 |
+
listaPDFs = handle_pdf_files_from_serializer(
|
97 |
+
data["files"], self.axiom_instance
|
98 |
+
)
|
99 |
|
100 |
+
resposta_llm = await gerar_documento(obj, listaPDFs, self.axiom_instance)
|
101 |
+
self.axiom_instance.send_axiom(f"resposta_llm: {resposta_llm}")
|
102 |
|
103 |
remove_pdf_temp_files(listaPDFs)
|
104 |
+
self.axiom_instance.send_axiom(
|
105 |
"PRÓXIMA LINHA ENVIA A RESPOSTA A QUEM FEZ A REQUISIÇÃO"
|
106 |
)
|
107 |
return Response({"resposta": resposta_llm})
|