Redmind commited on
Commit
18739c5
·
verified ·
1 Parent(s): c5fe17e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -41
app.py CHANGED
@@ -509,7 +509,7 @@ def bind_llm(llm, tools,prompt_template):
509
  # Define input and output models using Pydantic
510
  class QueryInput(BaseModel):
511
  question: str = Field(
512
- description="The question to be answered by appropriate tool. Please follow the instructions. For API tool, do not send the question as it is. Please send the ASN id.")# Invoke datavisulaization tool by processing the user question and send two inputs to the tool. One input will be the warehouse name and another input to the tool will be the entire user_question itself. Please join those two strings and send them as a single input string with ':' as delimiter")
513
  # config: dict = Field(default={}, description="Optional configuration for the database query.")
514
 
515
 
@@ -522,27 +522,7 @@ class QueryOutput(BaseModel):
522
  # Wrap the function with StructuredTool for better parameter handling
523
  tools = [
524
 
525
- StructuredTool(
526
- func=get_ASN_data,
527
- name="APIData",
528
- args_schema=QueryInput,
529
- output_schema=QueryOutput,
530
- description="Tool to get details of ASN api. ASN id will be in the input with the format of first three letters as ASN and it is followed by 11 digit numeral. Pass only the id as input. Do not send the complete user question to the tool. If there are any other queries related to ASN without ASN id, please use the document tool."
531
- ),
532
- StructuredTool(
533
- func=document_data_tool,
534
- name="DocumentData",
535
- args_schema=QueryInput,
536
- output_schema=QueryOutput,
537
- description="You are an AI assistant trained to help with warehouse management questions based on a detailed document about our WMS. The document covers various processes such as ASN handling, purchase orders, cross docking, appointment scheduling for shipments, and yard management. Please provide a complete and concise response within 200 words and Ensure that the response is not truncated and covers the essential points. "
538
- ),
539
- StructuredTool(
540
- func=database_tool,
541
- name="DatabaseQuery",
542
- args_schema=QueryInput,
543
- output_schema=QueryOutput,
544
- description="Tool to query the database based on structured input."
545
- ),
546
  StructuredTool(
547
  func=inventory_report,
548
  name="dataVisualization",
@@ -561,11 +541,7 @@ tools = [
561
  )
562
  ]
563
 
564
- prompt_template = f"""You are an assistant that helps with database queries, API information, and document retrieval. Your job is to provide clear, complete, and detailed responses to the following queries. Please give the output response in an user friendly way and remove "**" from the response. For example, document related queries can be answered in a clear and concise way with numbering and not as a paragraph. Database related queries should be answered with proper indentation and use numbering for the rows. ASN id related queries should be answered with proper indentation and use numbering for the rows.
565
-
566
- For ASN id related questions, if the user specifies an ASN id, provide the information from the api tool. Pass only the id as input to the tool. Do not pass the entire question as input to the tool. If the details are not found, say it in a clear and concise way.
567
- You are an AI assistant trained to help with warehouse management questions based on a detailed document about our WMS. The document covers various processes such as ASN handling, purchase orders, cross docking, appointment scheduling for shipments, and yard management. Please provide a complete and concise response within 200 words and Ensure that the response is not truncated and covers the essential points. When answering, focus on providing actionable insights and clear explanations related to the specific query. Please remove "**" from the response.
568
- For SQL database-related questions, only use the fields available in the warehouse schema, including tables such as customer_master, efs_company_master, efs_group_company_master, efs_region_master, party_address_detail, wms_warehouse_master.
569
  For datavisualization, user will ask for inventory report of a particular warehouse. Your job is to return the image path to chat interface and display the image as output.
570
  If the proper response is generated, return the response back. Do not iterate again and again.
571
  {{agent_scratchpad}}
@@ -1106,11 +1082,8 @@ def add_to_redmindgpt(title, summary):
1106
  # Add the new tool to the beginning
1107
  tools.insert(0, run_time_tool)
1108
 
1109
- prompt_template = f"""You are an assistant that helps with database queries, API information, and document retrieval. Your job is to provide clear, complete, and detailed responses to the following queries. Please give the output response in an user friendly way and remove "**" from the response. For example, document related queries can be answered in a clear and concise way with numbering and not as a paragraph. Database related queries should be answered with proper indentation and use numbering for the rows. ASN id related queries should be answered with proper indentation and use numbering for the rows.
1110
  {run_time_tool_summary}
1111
- For ASN id related questions, if the user specifies an ASN id, provide the information from the api tool. Pass only the id as input to the tool. Do not pass the entire question as input to the tool. If the details are not found, say it in a clear and concise way.
1112
- You are an AI assistant trained to help with warehouse management questions based on a detailed document about our WMS. The document covers various processes such as ASN handling, purchase orders, cross docking, appointment scheduling for shipments, and yard management. Please provide a complete and concise response within 200 words and Ensure that the response is not truncated and covers the essential points. When answering, focus on providing actionable insights and clear explanations related to the specific query. Please remove "**" from the response.
1113
- For SQL database-related questions, only use the fields available in the warehouse schema, including tables such as customer_master, efs_company_master, efs_group_company_master, efs_region_master, party_address_detail, wms_warehouse_master.
1114
  For datavisualization, user will ask for inventory report of a particular warehouse. Your job is to return the image path to chat interface and display the image as output.
1115
 
1116
  {{agent_scratchpad}}
@@ -1135,11 +1108,8 @@ def add_to_redmindgpt(title, summary):
1135
  # Add the new tool to the beginning
1136
  tools.insert(0, run_time_excel_tool)
1137
 
1138
- prompt_template = f"""You are an assistant that helps with database queries, API information, and document retrieval. Your job is to provide clear, complete, and detailed responses to the following queries. Please give the output response in an user friendly way and remove "**" from the response. For example, document related queries can be answered in a clear and concise way with numbering and not as a paragraph. Database related queries should be answered with proper indentation and use numbering for the rows. ASN id related queries should be answered with proper indentation and use numbering for the rows.
1139
  {run_time_excel_tool_summary}
1140
- For ASN id related questions, if the user specifies an ASN id, provide the information from the api tool. Pass only the id as input to the tool. Do not pass the entire question as input to the tool. If the details are not found, say it in a clear and concise way.
1141
- You are an AI assistant trained to help with warehouse management questions based on a detailed document about our WMS. The document covers various processes such as ASN handling, purchase orders, cross docking, appointment scheduling for shipments, and yard management. Please provide a complete and concise response within 200 words and Ensure that the response is not truncated and covers the essential points. When answering, focus on providing actionable insights and clear explanations related to the specific query. Please remove "**" from the response.
1142
- For SQL database-related questions, only use the fields available in the warehouse schema, including tables such as customer_master, efs_company_master, efs_group_company_master, efs_region_master, party_address_detail, wms_warehouse_master.
1143
  For datavisualization, user will ask for inventory report of a particular warehouse. Your job is to return the image path to chat interface and display the image as output.
1144
 
1145
  {{agent_scratchpad}}
@@ -1515,9 +1485,6 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
1515
 
1516
  # Buttons for sample queries
1517
  with gr.Row():
1518
- sample_button = gr.Button("What are the details of ASN24091600002", elem_classes="gr-buttonbig")
1519
- sample_button1 = gr.Button("What are the active warehouses available", elem_classes="gr-buttonbig")
1520
- sample_button2 = gr.Button("Explain Pre-Receiving Yard Management", elem_classes="gr-buttonbig")
1521
  sample_button3 = gr.Button("can you generate a doughnut chart with item name and quantities for warehouse DUBAIWARE", elem_classes="gr-buttonbig")
1522
  sample_button4 = gr.Button("Analyze item name & quantity for different customers in a stacked bar chart for the warehouse DUBAIWARE & send email to [email protected]", elem_classes="gr-button")
1523
 
@@ -1568,9 +1535,6 @@ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
1568
  submit_feedback_button.click(submit_feedback, [feedback_textbox, chatbot], [chatbot, feedback_textbox, submit_feedback_button])
1569
  submit_feedback_button.click(lambda x: gr.update(value=''), [], [feedback_textbox])
1570
 
1571
- sample_button.click(handle_query, [sample_button, chatbot], [chatbot])
1572
- sample_button1.click(handle_query, [sample_button1, chatbot], [chatbot])
1573
- sample_button2.click(handle_query, [sample_button2, chatbot], [chatbot])
1574
  sample_button3.click(handle_query, [sample_button3, chatbot], [chatbot])
1575
  sample_button4.click(handle_query, [sample_button4, chatbot], [chatbot])
1576
 
 
509
  # Define input and output models using Pydantic
510
  class QueryInput(BaseModel):
511
  question: str = Field(
512
+ description="The question to be answered by appropriate tool. Please follow the instructions. ")
513
  # config: dict = Field(default={}, description="Optional configuration for the database query.")
514
 
515
 
 
522
  # Wrap the function with StructuredTool for better parameter handling
523
  tools = [
524
 
525
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
526
  StructuredTool(
527
  func=inventory_report,
528
  name="dataVisualization",
 
541
  )
542
  ]
543
 
544
+ prompt_template = f"""You are an assistant that helps with document retrieval, excel analysis and visual analysis. Your job is to provide clear, complete, and detailed responses to the following queries. Please give the output response in an user friendly way and remove "**" from the response. For example, document related queries can be answered in a clear and concise way with numbering and not as a paragraph.
 
 
 
 
545
  For datavisualization, user will ask for inventory report of a particular warehouse. Your job is to return the image path to chat interface and display the image as output.
546
  If the proper response is generated, return the response back. Do not iterate again and again.
547
  {{agent_scratchpad}}
 
1082
  # Add the new tool to the beginning
1083
  tools.insert(0, run_time_tool)
1084
 
1085
+ prompt_template = f"""You are an assistant that helps with database queries, API information, and document retrieval. Your job is to provide clear, complete, and detailed responses to the following queries. Please give the output response in an user friendly way and remove "**" from the response. For example, document related queries can be answered in a clear and concise way with numbering and not as a paragraph.
1086
  {run_time_tool_summary}
 
 
 
1087
  For datavisualization, user will ask for inventory report of a particular warehouse. Your job is to return the image path to chat interface and display the image as output.
1088
 
1089
  {{agent_scratchpad}}
 
1108
  # Add the new tool to the beginning
1109
  tools.insert(0, run_time_excel_tool)
1110
 
1111
+ prompt_template = f"""You are an assistant that helps with database queries, API information, and document retrieval. Your job is to provide clear, complete, and detailed responses to the following queries. Please give the output response in an user friendly way and remove "**" from the response. For example, document related queries can be answered in a clear and concise way with numbering and not as a paragraph.
1112
  {run_time_excel_tool_summary}
 
 
 
1113
  For datavisualization, user will ask for inventory report of a particular warehouse. Your job is to return the image path to chat interface and display the image as output.
1114
 
1115
  {{agent_scratchpad}}
 
1485
 
1486
  # Buttons for sample queries
1487
  with gr.Row():
 
 
 
1488
  sample_button3 = gr.Button("can you generate a doughnut chart with item name and quantities for warehouse DUBAIWARE", elem_classes="gr-buttonbig")
1489
  sample_button4 = gr.Button("Analyze item name & quantity for different customers in a stacked bar chart for the warehouse DUBAIWARE & send email to [email protected]", elem_classes="gr-button")
1490
 
 
1535
  submit_feedback_button.click(submit_feedback, [feedback_textbox, chatbot], [chatbot, feedback_textbox, submit_feedback_button])
1536
  submit_feedback_button.click(lambda x: gr.update(value=''), [], [feedback_textbox])
1537
 
 
 
 
1538
  sample_button3.click(handle_query, [sample_button3, chatbot], [chatbot])
1539
  sample_button4.click(handle_query, [sample_button4, chatbot], [chatbot])
1540