-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Legal Assistant configuration (#1007)
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ross Smith <ross-p-smith@users.noreply.github.com> Co-authored-by: komalg1 <komalgrover@microsoft.com> Co-authored-by: Chinedum Echeta <60179183+cecheta@users.noreply.github.com> Co-authored-by: Arpit Gaur <gaurarpit@gmail.com> Co-authored-by: Liam Moat <liam.moat@microsoft.com> Co-authored-by: frtibble <32080479+frtibble@users.noreply.github.com> Co-authored-by: almicia <aldunson@microsoft.com>
- Loading branch information
1 parent
7989689
commit 64088d8
Showing
29 changed files
with
208 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
code/backend/batch/utilities/helpers/config/assistant_strategy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from enum import Enum | ||
|
||
|
||
class AssistantStrategy(Enum): | ||
DEFAULT = "default" | ||
LEGAL_ASSISTANT = "legal assistant" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
code/backend/batch/utilities/helpers/config/default_legal_assistant_prompt.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
## Retrieved documents | ||
{sources} | ||
## User Question | ||
{question} | ||
|
||
## On your Available documents | ||
## **Point 1**: A list of documents will displayed as below: | ||
- your answer: | ||
- Extract the document titles. | ||
- YOU DO NOT REPEAT CITATION NUMBER. | ||
- YOU DO NOT INVENT THE DOCUMENT TITLE. | ||
- YOU DO NOT REPEAT DOCUMENT TITLE IN THE LIST. | ||
- EACH DOCUMENT TITLE IN THE LIST IS UNIQUE. | ||
- ALWAYS CREATE A LIST OF DOCUMENTS AS A tab-separated table with columns: #, Name of the document. | ||
|
||
|
||
## When asked about documents related to a state [Name of the state] or documents based on a specific criterion (e.g., business type) or within a specific date range | ||
- your answer: | ||
- Extract and list the document titles that mention the state [Name of the state] in their metadata, or specified criterion (e.g., business type), or the specified date range. | ||
- Format the list as we defined in **Point 1**. | ||
|
||
## **Point 2**: When asked to summarize a specific document | ||
- your answer: | ||
- Extract the key or relevant content for the specified document. | ||
- Group Documents by document title. | ||
- If any key factor (such as party, date, or any main key summarization part) is not available, do not include it in the answer. | ||
- Summary of [Document Title]: | ||
- You write one paragraph with the summary about the document. | ||
- Parties Involved: [Party A], [Party B] (if available) | ||
- Key Dates (if available): | ||
- Effective date: [Date] (if available) | ||
- Expire date: [Date] (if available) | ||
- Obligations (if available): | ||
- [Party A] is responsible for [obligation 1] (if available) | ||
- [Party B] is responsible for [obligation 2] (if available) | ||
- Terms (if available): | ||
- Payment terms: [details] (if available) | ||
- Termination clauses: [details] (if available) | ||
|
||
## When asked to provide a list of document summaries | ||
- your answer: | ||
- Extract the relevant documents and their summaries from available documents. | ||
- Format the response using **Point 2** for each document in the list. | ||
|
||
## When asked to summarize termination clauses used in these documents | ||
- your answer: | ||
- Extract the termination clauses from the documents listed from the previous question. | ||
- Provide the extracted information in a clear and concise manner. | ||
- Format the response using **Point 2** for each document in the list. | ||
|
||
## When asked for clause is defined in a contract | ||
- your answer: | ||
- Extract the specified clause (e.g., payment term clause) from the specified contract or from the previous document list. | ||
- Provide the extracted information in a clear and concise manner. | ||
- Format the response using **Point 2** for each document in the list. | ||
|
||
## When asked FAQ questions related documents | ||
- your answer: | ||
- Ensure the question is answered using only the information you have available. | ||
- If the information is not available in the context, reply that the information is not in the knowledge base. | ||
|
||
## Very Important Instruction | ||
- YOU ARE AN AI LEGAL ASSISTANT. | ||
- If you can't answer a question using available documents, reply politely that the information is not in the knowledge base. | ||
- Questions with a date range, use documents within the same range. | ||
Question: {question} | ||
Answer: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+2.88 MB
data/legal_data/1628215729_Kyndryl_-_Master_Agreement__executed_utah.pdf
Binary file not shown.
Binary file added
BIN
+186 KB
data/legal_data/Final_MA_999_200000000170_3_MA_FORM_ADV_PDF wireless.PDF
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+95.8 KB
data/legal_data/Master_Agreement_OEM_Filters_ALDOT_V1 - OEM filters.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.94 MB
data/legal_data/NASPO_Participating_Addendum - insight public sector.pdf
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+281 KB
data/legal_data/Server_Storage_Solutions_Technical_Services_ITB_v1.2 - OEM Terms.pdf
Binary file not shown.
Binary file added
BIN
+453 KB
data/legal_data/State_of_Alabama_NASPO_Cloud_Services_PA_032224_.docx 1.pdf
Binary file not shown.
Binary file added
BIN
+453 KB
data/legal_data/State_of_Alabama_NASPO_Cloud_Services_PA_032224_.docx.pdf
Binary file not shown.
Binary file added
BIN
+96.9 KB
data/legal_data/Statewide_Truck_Chassis_19_000_GVWR_and_Greater-Southland_V1.pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# CWYD Legal Assistant | ||
|
||
## Overview | ||
The CWYD Legal Assistant is designed to help legal professionals efficiently manage and interact with a large collection of legal documents. It utilizes advanced natural language processing capabilities to provide accurate and contextually relevant responses to user queries about the documents. | ||
|
||
## Legal Assistant Infrastructure Configuration | ||
|
||
The following is the CWYD infrastructure configuration that we suggest to optimize the performance and functionality of the Legal Assistant: | ||
|
||
- **Azure Semantic Search**: Utilize Azure Semantic Search to efficiently index and search legal documents. This provides powerful search capabilities and integration with other Azure services. | ||
- **Azure Cognitive Search Top K 15**: Set the Top K parameter to 15 to retrieve the top 15 most relevant documents. This configuration helps in providing precise and relevant search results for user queries. | ||
- **Azure Search Integrated Vectorization**: Enable integrated vectorization in Azure Search to improve the semantic understanding and relevance of search results. This enhances the Legal Assistant's ability to provide contextually accurate answers. | ||
- **Azure OpenAI Model gpt-4o**: Leverage the Azure OpenAI model gpt-4o for advanced natural language processing capabilities. This model is well-suited for handling complex legal queries and providing detailed and contextually appropriate responses. | ||
- **Orchestration Strategy: Semantic Kernel**: Implement the Semantic Kernel orchestration strategy to effectively manage the integration and interaction between different components of the infrastructure. This strategy ensures seamless operation and optimal performance of the Legal Assistant. | ||
- **Conversation Flow Options**: Setting `CONVERSATION_FLOW` enables running advanced AI models like GPT-4o on your own enterprise data without needing to train or fine-tune models. | ||
|
||
By following these infrastructure configurations, you can enhance the efficiency, accuracy, and overall performance of the CWYD Legal Assistant, ensuring it meets the high demands and expectations of legal professionals. | ||
|
||
## Updating Configuration Fields | ||
|
||
To apply the suggested configurations in your deployment, update the following fields accordingly: | ||
- **Azure Semantic Search**: Set `AZURE_SEARCH_USE_SEMANTIC_SEARCH` to `true` | ||
- **Azure Cognitive Search Top K 15**: Set `AZURE_SEARCH_TOP_K` to `15`. | ||
- **Azure Search Integrated Vectorization**: Set `AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION` to `true`. | ||
- **Azure OpenAI Model**: Set `AZURE_OPENAI_MODEL` to `gpt-4o`. | ||
- **Azure OpenAI Model Name**: Set `AZURE_OPENAI_MODEL_NAME` to `gpt-4o`. (could be different based on the name of the Azure OpenAI model deployment) | ||
- **Azure OpenAI Model Name Version**: Set `AZURE_OPENAI_MODEL_VERSION` to `2024-05-13`. | ||
- **Conversation Flow Options**: Set `CONVERSATION_FLOW` to `byod` | ||
- **Orchestration Strategy**: Set `ORCHESTRATION_STRATEGY` to `Semantic Kernel`. | ||
|
||
|
||
## Admin Configuration | ||
In the admin panel, there is a dropdown to select the CWYD Legal Assistant. The options are: | ||
|
||
- **Default**: CWYD default prompt. | ||
|
||
![UnSelected](images/cwyd_admin_legal_unselected.png) | ||
|
||
- **Selected**: Legal Assistant prompt. | ||
|
||
![Checked](images/cwyd_admin_legal_selected.png) | ||
|
||
When the user selects "Legal Assistant," the user prompt textbox will update to the Legal Assistant prompt. When the user selects the default, the user prompt textbox will update to the default prompt. Note that if the user has a custom prompt in the user prompt textbox, selecting an option from the dropdown will overwrite the custom prompt with the default or legal assistant prompt. Ensure to **Save the Configuration** after making this change. | ||
|
||
## Legal Assistant Prompt | ||
The Legal Assistant prompt configuration ensures that the AI responds accurately based on the given context, handling a variety of tasks such as listing documents, filtering based on specific criteria, and summarizing document content. Below is the detailed prompt configuration: | ||
|
||
```plaintext | ||
## Summary Contracts | ||
Context: | ||
{sources} | ||
- You are a legal assistant. | ||
``` | ||
You can see the [Legal Assistant Prompt](../code/backend/batch/utilities/helpers/config/default_legal_assistant_prompt.txt) file for more details. | ||
|
||
## Sample Legal Data | ||
We have added sample legal data in the [Legal Assistant sample Docs](../data/legal_data) folder. This data can be used to test and demonstrate the Legal Assistant's capabilities. | ||
|
||
## Conclusion | ||
This README provides an overview of the CWYD Legal Assistant prompt, instructions for updating the prompt configuration, and examples of questions and answers. Ensure you follow the guidelines for updating the prompt to maintain consistency and accuracy in responses. |