Skip to content

Commit 1448c01

Browse files
Himanshi-MirosoftHimanshi AgrawalRoopan-MicrosoftHarmanpreet Kaur
authored
fix: CWYD-Contract Assistant - Landing page should mention Contract Assistant (similar to our Research Assistant accelerator) (#1199)
Co-authored-by: Himanshi Agrawal <[email protected]> Co-authored-by: Roopan P M <[email protected]> Co-authored-by: Roopan-Microsoft <[email protected]> Co-authored-by: Harmanpreet Kaur <[email protected]> Co-authored-by: Pavan Kumar <v-kupavan.microsoft.com>
1 parent 6ba499f commit 1448c01

36 files changed

+251
-50
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ In this scenario, a financial advisor is preparing for a meeting with a potentia
114114

115115
Now that the financial advisor is more informed about Woodgrove’s Emerging Markets Funds, they're better equipped to respond to questions about this fund from their client.
116116

117-
#### Contract Review and Summarization Assistant scenario
118-
Additionally, we have implemented a Contract Review and Summarization Assistant scenario to demonstrate how this accelerator can be utilized in any industry. The Contract Review and Summarization Assistant helps professionals manage and interact with a large collection of documents efficiently. For more details, refer to the [Contract Review and Summarization Assistant README](docs/contract_assistance.md).
117+
#### Legal Review and Summarization Assistant scenario
118+
Additionally, we have implemented a Legal Review and Summarization Assistant scenario to demonstrate how this accelerator can be utilized in any industry. The Legal Review and Summarization Assistant helps professionals manage and interact with a large collection of documents efficiently. For more details, refer to the [Legal Review and Summarization Assistant README](docs/contract_assistance.md).
119119

120120
Note: Some of the sample data included with this accelerator was generated using AI and is for illustrative purposes only.
121121

code/backend/batch/utilities/helpers/config/assistant_strategy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
class AssistantStrategy(Enum):
55
DEFAULT = "default"
6-
LEGAL_ASSISTANT = "legal assistant"
6+
CONTRACT_ASSISTANT = "contract assistant"

code/backend/batch/utilities/helpers/config/config_helper.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,13 @@ def get_default_config():
246246

247247
@staticmethod
248248
@functools.cache
249-
def get_default_legal_assistant():
250-
legal_file_path = os.path.join(os.path.dirname(__file__), "default_legal_assistant_prompt.txt")
251-
legal_assistant = ""
252-
with open(legal_file_path, encoding="utf-8") as f:
253-
legal_assistant = f.readlines()
249+
def get_default_contract_assistant():
250+
contract_file_path = os.path.join(os.path.dirname(__file__), "default_contract_assistant_prompt.txt")
251+
contract_assistant = ""
252+
with open(contract_file_path, encoding="utf-8") as f:
253+
contract_assistant = f.readlines()
254254

255-
return ''.join([str(elem) for elem in legal_assistant])
255+
return ''.join([str(elem) for elem in contract_assistant])
256256

257257
@staticmethod
258258
def clear_config():

code/backend/batch/utilities/helpers/config/default_legal_assistant_prompt.txt renamed to code/backend/batch/utilities/helpers/config/default_contract_assistant_prompt.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
- If the information is not available in the context, reply that the information is not in the knowledge base.
6161

6262
## Very Important Instruction
63-
- YOU ARE AN AI LEGAL ASSISTANT.
63+
- YOU ARE AN AI CONTRACT ASSISTANT.
6464
- If you can't answer a question using available documents, reply politely that the information is not in the knowledge base.
6565
- Questions with a date range, use documents within the same range.
6666
Question: {question}

code/backend/pages/04_Configuration.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,10 @@ def validate_answering_user_prompt():
9393
st.warning("Your answering prompt doesn't contain the variable `{question}`")
9494

9595

96-
def config_legal_assistant_prompt():
97-
if st.session_state["ai_assistant_type"] == AssistantStrategy.LEGAL_ASSISTANT.value:
98-
st.success("Legal Assistant Prompt")
99-
st.session_state["answering_user_prompt"] = (
100-
ConfigHelper.get_default_legal_assistant()
101-
)
96+
def config_contract_assistant_prompt():
97+
if st.session_state["ai_assistant_type"] == AssistantStrategy.CONTRACT_ASSISTANT.value:
98+
st.success("Contract Assistant Prompt")
99+
st.session_state["answering_user_prompt"] = ConfigHelper.get_default_contract_assistant()
102100
else:
103101
st.success("Default Assistant Prompt")
104102
st.session_state["answering_user_prompt"] = (
@@ -190,7 +188,7 @@ def validate_documents():
190188
post_answering_prompt_help = "You can configure a post prompt that allows to fact-check or process the answer, given the sources, question and answer. This prompt needs to return `True` or `False`."
191189
use_on_your_data_format_help = "Whether to use a similar prompt format to Azure OpenAI On Your Data, including separate system and user messages, and a few-shot example."
192190
post_answering_filter_help = "The message that is returned to the user, when the post-answering prompt returns."
193-
ai_assistant_type_help = "Whether to use the default user prompt or the Legal Assistance user prompt. Refer to the Legal Assistance README for more details."
191+
ai_assistant_type_help = "Whether to use the default user prompt or the Contract Assistance user prompt. Refer to the Contract Assistance README for more details."
194192
example_documents_help = (
195193
"JSON object containing documents retrieved from the knowledge base, in the following format: \n"
196194
"""```json
@@ -219,7 +217,7 @@ def validate_documents():
219217
st.selectbox(
220218
"Assistant Type",
221219
key="ai_assistant_type",
222-
on_change=config_legal_assistant_prompt,
220+
on_change=config_contract_assistant_prompt,
223221
options=config.get_available_ai_assistant_types(),
224222
help=ai_assistant_type_help,
225223
)

code/create_app.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,4 +448,10 @@ def speech_config():
448448

449449
return {"error": "Failed to get speech config"}, 500
450450

451+
@app.route("/api/assistanttype", methods=["GET"])
452+
def assistanttype():
453+
ConfigHelper.get_active_config_or_default.cache_clear()
454+
result = ConfigHelper.get_active_config_or_default()
455+
return jsonify({"ai_assistant_type": result.prompts.ai_assistant_type})
456+
451457
return app

code/frontend/src/api/api.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,24 @@ export async function callConversationApi(options: ConversationRequest, abortSig
2121

2222
return response;
2323
}
24+
25+
export async function getAssistantTypeApi() {
26+
try {
27+
const response = await fetch("/api/assistanttype", {
28+
method: "GET",
29+
headers: {
30+
"Content-Type": "application/json"
31+
},
32+
});
33+
34+
if (!response.ok) {
35+
throw new Error('Network response was not ok');
36+
}
37+
38+
const config = await response.json(); // Parse JSON response
39+
return config;
40+
} catch (error) {
41+
console.error('Failed to fetch configuration:', error);
42+
return null; // Return null or some default value in case of error
43+
}
44+
}
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)