File size: 14,939 Bytes
cb23311
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7fa7a9c
cb23311
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7fa7a9c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1286e81
cb23311
12d3e1a
cb23311
 
 
12d3e1a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1286e81
 
 
12d3e1a
1286e81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12d3e1a
1286e81
 
 
 
 
 
 
 
 
 
 
12d3e1a
1286e81
 
 
12d3e1a
1286e81
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
prompt_auxiliar_do_contextual_prompt = """Você é um assistente jurídico especializado em direito brasileiro. Sua tarefa é criar um resumo conciso e informativo de um processo jurídico, de acordo com as leis do Brasil. O resumo deve focar nos momentos cruciais do processo, na última movimentação processual e nas principais movimentações que ocorreram.

Aqui estão as 10 principais peças processuais em ordem cronológica do processo civil brasileiro que você deve priorizar em sua análise:
1. Petição Inicial
2. Contestação
3. Réplica
4. Decisão de Saneamento
5. Sentença
6. Recurso de Apelação
7. Embargos de Declaração
8. Cumprimento de Sentença
9. Embargos à Execução
10. Agravo de Instrumento

Siga este passo a passo para criar o resumo:

1. Leia atentamente todo o processo jurídico fornecido.
<processo_juridico>
{PROCESSO_JURIDICO}
</processo_juridico>

2. Identifique e anote as datas e conteúdos relevantes relacionados às 10 peças processuais listadas acima.

3. Organize cronologicamente as informações coletadas.

4. Destaque a última movimentação processual e seu significado para o andamento do processo.

5. Resuma as principais movimentações, focando em seu impacto no processo.

6. Elabore um texto coeso que apresente o fluxo do processo, destacando os pontos cruciais e as decisões mais importantes.

Após criar o resumo inicial, utilize a técnica socrática de reflexão para garantir a precisão e completude do resumo. Faça a si mesmo as seguintes perguntas:

1. O resumo abrange todas as 10 peças processuais principais?
2. A última movimentação processual está claramente identificada e explicada?
3. O texto apresenta uma visão clara do fluxo do processo?
4. Todas as informações cruciais para o entendimento do caso estão incluídas?
5. O resumo está livre de opiniões pessoais e se atém aos fatos do processo?
6. A linguagem utilizada é clara e acessível, mesmo para quem não é especialista em direito?

Revise e ajuste o resumo conforme necessário com base nessa reflexão.

O resumo final deve ter no máximo 2 páginas de extensão (aproximadamente 1000 palavras).

Formate sua resposta da seguinte maneira:

<resumo_processo>
[Insira aqui o resumo do processo jurídico]
</resumo_processo>

<reflexao_socratica>
[Insira aqui suas respostas às perguntas da reflexão socrática]
</reflexao_socratica>

<resumo_final>
[Insira aqui o resumo final revisado, se houver alterações após a reflexão]
</resumo_final>"""


def create_prompt_auxiliar_do_contextual_prompt(PROCESSO_JURIDICO: str):
    return f"""Você é um assistente jurídico especializado em direito brasileiro. Sua tarefa é criar um resumo conciso e informativo de um processo jurídico, de acordo com as leis do Brasil. O resumo deve focar nos momentos cruciais do processo, na última movimentação processual e nas principais movimentações que ocorreram.

Aqui estão as 10 principais peças processuais em ordem cronológica do processo civil brasileiro que você deve priorizar em sua análise:
1. Petição Inicial
2. Contestação
3. Réplica
4. Decisão de Saneamento
5. Sentença
6. Recurso de Apelação
7. Embargos de Declaração
8. Cumprimento de Sentença
9. Embargos à Execução
10. Agravo de Instrumento

Siga este passo a passo para criar o resumo:

1. Leia atentamente todo o processo jurídico fornecido.
<processo_juridico>
{PROCESSO_JURIDICO}
</processo_juridico>

2. Identifique e anote as datas e conteúdos relevantes relacionados às 10 peças processuais listadas acima.

3. Organize cronologicamente as informações coletadas.

4. Destaque a última movimentação processual e seu significado para o andamento do processo.

5. Resuma as principais movimentações, focando em seu impacto no processo.

6. Elabore um texto coeso que apresente o fluxo do processo, destacando os pontos cruciais e as decisões mais importantes.

Após criar o resumo inicial, utilize a técnica socrática de reflexão para garantir a precisão e completude do resumo. Faça a si mesmo as seguintes perguntas:

1. O resumo abrange todas as 10 peças processuais principais?
2. A última movimentação processual está claramente identificada e explicada?
3. O texto apresenta uma visão clara do fluxo do processo?
4. Todas as informações cruciais para o entendimento do caso estão incluídas?
5. O resumo está livre de opiniões pessoais e se atém aos fatos do processo?
6. A linguagem utilizada é clara e acessível, mesmo para quem não é especialista em direito?

Revise e ajuste o resumo conforme necessário com base nessa reflexão.

O resumo final deve ter no máximo 2 páginas de extensão (aproximadamente 1000 palavras).

Formate sua resposta da seguinte maneira:

<resumo_processo>
[Insira aqui o resumo do processo jurídico]
</resumo_processo>

<reflexao_socratica>
[Insira aqui suas respostas às perguntas da reflexão socrática]
</reflexao_socratica>

<resumo_final>
[Insira aqui o resumo final revisado, se houver alterações após a reflexão]
</resumo_final>"""


def contextual_prompt(single_page_text, summary_text, chunk_content):
    return f"""You are an AI assistant specialized in providing context for document retrieval. Your task is to analyze a chunk of text from a larger document and provide a brief context for it.

Here's the summary of the full text of the document:
<summary_text>
{summary_text}
</summary_text>

Here's the single page where the chunk is situated:

<single_page>
{single_page_text}
</single_page>

And here's the specific chunk to contextualize:
<chunk>
{chunk_content}
</chunk>

Follow these steps:
1. Identify and quote the document ID (found between "NUM." and "- Pág") and the document name (from the header).
2. Summarize the main topics or themes of the single page and where it fit within the summary of the full text.
3. Identify where the specific chunk fits within these themes.
4. Create a concise context that situates the chunk within the document.

With this informations, your response should be a single, concise paragraph that includes:
- The document ID
- The document name
- A brief context for the chunk

Example final output structure (do not copy the content, only the format):
<chunk_context>
[Single paragraph with document ID, name, and chunk context]
</chunk_context>"""


#     return f"""You are a language model tasked with providing context to improve the retrieval of information from a chunk extracted from a document. Follow these steps internally (do not display reasoning or reflection in the final output):
# 1. **Chain of Thought (internal)**:
# - Identify the document ID, which is the value between "NUM." and "- Pág".
# - Identify the document name from the header.
# 2. **Reflection (internal)**:
# - Confirm the document ID and name are correctly identified.
# - Ensure the final context is concise and helpful.
# 3. **Final Response**:
# - Provide a short context situating the *chunk* within the document, including the document ID and document name.
# - Do not include any reasoning or reflection in your response.
# **Example Usage:**
# ```
# <document> {full_text} </document>
# <chunk> {chunk_content} </chunk>
# Please return only the succinct context (without displaying your internal reasoning), including the document ID and the document name.
# ```
# """


# Novo nome --> prompt-auxiliar --> Para gerar documentos (é usado como auxiliar no prompt final)
prompt_auxiliar_inicio = """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."""

prompt_auxiliar_padrao = """
**Instructions**:
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.
2. **Reading the Context**: Extract the following information from `context`:
- The name of the defendant (réu).
- The crime they have been accused of (nome_do_crime).
- The applicable article and subsection of the Penal Code (artigo_e_inciso_do_crime).
- The date the accusation was accepted (data_do_recebimento).
- The ID of the decision document (id_do_documento).
3. **Prescriptive Details**: If no other interruptive or suspensive causes of prescription are mentioned, confirm that there are none.
4. **Formatting**: Your final answer must strictly follow the format below, in Portuguese, and replace the placeholders with the appropriate information:
```
<relatorio>
Trata-se de Ação Penal em que o Ministério Público denunciou [nome_do_reu], pela prática do [nome_do_crime] [artigo_e_inciso_do_crime], do Código Penal.
A denúncia foi recebida em [data_do_recebimento], conforme Decisão [id_do_documento].
Não há outras causas interruptivas ou suspensivas da prescrição.
</relatorio>
```
5. **Completeness**: If any piece of required information is missing in the `context`, note that explicitly in the final answer within the format.
**Reminder**:
- Do not include your chain of thought in the final output.
- Do not add extra information or commentary beyond the specified format.
- The final answer must be in Portuguese.
---

**Contextual Information (provided separately):**
{context}
---
**Example with a given context**:
- Input:
`context` = 'Em 10/03/2021, o Ministério Público denunciou João da Silva, imputando-lhe o crime de furto qualificado, previsto no art. 155, §4º, inciso II, do Código Penal. A denúncia foi recebida em 12/03/2021, conforme Decisão nº 20210312-01. Não há menção a qualquer causa interruptiva ou suspensiva da prescrição.'
- Expected final answer:
```
<formato>
Trata-se de Ação Penal em que o Ministério Público denunciou João da Silva, pela prática do furto qualificado (art. 155, §4º, inciso II do Código Penal).
A denúncia foi recebida em 12/03/2021, conforme Decisão 20210312-01.
Não há outras causas interruptivas ou suspensivas da prescrição.
</formato>
"""

# Novo nome --> prompt-gerar-documento --> Para gerar documentos
prompt_gerar_documento = """
You are a large language model that must produce a single final document in **Portuguese**. To do this, you will follow a private chain of thought and then produce a final answer. The final answer must follow the formatting and stylistic conventions shown in the user-provided model `user's template`. The information to be included in the final document is derived from the `context` (a report describing a legal case).
**Contextual Information (provided separately):**
{context}
**User Model (provided separately):**
<user's_template>PROMPT DO MODELO DO USUÁRIO</user's_template>
**Instructions:**
1. **Goal:** Produce one single final sentence in Portuguese that matches the structure, format, and style given by `user's template`.
2. **Chain of Thought (private to the assistant and not to be shown in the final answer):**
- Carefully review the `context` which is a legal report of a case.
- Identify:
- The defendant’s name.
- The crime’s name, its article, and any subsection (inciso).
- The date of receipt of the complaint (data do recebimento da denúncia).
- The document ID.
- Ensure these elements are correctly incorporated into the final sentence.
- Check compliance with the formatting style indicated by `user's template`.
- Compose the sentence following the structure from the user model.
- Use reflection: Before finalizing the answer, reassess if all required information is included, if the format matches the user model, and if the sentence is written correctly in Portuguese.
3. **Reflection Technique (private):**
After composing the sentence, but before presenting it as the final answer, reflect if:
- All required details from the `context` are accurately included.
- The sentence format strictly matches the pattern of `user's template`.
- The sentence is grammatically correct in Portuguese.
4. **Final Answer:**
- After completing the chain of thought and ensuring correctness through reflection, present only the final sentence in Portuguese.
- Do not show the chain of thought or the reflection step. Only the final formatted sentence should be visible to the user. 
"""

prompt_auxiliar_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.
**Instructions**:
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.
2. **Reading the Context**: Extract the following information from `context`:
- The name of the defendant (réu).
- The crime they have been accused of (nome_do_crime).
- The applicable article and subsection of the Penal Code (artigo_e_inciso_do_crime).
- The date the accusation was accepted (data_do_recebimento).
- The ID of the decision document (id_do_documento).
3. **Prescriptive Details**: If no other interruptive or suspensive causes of prescription are mentioned, confirm that there are none.
4. **Formatting**: Your final answer must strictly follow the format below, in Portuguese, and replace the placeholders with the appropriate information:
```
<formato>
Trata-se de Ação Penal em que o Ministério Público denunciou [nome_do_reu], pela prática do [nome_do_crime] [artigo_e_inciso_do_crime], do Código Penal.
A denúncia foi recebida em [data_do_recebimento], conforme Decisão [id_do_documento].
Não há outras causas interruptivas ou suspensivas da prescrição.
</formato>
```
5. **Completeness**: If any piece of required information is missing in the `context`, note that explicitly in the final answer within the format.
**Reminder**:
- Do not include your chain of thought in the final output.
- Do not add extra information or commentary beyond the specified format.
- The final answer must be in Portuguese.
```
<formato>
Trata-se de Ação Penal em que o Ministério Público denunciou João da Silva, pela prática do furto qualificado (art. 155, §4º, inciso II do Código Penal).
A denúncia foi recebida em 12/03/2021, conforme Decisão 20210312-01.
Não há outras causas interruptivas ou suspensivas da prescrição.
</formato>
"""