Spaces:
Sleeping
Sleeping
Commit
·
ecd9808
1
Parent(s):
20e3edd
feat: adicionando o resumo na resposta final
Browse files
_utils/gerar_relatorio_modelo_usuario/EnhancedDocumentSummarizer.py
CHANGED
@@ -40,7 +40,7 @@ class EnhancedDocumentSummarizer(DocumentSummarizer):
|
|
40 |
gpt_temperature,
|
41 |
id_modelo_do_usuario,
|
42 |
prompt_modelo,
|
43 |
-
reciprocal_rank_fusion
|
44 |
):
|
45 |
super().__init__(
|
46 |
openai_api_key,
|
@@ -62,6 +62,7 @@ class EnhancedDocumentSummarizer(DocumentSummarizer):
|
|
62 |
self.id_modelo_do_usuario = id_modelo_do_usuario
|
63 |
self.prompt_modelo = prompt_modelo
|
64 |
self.reciprocal_rank_fusion = reciprocal_rank_fusion
|
|
|
65 |
|
66 |
def create_enhanced_vector_store(
|
67 |
self, chunks: List[ContextualizedChunk], is_contextualized_chunk
|
@@ -260,6 +261,8 @@ class EnhancedDocumentSummarizer(DocumentSummarizer):
|
|
260 |
prompt_gerar_relatorio.format(context="\n\n".join(contexts))
|
261 |
)
|
262 |
|
|
|
|
|
263 |
prompt_gerar_modelo = PromptTemplate(
|
264 |
template=self.prompt_modelo,
|
265 |
input_variables=["context", "modelo_usuario"],
|
|
|
40 |
gpt_temperature,
|
41 |
id_modelo_do_usuario,
|
42 |
prompt_modelo,
|
43 |
+
reciprocal_rank_fusion
|
44 |
):
|
45 |
super().__init__(
|
46 |
openai_api_key,
|
|
|
62 |
self.id_modelo_do_usuario = id_modelo_do_usuario
|
63 |
self.prompt_modelo = prompt_modelo
|
64 |
self.reciprocal_rank_fusion = reciprocal_rank_fusion
|
65 |
+
self.resumo_gerado = ""
|
66 |
|
67 |
def create_enhanced_vector_store(
|
68 |
self, chunks: List[ContextualizedChunk], is_contextualized_chunk
|
|
|
261 |
prompt_gerar_relatorio.format(context="\n\n".join(contexts))
|
262 |
)
|
263 |
|
264 |
+
self.resumo_gerado = relatorio_gerado
|
265 |
+
|
266 |
prompt_gerar_modelo = PromptTemplate(
|
267 |
template=self.prompt_modelo,
|
268 |
input_variables=["context", "modelo_usuario"],
|
_utils/resumo_completo_cursor.py
CHANGED
@@ -105,7 +105,7 @@ async def get_llm_summary_answer_by_cursor_complete(
|
|
105 |
chunks_passados, is_contextualized_chunk
|
106 |
)
|
107 |
|
108 |
-
|
109 |
**Instructions**:
|
110 |
1. **Chain of Thought**: Before producing your final answer, you must think through and plan your summary silently, without showing this reasoning in the final output. The final answer must only contain the required formatted report and nothing else.
|
111 |
2. **Reading the Context**: Extract the following information from `context`:
|
@@ -142,7 +142,7 @@ Não há outras causas interruptivas ou suspensivas da prescrição.
|
|
142 |
chunk_ids
|
143 |
# , serializer["user_message"]
|
144 |
,
|
145 |
-
|
146 |
)
|
147 |
|
148 |
if not isinstance(structured_summaries, list):
|
@@ -156,6 +156,10 @@ Não há outras causas interruptivas ou suspensivas da prescrição.
|
|
156 |
# print(json_output)
|
157 |
texto_completo = ""
|
158 |
print("\n\n\n")
|
|
|
|
|
|
|
|
|
159 |
print("structured_summaries: ", structured_summaries)
|
160 |
for x in structured_summaries:
|
161 |
texto_completo = texto_completo + x["content"] + "\n"
|
|
|
105 |
chunks_passados, is_contextualized_chunk
|
106 |
)
|
107 |
|
108 |
+
prompt_resumo_sem_context = """You are a language model specialized in producing concise and well-structured legal case summaries in Portuguese. You will receive a variable `context`, which contains information about a legal case. Your task is to read the `context` carefully and produce a summary report in Portuguese, following the specific format provided below. Do not include any additional comments or reasoning steps in your final answer.
|
109 |
**Instructions**:
|
110 |
1. **Chain of Thought**: Before producing your final answer, you must think through and plan your summary silently, without showing this reasoning in the final output. The final answer must only contain the required formatted report and nothing else.
|
111 |
2. **Reading the Context**: Extract the following information from `context`:
|
|
|
142 |
chunk_ids
|
143 |
# , serializer["user_message"]
|
144 |
,
|
145 |
+
prompt_resumo_sem_context,
|
146 |
)
|
147 |
|
148 |
if not isinstance(structured_summaries, list):
|
|
|
156 |
# print(json_output)
|
157 |
texto_completo = ""
|
158 |
print("\n\n\n")
|
159 |
+
print("summarizer.resumo_gerado: ", summarizer.resumo_gerado)
|
160 |
+
texto_completo += summarizer.resumo_gerado
|
161 |
+
texto_completo += "\n\n"
|
162 |
+
print("\n\n\n")
|
163 |
print("structured_summaries: ", structured_summaries)
|
164 |
for x in structured_summaries:
|
165 |
texto_completo = texto_completo + x["content"] + "\n"
|
example.env
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
DATABASE_PASSWORD=""
|
2 |
+
OPENAI_API_KEY=""
|
3 |
+
CLAUDE_API_KEY=""
|
4 |
+
LANGCHAIN_API_KEY=""
|
5 |
+
HUGGINGFACEHUB_API_TOKEN=""
|
6 |
+
COHERE_API_KEY=""
|
7 |
+
SECRET_KEY=""
|
8 |
+
DATABASE_PASSWORD=""
|
setup/urls.py
CHANGED
@@ -31,7 +31,7 @@ urlpatterns = [
|
|
31 |
path("resumo", ResumoView.as_view(), name="summary-pdf"),
|
32 |
path("resumo/cursor", ResumoSimplesCursorView.as_view(), name="summary-cursor-pdf"),
|
33 |
path(
|
34 |
-
"gerar-
|
35 |
ResumoSimplesCursorCompletoView.as_view(),
|
36 |
name="summary-cursor-completo-pdf",
|
37 |
),
|
|
|
31 |
path("resumo", ResumoView.as_view(), name="summary-pdf"),
|
32 |
path("resumo/cursor", ResumoSimplesCursorView.as_view(), name="summary-cursor-pdf"),
|
33 |
path(
|
34 |
+
"gerar-documento",
|
35 |
ResumoSimplesCursorCompletoView.as_view(),
|
36 |
name="summary-cursor-completo-pdf",
|
37 |
),
|