darthPanda commited on
Commit
3bd3c7b
1 Parent(s): a5b9a66

updated stage

Browse files
app.py CHANGED
@@ -14,7 +14,7 @@ import prompt_tracing
14
 
15
  load_dotenv()
16
 
17
- tracking = True
18
 
19
  iteration = 0
20
  iteration_limit = 50
 
14
 
15
  load_dotenv()
16
 
17
+ tracking = False
18
 
19
  iteration = 0
20
  iteration_limit = 50
data/logs.txt CHANGED
@@ -1,168 +1 @@
1
-
2
- name of parties: LLC Cesla Property Group vs. Samara Cable Company JSC, with Magistral LLC as a third party
3
- date of claim filing: "March 10" March 2023
4
- amount of claim: 116,950 rubles + 3,844.93 rubles in interest
5
- Claim validity: True
6
- Circumstance:
7
- - Principal Circumstance: Damage to the Claimant's property (10 kV cable line) caused by the Respondent's actions during excavation works.
8
- - Derivative Circumstance: The need for emergency repair works on the damaged cable line.
9
- - Indirectly Derivative Circumstance: The issuance of a permit for excavation works and the notification of such works.
10
- - Ancillary Circumstance: The rules and regulations governing excavation works and the responsibilities of parties involved in such works.
11
-
12
- Analysis of circumstances:
13
- - Categories of circumstances are referred to by the Claimant in the claim statement as confirmed by evidence: The Claimant refers to the principal and derivative circumstances as confirmed by evidence.
14
- - Most important circumstance: The damage to the Claimant's property (10 kV cable line) and the subsequent repair works.
15
-
16
- Evidence indicated in the claim and other documents:
17
- -Evidence 1: Sale and purchase agreement dated April 11, 2022, strength: Medium, related fact(s): Ownership of the damaged property by the Claimant.
18
- -Evidence 2: Contract No. 1-AVR dated August 07, 2022 with Magistral LLC for emergency recovery works, strength: Medium, related fact(s): Engagement of Magistral LLC for repair works.
19
- -Evidence 3: Act of completed work under the contract signed on September 30, 2022, strength: Medium, related fact(s): Completion of the repair works.
20
- -Evidence 4: Invoice for payment #65 dated October 05, 2022, strength: Medium, related fact(s): Payment made to Magistral LLC for the repair works.
21
- -Evidence 5: Letter from Magistral LLC to Regional Power Grids LLC dated August 08, 2022, strength: Medium, related fact(s): Notification of the damage and repair works.
22
- -Evidence 6: Notification of excavation works No. 3016 dated 26.07.2022, strength: Strong, related fact(s): Permit and notification for the excavation works that led to the damage.
23
- -Evidence 7: Response from the Department of Urban Economy and Ecology of the Administration of the City District of Samara, strength: Strong, related fact(s): Confirmation of the excavation works carried out by Samara branch of PJSC "T Plus" based on the notification.
24
-
25
- Response validity: True
26
- Claim needs rechecking: False
27
- Prima Facie refuted: True
28
- Circumstance:
29
- - Principal Circumstance: Damage to the electrical cable owned by the Claimant.
30
- - Derivative Circumstance: The absence of evidence confirming the cable damage by the Defendant.
31
- - Indirectly Derivative Circumstance: The absence of an investigation report on the causes of the accident.
32
- - Ancillary Circumstance: The precautions taken by the Defendant to prevent damage to underground and above-ground engineering networks.
33
-
34
- Analysis of circumstances:
35
- - Categories of circumstances are referred to by the Defendant in the claim statement as confirmed by evidence: The Defendant refers to the Derivative and Ancillary Circumstances as refuted by their evidence.
36
- - Most important circumstance: The Derivative Circumstance, specifically the absence of evidence confirming the cable damage by the Defendant, is the most significant because it directly challenges the Claimant's assertion of damage caused by the Defendant.
37
-
38
- Evidence indicated in the claim and other documents:
39
- -Evidence 1: Letter from LLC "Magistral" dated August 8, 2022, No. 15, indicating damage to the power line, strength: Medium, related fact(s): Damage to the electrical cable.
40
- -Evidence 2: Documentation of precautions taken by the Defendant, including obtaining design documentation, transfer of the construction site, opening of the permit for excavation works, and calling representatives of organizations operating adjacent networks, strength: Medium, related fact(s): Precautions taken to prevent damage.
41
- -Evidence 3: Absence of an investigation report on the causes of the accident, strength: Weak, related fact(s): Lack of investigation into the cause of the cable damage.
42
- -Evidence 4: Contract between T PLUS and LLC SK Fakel for construction and installation works, strength: Medium, related fact(s): Execution of works near the Claimant's property.
43
-
44
- Claimant clarification to defendant's response:
45
-
46
- Response given: True
47
-
48
- **Review of Added Evidence and Arguments**
49
- - The Claimant has provided detailed evidence and arguments to counter the Defendant's claims, including operational journal entries, letters, and photographs, which substantiate the occurrence of cable damage on August 6, 2022.
50
- - The Claimant has argued that the absence of a formal investigation act does not preclude the recovery of damages, emphasizing the presence of convincing evidence of the fact of damage and its extent.
51
- - The Claimant has highlighted the legal basis for damages recovery, focusing on the presence of evidence confirming the violation and the amount of damage caused, rather than the formal preparation of an investigation act.
52
- - The Claimant has provided information linking the Defendant to the excavation works that led to the cable damage, including a letter from the Department of Urban Economy and Ecology of the Administration of the urban district of Samara.
53
-
54
- **Evaluation of the Claimant's Position**
55
- - The Claimant has effectively used the operational journal entry and the response from LLC "Magistral" to establish the fact of cable damage, which directly challenges the Defendant's claim of insufficient evidence.
56
- - The argument regarding the non-necessity of a formal investigation act for accidents on facilities with a voltage below 35 kV underlines the adaptability of evidence requirements to the specifics of the case, which supports the Claimant's position.
57
- - The linkage of the Defendant to the excavation works through the letter from the Department of Urban Economy and Ecology provides a direct connection between the Defendant's actions and the damage incurred, which is crucial for establishing liability.
58
- - The initial acknowledgment by JSC “Samara Cable Company” of their responsibility for the damage, as mentioned by the Claimant, further complicates the Defendant's position by introducing a potential admission of guilt, albeit later retracted.
59
-
60
- **Conclusion**:
61
- The Claimant has provided substantial evidence and arguments that not only counter the Defendant's claims but also establish a strong linkage between the Defendant's actions and the damage incurred. The detailed evidence, including operational journal entries, letters, and photographs, alongside legal arguments, strengthens the Claimant's position. The Claimant's clarification effectively challenges the Defendant's response, necessitating a re-evaluation of the Defendant's position and possibly inviting additional objections from the Defendant. The evidence and arguments presented by the Claimant are at least indirectly related to the facts of the case, providing a solid basis for their claim for damages.
62
-
63
- Defendant's response to claimant's clarifications:
64
-
65
- Response given: True
66
- Defendant provided new evidence: False
67
- **Clarifications given**:
68
- - The defendant, PJSC "T Plus", reiterated its position that the claimant's evidence is insufficient, specifically pointing out the lack of diverse and convincing evidence as required by Article 65 of the Arbitration Procedure Code of the Russian Federation. This includes the absence of photographs, video materials, and a joint inspection report.
69
- - PJSC "T Plus" also highlighted the absence of an investigation report on the causes of the accident, which is a procedural requirement according to the "Rules for the Investigation of Causes of Accidents in Power Engineering" as per the Government Decree of the Russian Federation dated October 28, 2009, No. 846.
70
- - The defendant contested the claimant's demand for penalties, arguing that under Chapter 25 of the Civil Code of the Russian Federation and the Resolution of the Plenum of the Supreme Court of the Russian Federation dated March 24, 2016, No. 7, penalties are not applicable in the form of liability for non-performance or improper performance when it involves the recovery of losses. They emphasized that interest prescribed by Article 395 of the Civil Code cannot be applied over and above the actual damages incurred due to non-performance or improper performance of a monetary obligation.
71
-
72
- **Conclusion**:
73
- The defendant's response to the claimant's clarifications does not introduce new evidence but reiterates and elaborates on their initial arguments against the claimant's evidence and legal basis for the claim. The defendant's emphasis on procedural and legal standards, specifically the requirements for evidence under the Arbitration Procedure Code and the Civil Code of the Russian Federation, challenges the sufficiency and relevance of the claimant's evidence. However, without new evidence or a proposed settlement, the response serves to reinforce the defendant's position rather than alter the course of the dispute. The defendant's arguments necessitate a detailed examination of the claimant's evidence in light of the legal requirements and standards cited.
74
-
75
- **Evidence Analysis:**
76
-
77
- 1. **Direct Facts Established:**
78
-
79
- - **Plaintiff's Main Evidence Direct Fact:** The ownership of the damaged property by Cesla Property Group LLC and the occurrence of damage during excavation works are directly confirmed by the Purchase and Sale Agreement, the Rehabilitation Work Agreement, the Certificate of Completion, and the Invoice for Payment. These documents unequivocally establish Cesla Property Group LLC's ownership and the subsequent damage and repair costs incurred due to excavation works.
80
-
81
- - **Defendant's Main Evidence Direct Fact:** The precautions taken by the contractor organization of PJSC "T Plus" during the excavation works, including the collaboration with utility operators and the acquisition of necessary permits and approvals for the excavation works, are directly confirmed by the Explanation of Fakel LLC. This evidence establishes that all required steps were taken to prevent damage to underground and above-ground engineering networks.
82
-
83
- 2. **Analysis of Direct Facts Against Each Other:**
84
-
85
- The direct fact from the plaintiff's evidence does not directly contradict the direct fact from the defendant's evidence. The plaintiff's fact establishes damage and costs incurred due to excavation works, while the defendant's fact asserts that all precautions and legal requirements were met during the excavation works. The presence of one fact does not exclude the existence of the other; it is possible for damage to occur even when precautions are taken, and for all legal requirements to be met.
86
-
87
- 2.1. **Strength of Evidence Supporting the Facts:**
88
-
89
- - **Plaintiff's Evidence Strength:** Medium to Strong. The evidence includes agreements and certificates signed by multiple independent parties (Cesla Property Group LLC and Magistral LLC), and an invoice for payment, which are medium strength. The regulatory context provided by the Department of Urban Economy and Ecology adds to the strength by providing an objective regulatory perspective, making the overall evidence strong.
90
-
91
- - **Defendant's Evidence Strength:** Medium. The explanation provided by Fakel LLC, detailing the precautions taken and the collaboration with utility operators, is supported by documentary evidence prepared by the defendant. Although it mentions permits and approvals, the direct evidence of these documents (e.g., copies of the permits) is not described, making the evidence medium strength.
92
-
93
- 2.1.2. **Cross-Check of Facts for Indirect Support:**
94
-
95
- - **Indirect Facts Supporting the Defendant's Main Fact from Plaintiff's Evidence:** The plaintiff's evidence does not provide indirect support for the defendant's claim that all precautions were taken and that damage to underground and above-ground engineering networks was prevented. The plaintiff's evidence focuses on the damage and the costs incurred for repairs.
96
-
97
- - **Indirect Facts Supporting the Plaintiff's Main Fact from Defendant's Evidence:** The defendant's evidence indirectly supports the plaintiff's main fact by acknowledging the execution of excavation works near the plaintiff's property. While it claims that all precautions were taken, the mere occurrence of such works near the damaged property indirectly supports the plaintiff's claim of damage during these works.
98
-
99
- 2.1.2.2.4. **Analysis of Strength of Evidence by Opposing Side:**
100
-
101
- Since the defendant's evidence indirectly supports the occurrence of excavation works near the plaintiff's property, and given the medium strength of the defendant's evidence against the strong evidence provided by the plaintiff (due to the regulatory context and documents signed by independent parties), the analysis leans towards giving more weight to the plaintiff's main fact.
102
-
103
- **Conclusion:**
104
-
105
- The main facts from the main evidence of both parties do not directly contradict each other, but the analysis favors the plaintiff's main fact due to the indirect support provided by the defendant's evidence and the stronger evidence supporting the plaintiff's claim. The occurrence of damage during excavation works and the incurred costs are established facts, with the defendant's precautions during the works not excluding the possibility of damage occurring.
106
-
107
- **Evidence Analysis:**
108
-
109
- 1. **Direct Facts Established:**
110
-
111
- - **Plaintiff's Main Evidence Direct Fact:** The ownership of the damaged property by Cesla Property Group LLC and the occurrence of damage during excavation works are directly confirmed by the Purchase and Sale Agreement, the Rehabilitation Work Agreement, the Certificate of Completion, and the Invoice for Payment. These documents unequivocally establish Cesla Property Group LLC's ownership and the subsequent damage and repair costs incurred due to excavation works.
112
-
113
- - **Defendant's Main Evidence Direct Fact:** The precautions taken by the contractor organization of PJSC "T Plus" during the excavation works, including the collaboration with utility operators and the acquisition of necessary permits and approvals for the excavation works, are directly confirmed by the Explanation of Fakel LLC. This evidence establishes that all required steps were taken to prevent damage to underground and above-ground engineering networks.
114
-
115
- 2. **Analysis of Direct Facts Against Each Other:**
116
-
117
- The direct fact from the plaintiff's evidence does not directly contradict the direct fact from the defendant's evidence. The plaintiff's fact establishes damage and costs incurred due to excavation works, while the defendant's fact asserts that all precautions and legal requirements were met during the excavation works. The presence of one fact does not exclude the existence of the other; it is possible for damage to occur even when precautions are taken, and for all legal requirements to be met.
118
-
119
- 2.1. **Strength of Evidence Supporting the Facts:**
120
-
121
- - **Plaintiff's Evidence Strength:** Medium to Strong. The evidence includes agreements and certificates signed by multiple independent parties (Cesla Property Group LLC and Magistral LLC), and an invoice for payment, which are medium strength. The regulatory context provided by the Department of Urban Economy and Ecology adds to the strength by providing an objective regulatory perspective, making the overall evidence strong.
122
-
123
- - **Defendant's Evidence Strength:** Medium. The explanation provided by Fakel LLC, detailing the precautions taken and the collaboration with utility operators, is supported by documentary evidence prepared by the defendant. Although it mentions permits and approvals, the direct evidence of these documents (e.g., copies of the permits) is not described, making the evidence medium strength.
124
-
125
- 2.1.2. **Cross-Check of Facts for Indirect Support:**
126
-
127
- - **Indirect Facts Supporting the Defendant's Main Fact from Plaintiff's Evidence:** The plaintiff's evidence does not provide indirect support for the defendant's claim that all precautions were taken and that damage to underground and above-ground engineering networks was prevented. The plaintiff's evidence focuses on the damage and the costs incurred for repairs.
128
-
129
- - **Indirect Facts Supporting the Plaintiff's Main Fact from Defendant's Evidence:** The defendant's evidence indirectly supports the plaintiff's main fact by acknowledging the execution of excavation works near the plaintiff's property. While it claims that all precautions were taken, the mere occurrence of such works near the damaged property indirectly supports the plaintiff's claim of damage during these works.
130
-
131
- 2.1.2.2.4. **Analysis of Strength of Evidence by Opposing Side:**
132
-
133
- Since the defendant's evidence indirectly supports the occurrence of excavation works near the plaintiff's property, and given the medium strength of the defendant's evidence against the strong evidence provided by the plaintiff (due to the regulatory context and documents signed by independent parties), the analysis leans towards giving more weight to the plaintiff's main fact.
134
-
135
- **Conclusion:**
136
-
137
- The main facts from the main evidence of both parties do not directly contradict each other, but the analysis favors the plaintiff's main fact due to the indirect support provided by the defendant's evidence and the stronger evidence supporting the plaintiff's claim. The occurrence of damage during excavation works and the incurred costs are established facts, with the defendant's precautions during the works not excluding the possibility of damage occurring.
138
-
139
- ### Analysis of Evidence from Parties
140
-
141
- The case involves a dispute between LLC Cesla Property Group (Claimant) and PJSC "T Plus" (Defendant), with Magistral LLC as a third party. The claimant alleges damage to their property due to excavation works and seeks compensation for the repair costs from the defendant. The defendant contests the sufficiency and relevance of the evidence provided by the claimant and argues against the legal basis for the claim.
142
-
143
- #### Direct Facts Established:
144
- 1. **Ownership of the Damaged Property**: The evidence provided by the claimant, including the purchase and sale agreement, establishes LLC Cesla Property Group's ownership of the property in question.
145
- 2. **Occurrence of Damage**: The Certificate of Completion and invoice for payment substantiate the occurrence of damage and the subsequent repair work.
146
- 3. **Request for Payment**: Documentation shows that Cesla Property Group LLC requested payment from the respondent for the repair costs, which was refused.
147
-
148
- #### Probable Facts Established:
149
- 1. **Cause of Damage**: The linkage of the defendant to the excavation works and the damage incurred is supported by operational journal entries and a letter from the Department of Urban Economy and Ecology. However, this is inferred rather than directly evidenced.
150
- 2. **Responsibility for Damage**: The initial acknowledgment by JSC “Samara Cable Company” of their responsibility, later retracted, suggests a probable acknowledgment of fault, albeit indirectly.
151
-
152
- #### Analysis of Contradictions:
153
- - The defendant's challenge to the sufficiency of evidence, particularly the lack of a joint inspection report and an investigation report, contests the directness of the evidence supporting the cause and responsibility for the damage.
154
- - The claimant's evidence, while not including a formal investigation act, provides a substantial basis for linking the damage to the defendant's actions through operational journal entries and correspondence.
155
-
156
- #### Main and Derivative Circumstances:
157
- - **Main Circumstance**: The actual occurrence of damage to the property owned by Cesla Property Group LLC.
158
- - **Derivative Circumstance**: The involvement of the defendant in excavation works leading to the damage.
159
-
160
- #### Evidence Strength:
161
- - **Strong Evidence**: The Certificate of Completion and invoice for payment are objective evidence of the damage and repair costs.
162
- - **Medium Evidence**: Correspondence and operational journal entries provide a link between the defendant's actions and the damage but are less direct.
163
- - **Weak Evidence**: The absence of a joint inspection report and an investigation report as pointed out by the defendant.
164
-
165
- #### Case Fable:
166
- The evidence establishes the occurrence of damage to LLC Cesla Property Group's property and the subsequent repair work, substantiating the claimant's ownership and the incurred costs. While the direct cause of the damage and the defendant's responsibility are contested, the claimant provides a reasonable linkage through operational journal entries and correspondence. The absence of a formal investigation act does not negate the presence of convincing evidence of the fact of damage and its extent. The defendant's arguments, focusing on procedural and legal standards, challenge the sufficiency of the claimant's evidence but do not provide new evidence to refute the claimant's position.
167
-
168
- Given the evidence's strength and relevance, the main circumstance of the damage occurrence and the derivative circumstance of the defendant's involvement in the excavation works are included in the case fable. The absence of certain procedural documents (joint inspection report, investigation report) as highlighted by the defendant does not sufficiently counter the established link between the defendant's actions and the damage incurred. Therefore, the claimant's evidence, supported by objective documentation and correspondence, forms the basis of the case fable, with the defendant's liability for the damage as the central issue for adjudication.
 
1
+ I'm sorry, but you haven't provided any specific text or details from a lawsuit for analysis. Please provide the text or details of the lawsuit you'd like analyzed according to the steps outlined.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
judge.py CHANGED
@@ -11,6 +11,7 @@ from datetime import date
11
  from prompts import judgement_stage_prompts
12
  import prompt_tracing
13
  import comet_llm
 
14
 
15
 
16
  from dotenv import load_dotenv
@@ -159,7 +160,7 @@ class Judge():
159
  )
160
 
161
  # print(prompt_tracing.user + ":\n" + prompt)
162
- if tracking:
163
  # prompt_tracing.send_prompt_over_discord(prompt)
164
  # prompt_tracing.send_response_over_discord(chat_completion.choices[0].message.content)
165
  comet_llm.log_prompt(
@@ -211,6 +212,7 @@ class Judge():
211
  # print(prompt)
212
 
213
  response = self.llm_function_call(prompt, "gpt-4-0125-preview")
 
214
  # response = self.llm_function_call(prompt, "mistral-large-azure")
215
  # response = self.llm_function_call(prompt, "llama3-70b-8192")
216
  # response = mock_constants.stage_1_and_1_1_response
@@ -449,7 +451,8 @@ The only permissible action for the claimant at this stage is to challenge the c
449
  gpt_prompt = judgement_stage_prompts.stage_4_9_5_prompt
450
 
451
  # prompt = self.lawsuit_facts + self.response_facts + "\nEvidence submitted by defendant: \n" + input_text + gpt_prompt
452
- prompt = self.evidence_analysis + "\n\nPrompt:" + gpt_prompt
 
453
 
454
  response = self.llm_function_call(prompt, "gpt-4-0125-preview")
455
  # response = self.llm_function_call(prompt, "mistral-large-azure")
 
11
  from prompts import judgement_stage_prompts
12
  import prompt_tracing
13
  import comet_llm
14
+ import llm
15
 
16
 
17
  from dotenv import load_dotenv
 
160
  )
161
 
162
  # print(prompt_tracing.user + ":\n" + prompt)
163
+ if prompt_tracing.tracking:
164
  # prompt_tracing.send_prompt_over_discord(prompt)
165
  # prompt_tracing.send_response_over_discord(chat_completion.choices[0].message.content)
166
  comet_llm.log_prompt(
 
212
  # print(prompt)
213
 
214
  response = self.llm_function_call(prompt, "gpt-4-0125-preview")
215
+ # response = llm.llm_function_call(prompt, "gpt-4-azure")
216
  # response = self.llm_function_call(prompt, "mistral-large-azure")
217
  # response = self.llm_function_call(prompt, "llama3-70b-8192")
218
  # response = mock_constants.stage_1_and_1_1_response
 
451
  gpt_prompt = judgement_stage_prompts.stage_4_9_5_prompt
452
 
453
  # prompt = self.lawsuit_facts + self.response_facts + "\nEvidence submitted by defendant: \n" + input_text + gpt_prompt
454
+ prompt = self.claim_extracted_text + self.defendant_extracted_text + self.claimant_response_extracted_text + self.defendant_response_extracted_text + self.evidence_analysis + "\n\nPrompt:" + gpt_prompt
455
+ # prompt = self.evidence_analysis + "\n\nPrompt:" + gpt_prompt
456
 
457
  response = self.llm_function_call(prompt, "gpt-4-0125-preview")
458
  # response = self.llm_function_call(prompt, "mistral-large-azure")
llm.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from openai import OpenAI
3
+ from llama_index.llms.groq import Groq
4
+ from mistralai.client import MistralClient
5
+ from mistralai.models.chat_completion import ChatMessage
6
+ import prompt_tracing
7
+ import comet_llm
8
+ from openai import AzureOpenAI
9
+ from dotenv import load_dotenv
10
+
11
+ load_dotenv()
12
+
13
+ def llm_function_call(prompt, model):
14
+
15
+ if "gpt-4-azure" in model:
16
+ client = AzureOpenAI(
17
+ api_key=os.getenv("AZURE_OPENAI_API_KEY"),
18
+ api_version="2024-02-01",
19
+ azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT")
20
+ )
21
+ response = client.chat.completions.create(
22
+ model="gpt-4",
23
+ temperature=0,
24
+ messages = [
25
+ {
26
+ "role":"user",
27
+ "content":prompt
28
+ }])
29
+ return response.choices[0].message.content
30
+
31
+
32
+ elif "gpt" in model:
33
+ client = OpenAI(
34
+ # This is the default and can be omitted
35
+ api_key=os.environ.get("OPENAI_API_KEY"),
36
+ )
37
+
38
+ chat_completion = client.chat.completions.create(
39
+ messages=[
40
+ {
41
+ "role": "user",
42
+ "content": prompt,
43
+ }
44
+ ],
45
+ model=model,
46
+ # model = "gpt-4o-2024-05-13",
47
+ temperature=0
48
+ )
49
+ # print(prompt_tracing.user + ":\n" + prompt)
50
+ if prompt_tracing.tracking:
51
+ # prompt_tracing.send_prompt_over_discord(prompt)
52
+ # prompt_tracing.send_response_over_discord(chat_completion.choices[0].message.content)
53
+ comet_llm.log_prompt(
54
+ prompt=prompt_tracing.user + ":\n" + prompt,
55
+ output=chat_completion.choices[0].message.content,
56
+ )
57
+ return chat_completion.choices[0].message.content
58
+
59
+ elif model == "llama3-70b-8192":
60
+ llm = Groq(model="llama3-70b-8192", api_key=os.environ.get("GROQ_API_KEY"), temperature=0)
61
+ response = llm.complete(prompt)
62
+ return response.text
63
+
64
+ elif model == "mistral-large-azure":
65
+ client = MistralClient(
66
+ endpoint=os.environ.get("AZURE_AI_MISTRAL_LARGE_ENDPOINT"), api_key=os.environ.get("AZURE_AI_MISTRAL_LARGE_KEY")
67
+ )
68
+
69
+ response = client.chat(
70
+ model="azureai",
71
+ messages=[
72
+ ChatMessage(
73
+ role="user",
74
+ content=prompt,
75
+ )
76
+ ],
77
+ max_tokens=4096,
78
+ temperature=0,
79
+ )
80
+ print(response.usage)
81
+ return response.choices[0].message.content
82
+
83
+ else:
84
+ return "no model available"
mistral_test.ipynb → model_testing.ipynb RENAMED
@@ -2,20 +2,9 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 4,
6
  "metadata": {},
7
- "outputs": [
8
- {
9
- "data": {
10
- "text/plain": [
11
- "True"
12
- ]
13
- },
14
- "execution_count": 4,
15
- "metadata": {},
16
- "output_type": "execute_result"
17
- }
18
- ],
19
  "source": [
20
  "from mistralai.client import MistralClient\n",
21
  "from mistralai.models.chat_completion import ChatMessage\n",
@@ -27,17 +16,9 @@
27
  },
28
  {
29
  "cell_type": "code",
30
- "execution_count": 5,
31
  "metadata": {},
32
- "outputs": [
33
- {
34
- "name": "stdout",
35
- "output_type": "stream",
36
- "text": [
37
- "The most renowned French painter is widely considered to be Claude Monet, one of the founders of the Impressionist movement.\n"
38
- ]
39
- }
40
- ],
41
  "source": [
42
  "client = MistralClient(\n",
43
  " endpoint=os.environ.get(\"AZURE_AI_MISTRAL_LARGE_ENDPOINT\"), api_key=os.environ.get(\"AZURE_AI_MISTRAL_LARGE_KEY\")\n",
@@ -59,24 +40,51 @@
59
  },
60
  {
61
  "cell_type": "code",
62
- "execution_count": 9,
63
  "metadata": {},
64
- "outputs": [
65
- {
66
- "data": {
67
- "text/plain": [
68
- "UsageInfo(prompt_tokens=18, total_tokens=45, completion_tokens=27)"
69
- ]
70
- },
71
- "execution_count": 9,
72
- "metadata": {},
73
- "output_type": "execute_result"
74
- }
75
- ],
76
  "source": [
77
  "chat_response.usage"
78
  ]
79
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  {
81
  "cell_type": "code",
82
  "execution_count": null,
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": null,
6
  "metadata": {},
7
+ "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
8
  "source": [
9
  "from mistralai.client import MistralClient\n",
10
  "from mistralai.models.chat_completion import ChatMessage\n",
 
16
  },
17
  {
18
  "cell_type": "code",
19
+ "execution_count": null,
20
  "metadata": {},
21
+ "outputs": [],
 
 
 
 
 
 
 
 
22
  "source": [
23
  "client = MistralClient(\n",
24
  " endpoint=os.environ.get(\"AZURE_AI_MISTRAL_LARGE_ENDPOINT\"), api_key=os.environ.get(\"AZURE_AI_MISTRAL_LARGE_KEY\")\n",
 
40
  },
41
  {
42
  "cell_type": "code",
43
+ "execution_count": null,
44
  "metadata": {},
45
+ "outputs": [],
 
 
 
 
 
 
 
 
 
 
 
46
  "source": [
47
  "chat_response.usage"
48
  ]
49
  },
50
+ {
51
+ "cell_type": "code",
52
+ "execution_count": null,
53
+ "metadata": {},
54
+ "outputs": [],
55
+ "source": [
56
+ "import os\n",
57
+ "from openai import AzureOpenAI\n",
58
+ "from dotenv import load_dotenv\n",
59
+ "\n",
60
+ "load_dotenv()\n",
61
+ " \n",
62
+ "client = AzureOpenAI(\n",
63
+ " api_key=os.getenv(\"AZURE_OPENAI_API_KEY\"), \n",
64
+ " api_version=\"2024-02-01\",\n",
65
+ " azure_endpoint = os.getenv(\"AZURE_OPENAI_ENDPOINT\")\n",
66
+ " )\n",
67
+ " \n",
68
+ "# Send a completion call to generate an answer\n",
69
+ "print('Sending a test completion job')\n",
70
+ "start_phrase = 'Write a tagline for an ice cream shop. '\n",
71
+ "# response = client.completions.create(model=deployment_name, prompt=start_phrase, max_tokens=10)\n",
72
+ "response = client.chat.completions.create(\n",
73
+ " model=\"gpt-4\",\n",
74
+ " temperature=0, \n",
75
+ " messages = [{\"role\":\"system\", \"content\":\"this is a prompt\"}])\n",
76
+ "print(response)"
77
+ ]
78
+ },
79
+ {
80
+ "cell_type": "code",
81
+ "execution_count": null,
82
+ "metadata": {},
83
+ "outputs": [],
84
+ "source": [
85
+ "response.choices[0].message.content"
86
+ ]
87
+ },
88
  {
89
  "cell_type": "code",
90
  "execution_count": null,
prompt_tracing.py CHANGED
@@ -6,18 +6,7 @@ from dotenv import load_dotenv
6
 
7
  load_dotenv() # take environment variables from .env.
8
 
9
- # def track_ip(text, request: gr.Request):
10
- # client_ip = request.client.host
11
- # local_ip = socket.gethostbyname(socket.gethostbyname(""))
12
- # x_forwarded_for = request.headers.get('x-forwarded-for')
13
- # headers = request.headers
14
- # if x_forwarded_for:
15
- # client_ip = x_forwarded_for
16
- # print("client_ip", client_ip, text)
17
- # print("x_forwarded_for", x_forwarded_for)
18
- # return text, {"client_ip": client_ip,
19
- # "local_ip": local_ip,
20
- # "headers": headers}
21
  user = "user100"
22
 
23
  def make_discord_trace_intro():
 
6
 
7
  load_dotenv() # take environment variables from .env.
8
 
9
+ tracking = True
 
 
 
 
 
 
 
 
 
 
 
10
  user = "user100"
11
 
12
  def make_discord_trace_intro():
prompts/judgement_stage_prompts.py CHANGED
@@ -371,32 +371,62 @@ Output:
371
  '''
372
 
373
  stage_4_9_5_prompt = """
374
- Above is evidence analysis of evidence submitted by claimant and defendant.
375
  You are a legal assistant assigned to analyse evidences.
376
 
377
- 1. Use the information about the primary evidence that was highlighted in stages 2, 3, 4.9. Analyze all conflicting evidence presented by the plaintiff and the defendant according to the following algorithm:
378
- Determine, taking this information into account, which direct fact is confirmed by these pieces of evidence. Specifically, it is necessary to establish which direct fact is confirmed by the plaintiff’s primary evidence and which direct fact is confirmed by the defendant's primary evidence.
379
- A direct fact refers to circumstances or events that are directly and unequivocally confirmed by the presented evidence, meaning a direct fact cannot be refuted by other evidence, provided that this evidence is not falsified. For example, if a party provides evidence of owning a house, within the framework of a direct fact, this evidence confirms that the party owns the property (and this fact cannot be refuted by other evidence).
380
- At the end of this item, two facts must be established: one from the plaintiff's evidence and another from the defendant's evidence.
381
- Next, analyze these two facts to determine whether they directly contradict each other. A direct contradiction is when the presence of one fact excludes the existence of another fact. For example, one party presents evidence that within the direct fact confirms the completion of construction work, and the other party presents evidence that it (the other party) carried out these works; therefore, these two facts contradict each other.
382
- 2.1. If the two facts contradict each other, it is necessary to determine the strength of the evidence confirming them (strong, medium, weak).
383
- For this item:
384
- Weak evidence: Documentary evidence prepared exclusively by one party (signed only by the plaintiff or only by the defendant).
385
- Medium evidence: Documentary evidence signed by several independent parties (e.g., both by the plaintiff and the defendant, by the plaintiff and another person, by the defendant and another person, or simply by another person).
386
- Strong evidence: Objective evidence (evidence implying an independent recording of facts, such as photographs, expert opinions, etc.).
387
- 2.1.1. If the facts are confirmed by evidence of varying strengths, only the fact confirmed by the stronger evidence is considered further, and the weaker evidence is completely ignored.
388
- 2.1.2. If the facts are supported by evidence of equal strength, then a cross-check of these facts must be conducted according to the following algorithm:
389
- 2.1.2.1. Analyze all the plaintiff's evidence to determine what indirect facts in support of the main fact of the defendant, established in item 1, they can prove. For the purposes of this item, indirect facts are understood as circumstances or events whose existence is not directly confirmed by evidence but can be inferred from them through logical conclusions or assumptions.
390
- An example of an indirect fact might be a creditor's action of withdrawing cash, which can indirectly indicate his intention to enter into a loan agreement (e.g., the creditor's good faith).
391
- 2.1.2.2. Analyze all the defendant's evidence to determine what indirect facts in support of the main fact of the plaintiff, established in item 1, they can prove. For the purposes of this item, indirect facts are understood as circumstances or events whose existence is not directly confirmed by evidence but can be inferred from them through logical conclusions or assumptions.
392
- An example of an indirect fact might be a creditor's action of withdrawing cash, which can indirectly indicate his intention to enter into a loan agreement (e.g., the creditor's good faith).
393
- 2.1.2.2.1. If the indirect facts confirmed by the opposing party's evidence only affirm the main fact of the plaintiff, then the main evidence of the defendant is not considered further in the analysis of the evidence.
394
- 2.1.2.2.2. If the indirect facts confirmed by the opposing party's evidence only affirm the main fact of the defendant, then the main evidence of the plaintiff is not considered further in the analysis of the evidence.
395
- 2.1.2.2.3. If the indirect facts of the opposing party do not confirm either the main fact of the plaintiff or the main fact of the defendant, additional evidence is requested from the party to confirm the main fact, in this case, the original evidence is not considered at all. New evidence is analyzed starting from item 1.
396
- 2.1.2.2.4. If such indirect facts of the opposing party confirm both the main fact of the plaintiff and the main fact of the defendant, then analyze the strength of the evidence of the opposing party that confirms the indirect facts in support of the main fact of the plaintiff and the main fact of the defendant.
397
- 2.1.2.2.4.1. If the stronger evidence of the defendant confirms the indirect facts supporting the main fact of the plaintiff, then the main evidence of the defendant is not considered further.
398
- 2.1.2.2.4.2. If the more substantial evidence of the plaintiff confirms the indirect facts supporting the main fact of the defendant, then the main evidence of the plaintiff is not considered further.
399
- 3. At the end, establish the main facts from the primary evidence of both parties, which either do not contradict each other, or make a choice of one main fact out of the two contradicting each other.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  """
401
 
402
  stage_5_prompt = """
 
371
  '''
372
 
373
  stage_4_9_5_prompt = """
374
+ Above is text extracted and facts from lawsuit claim by claimant, text extracted and facts from defendant response, text extracted and facts from clarifications from claimant, text extracted and facts from clarification from defendant and evidence analysis.
375
  You are a legal assistant assigned to analyse evidences.
376
 
377
+ Analyze all the links of conditionally conflicting evidence of the Plaintiff and the Defendant. During the analysis, you must strictly follow the algorithm below, examining each link of conflicting evidence separately. As a result of the analysis of a specific link, you should either choose one of the two conditionally conflicting pieces of evidence, strictly according to the algorithm, or establish that the conditionally conflicting pieces of evidence do not actually contradict each other and can be synthesized to confirm a common fact.
378
+ Here is the algorithm for analyzing conditionally conflicting links of evidence:
379
+ 1 Use the information on the primary evidence provided in Steps 4.9, as well as considering the statement of claim, the defendant's response, and the parties' explanations.
380
+ 1.1. Determine, considering this information, which direct fact is confirmed by these pieces of evidence. Specifically, it is necessary to establish which direct fact is confirmed by the Plaintiff's conditionally conflicting evidence and which direct fact is confirmed by the Defendant's primary evidence.
381
+ A direct fact refers to circumstances or events that are directly and unequivocally confirmed by the presented evidence, meaning a direct fact cannot be refuted by other evidence unless such evidence is falsified. For example, if a party provides evidence of owning a house, within the scope of a direct fact, this evidence confirms that the party owns the property (and this fact cannot be refuted by other evidence).
382
+ At the end of this point, it is necessary to establish two facts: one from the Plaintiff's evidence and one from the Defendant's evidence.
383
+ 1.2. Next, analyze these two facts to determine whether they directly contradict each other. A direct contradiction occurs when the presence of one fact excludes the existence of another fact. For example, one party provides evidence that, within the scope of a direct fact, confirms the completion of construction work, while the other party provides evidence that it (the other party) performed these works; thus, these two facts contradict each other.
384
+ 2.1. If the two facts contradict each other, it is necessary to determine the strength of the evidence (strong, medium, weak) supporting them.
385
+ For this point:
386
+
387
+ Weak evidence: Documentary evidence prepared exclusively by one party (signed only by the Plaintiff or only by the Defendant).
388
+ Medium evidence: Documentary evidence signed by multiple independent parties (e.g., by both the Plaintiff and the Defendant, the Plaintiff and another person, the Defendant and another person, or just another person).
389
+ Strong evidence: Objective evidence (evidence that implies independent recording of facts, e.g., photographs, expert opinions, etc.).
390
+ 2.1.1. If the facts are supported by evidence of different strengths, only the fact supported by the stronger evidence is considered further, and the weaker evidence is completely disregarded.
391
+ 2.1.2. If the facts are supported by evidence of equal strength, a cross-check of these facts should be conducted according to the following algorithm:
392
+ 2.1.2.1. Analyze all of the Plaintiff's evidence to determine what indirect facts in support ofthe Defendant's main fact established in point 1 they can prove. For the purposes of this point, indirect facts refer to circumstances or events whose existence is not directly supported by evidence but can be inferred from it through logical deduction or assumption.
393
+ An example of an indirect fact might be the act of a creditor withdrawing cash, which can indirectly indicate their intention to enter into a loan agreement (e.g., the creditor's good faith).
394
+ 2.1.2.2. Analyze all of the Defendant's evidence to determine what indirect facts in support of the Plaintiff's main fact established in point 1 they can prove. For the purposes of this point, indirect facts refer to circumstances or events whose existence is not directly supported by evidence but can be inferred from it through logical deduction or assumption.
395
+ An example of an indirect fact might be the act of a creditor withdrawing cash, which can indirectly indicate their intention to enter into a loan agreement (e.g., the creditor's good faith).
396
+ 2.1.2.2.1. If indirect facts confirmed by the opposing side's evidence support only the Plaintiff's main fact, then the Defendant's main evidence is not considered further in the analysis of evidence.
397
+ 2.1.2.2.2. If indirect facts confirmed by the opposing side's evidence support only the Defendant's main fact, then the Plaintiff's main evidence is not considered further in the analysis of evidence.
398
+ 2.1.2.2.3 If indirect facts confirmed by the opposing side do not support either the Plaintiff's main fact or the Defendant's main fact, request additional evidence from the party to support the main fact; in this case, the initial evidence is not considered at all. New evidence is analyzed starting from point 1.
399
+ 2.1.2.2.4. If such indirect facts confirmed by the opposing side support both the Plaintiff's main fact and the Defendant's main fact, analyze which strength of evidence by the opposing side supports the indirect facts in confirmation of the Plaintiff's main fact and the Defendant's main fact.
400
+ 2.1.2.2.4.1. If stronger evidence by the Defendant confirms indirect facts in support of the Plaintiff's main fact, then the Defendant's main evidence is not considered further.
401
+ 2.1.2.2.4.2. If stronger evidence by the Plaintiff confirms indirect facts in support of the Defendant's main fact, then the Plaintiff's main evidence is not considered further.
402
+ 2.2. If conditionally conflicting evidence does not directly contradict each other, it is necessary to consider the probable purpose of providing such evidence in addition to the direct facts they establish. For example, the Plaintiff provides acts of completed work to prove that he completed the work and should be paid, while the Defendant provides acts of completed work with another person to prove that the work was completed by another person and should not be paid to the Plaintiff.
403
+ In such a case, the evidence de facto contradicts each other, so it is necessary to choose one of these two pieces of evidence, following the above algorithm.
404
+ If, even considering the purpose of providing such evidence, the evidence does not directly contradict each other, meaning it is objectively possible to conceive of the simultaneous existence of both facts confirmed by such evidence, then it is necessary to synthesize both facts into a single one. For example, the Plaintiff indicates that he is the owner of a house and provides proof of ownership, while the Defendant indicates that he lived in that house. Accordingly, these two facts do not contradict each other, as the Plaintiff can be the owner of the house and the Defendant can live in it. Accordingly, this will be the synthesized fact.
405
+ 3. As a result, choose one of three options based on the analysis of the conditionally conflicting link: either the Plaintiff's evidence, the Defendant's evidence, or the synthesis of both pieces of evidence to confirm a single fact.
406
+
407
+ Output format:
408
+ Evidence Links and Selected Facts
409
+ 1. Evidence Link 1
410
+ ◦ Plaintiff's Evidence:
411
+ ▪ Description: [Brief description of the evidence]
412
+ ▪ Direct Fact: [Description of the direct fact established by this evidence]
413
+ ◦ Defendant's Evidence:
414
+ ▪ Description: [Brief description of the evidence]
415
+ ▪ Direct Fact: [Description of the direct fact established by this evidence]
416
+ ◦ Selection:
417
+ ▪ [Plaintiff's Evidence/Defendant's Evidence/Synthesized Fact]
418
+ ▪ Reason for Selection: [Detailed explanation of the selection of one piece of evidence or synthesis of facts]
419
+ 2. Evidence Link 2
420
+ ◦ Plaintiff's Evidence:
421
+ ▪ Description: [Brief description of the evidence]
422
+ ▪ Direct Fact: [Description of the direct fact established by this evidence]
423
+ ◦ Defendant's Evidence:
424
+ ▪ Description: [Brief description of the evidence]
425
+ ▪ Direct Fact: [Description of the direct fact established by this evidence]
426
+ ◦ Selection:
427
+ ▪ [Plaintiff's Evidence/Defendant's Evidence/Synthesized Fact]
428
+ ▪ Reason for Selection: [Detailed explanation of the selection of one piece of evidence or synthesis of facts]
429
+ etc
430
  """
431
 
432
  stage_5_prompt = """