diff --git a/text2sql/prompt.yaml b/text2sql/prompt.yaml
index 3facc69..03b6f3f 100644
--- a/text2sql/prompt.yaml
+++ b/text2sql/prompt.yaml
@@ -10,7 +10,7 @@ template: |
The response to the user must meet the requirements in RESPONSE OUTPUT REQUIREMENTS.
IMPORTANT INFORMATION contains useful information that you can use to aid your knowledge.
- CONVERSATION HISTORY contains the previous question and answer pairs in the conversation in JSON format. Do not use this information to answer the question, but to provide context on what was asked previously.
+ CHAT HISTORY contains the previous question and answer pairs in the conversation in JSON format. Do not use this information to answer the question, but to provide context on what was asked previously.
[IMPORTANT INFORMATION]
@@ -38,7 +38,7 @@ template: |
3. Information Sources:
Use only information from the provided functions and specified important information.
- Do not use any external sources or the conversation history for constructing the response.
+ Do not use any external sources or the chat history for constructing the response.
In case of conflicting information, prioritize data from the SQL Database as the primary source of truth.
4. Calculations:
@@ -82,13 +82,8 @@ template: |
[END SOURCES PROPERTY REQUIREMENTS]
[END RESPONSE OUTPUT REQUIREMENTS]
-
- [CONVERSATION HISTORY]
-
- {{$chat_history}}
-
- [END CONVERSATION HISTORY]
+ {{$chat_history}}
{{$user_input}}
description: Chatbot
name: ChatBot
@@ -96,9 +91,6 @@ input_variables:
- name: user_input
description: The user input
is_required: true
- - name: chat_history
- description: The history of the conversation for the last 3 messages
- is_required: true
- name: important_information
description: Useful information for the chatbot
is_required: true
diff --git a/text2sql/rag_with_ai_search_and_text_2_sql.ipynb b/text2sql/rag_with_ai_search_and_text_2_sql.ipynb
index e0e797e..15d03d7 100644
--- a/text2sql/rag_with_ai_search_and_text_2_sql.ipynb
+++ b/text2sql/rag_with_ai_search_and_text_2_sql.ipynb
@@ -13,7 +13,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {
"gather": {
"logged": 1718623217703
@@ -58,7 +58,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -75,7 +75,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 3,
"metadata": {
"gather": {
"logged": 1718623218006
@@ -97,7 +97,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 4,
"metadata": {
"gather": {
"logged": 1718623218267
@@ -125,7 +125,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 5,
"metadata": {
"gather": {
"logged": 1718623218614
@@ -140,7 +140,18 @@
}
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "KernelPlugin(name='SQL', description=None, functions={'GetEntitySchema': KernelFunctionFromMethod(metadata=KernelFunctionMetadata(name='GetEntitySchema', plugin_name='SQL', description='Get the detailed schema of an entity in the Database. Use the entity and the column returned to formulate a SQL query. The view name or table name must be one of the ENTITY NAMES defined in the [ENTITIES LIST]. Only use the column names obtained from GetEntitySchema() when constructing a SQL query, do not make up column names.', parameters=[KernelParameterMetadata(name='entity_name', description='The view or table name to get the schema for. It must be one of the ENTITY NAMES defined in the [ENTITIES LIST] function.', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string', 'description': 'The view or table name to get the schema for. It must be one of the ENTITY NAMES defined in the [ENTITIES LIST] function.'}, function_schema_include=True)], is_prompt=False, is_asynchronous=True, return_parameter=KernelParameterMetadata(name='return', description='', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string'}, function_schema_include=True), additional_properties={}), invocation_duration_histogram=, streaming_duration_histogram=, method=>, stream_method=None), 'RunSQLQuery': KernelFunctionFromMethod(metadata=KernelFunctionMetadata(name='RunSQLQuery', plugin_name='SQL', description='Runs an SQL query against the SQL Database to extract information.', parameters=[KernelParameterMetadata(name='sql_query', description='The SQL query to run against the DB', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string', 'description': 'The SQL query to run against the DB'}, function_schema_include=True)], is_prompt=False, is_asynchronous=True, return_parameter=KernelParameterMetadata(name='return', description='', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string'}, function_schema_include=True), additional_properties={}), invocation_duration_histogram=, streaming_duration_histogram=, method=>, stream_method=None)})"
+ ]
+ },
+ "execution_count": 5,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# Register the SQL Plugin with the Database name to use.\n",
"sql_plugin = SQLPlugin(database=os.environ[\"SQL_DB_NAME\"])\n",
@@ -149,9 +160,20 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 6,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "KernelPlugin(name='AISearch', description=None, functions={'QueryDocumentStorage': KernelFunctionFromMethod(metadata=KernelFunctionMetadata(name='QueryDocumentStorage', plugin_name='AISearch', description='Runs an hybrid semantic search against some text to return relevant documents that are indexed within AI Search.', parameters=[KernelParameterMetadata(name='text', description='The text to run a semantic search against.', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string', 'description': 'The text to run a semantic search against.'}, function_schema_include=True)], is_prompt=False, is_asynchronous=True, return_parameter=KernelParameterMetadata(name='return', description='', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string'}, function_schema_include=True), additional_properties={}), invocation_duration_histogram=, streaming_duration_histogram=, method=>, stream_method=None)})"
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"ai_search_plugin = AISearchPlugin()\n",
"kernel.add_plugin(ai_search_plugin, \"AISearch\")"
@@ -172,7 +194,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
@@ -184,7 +206,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
@@ -204,7 +226,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
@@ -213,7 +235,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
@@ -251,6 +273,7 @@
" function_name=\"Chat\",\n",
" plugin_name=\"ChatBot\",\n",
" arguments=arguments,\n",
+ " chat_history=chat_history,\n",
" )\n",
"\n",
" logging.info(\"Answer: %s\", answer)\n",
diff --git a/text2sql/rag_with_text_2_sql.ipynb b/text2sql/rag_with_text_2_sql.ipynb
index ea5a307..402b9d1 100644
--- a/text2sql/rag_with_text_2_sql.ipynb
+++ b/text2sql/rag_with_text_2_sql.ipynb
@@ -13,7 +13,7 @@
},
{
"cell_type": "code",
- "execution_count": 13,
+ "execution_count": 1,
"metadata": {
"gather": {
"logged": 1718623217703
@@ -143,7 +143,7 @@
{
"data": {
"text/plain": [
- "KernelPlugin(name='SQL', description=None, functions={'GetEntitySchema': KernelFunctionFromMethod(metadata=KernelFunctionMetadata(name='GetEntitySchema', plugin_name='SQL', description='Get the detailed schema of an entity in the Database. Use the entity and the column returned to formulate a SQL query. The view name or table name must be one of the ENTITY NAMES defined in the [ENTITIES LIST]. Only use the column names obtained from GetEntitySchema() when constructing a SQL query, do not make up column names.', parameters=[KernelParameterMetadata(name='entity_name', description='The view or table name to get the schema for. It must be one of the ENTITY NAMES defined in the [ENTITIES LIST] function.', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string', 'description': 'The view or table name to get the schema for. It must be one of the ENTITY NAMES defined in the [ENTITIES LIST] function.'}, function_schema_include=True)], is_prompt=False, is_asynchronous=True, return_parameter=KernelParameterMetadata(name='return', description='', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string'}, function_schema_include=True), additional_properties={}), invocation_duration_histogram=, streaming_duration_histogram=, method=>, stream_method=None), 'RunSQLQuery': KernelFunctionFromMethod(metadata=KernelFunctionMetadata(name='RunSQLQuery', plugin_name='SQL', description='Runs an SQL query against the SQL Database to extract information.', parameters=[KernelParameterMetadata(name='sql_query', description='The SQL query to run against the DB', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string', 'description': 'The SQL query to run against the DB'}, function_schema_include=True)], is_prompt=False, is_asynchronous=True, return_parameter=KernelParameterMetadata(name='return', description='', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string'}, function_schema_include=True), additional_properties={}), invocation_duration_histogram=, streaming_duration_histogram=, method=>, stream_method=None)})"
+ "KernelPlugin(name='SQL', description=None, functions={'GetEntitySchema': KernelFunctionFromMethod(metadata=KernelFunctionMetadata(name='GetEntitySchema', plugin_name='SQL', description='Get the detailed schema of an entity in the Database. Use the entity and the column returned to formulate a SQL query. The view name or table name must be one of the ENTITY NAMES defined in the [ENTITIES LIST]. Only use the column names obtained from GetEntitySchema() when constructing a SQL query, do not make up column names.', parameters=[KernelParameterMetadata(name='entity_name', description='The view or table name to get the schema for. It must be one of the ENTITY NAMES defined in the [ENTITIES LIST] function.', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string', 'description': 'The view or table name to get the schema for. It must be one of the ENTITY NAMES defined in the [ENTITIES LIST] function.'}, function_schema_include=True)], is_prompt=False, is_asynchronous=True, return_parameter=KernelParameterMetadata(name='return', description='', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string'}, function_schema_include=True), additional_properties={}), invocation_duration_histogram=, streaming_duration_histogram=, method=>, stream_method=None), 'RunSQLQuery': KernelFunctionFromMethod(metadata=KernelFunctionMetadata(name='RunSQLQuery', plugin_name='SQL', description='Runs an SQL query against the SQL Database to extract information.', parameters=[KernelParameterMetadata(name='sql_query', description='The SQL query to run against the DB', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string', 'description': 'The SQL query to run against the DB'}, function_schema_include=True)], is_prompt=False, is_asynchronous=True, return_parameter=KernelParameterMetadata(name='return', description='', default_value=None, type_='str', is_required=True, type_object=, schema_data={'type': 'string'}, function_schema_include=True), additional_properties={}), invocation_duration_histogram=, streaming_duration_histogram=, method=>, stream_method=None)})"
]
},
"execution_count": 5,
@@ -247,6 +247,7 @@
" function_name=\"Chat\",\n",
" plugin_name=\"ChatBot\",\n",
" arguments=arguments,\n",
+ " chat_history=chat_history,\n",
" )\n",
"\n",
" logging.info(\"Answer: %s\", answer)\n",
@@ -281,7 +282,7 @@
"\n",
"The response to the user must meet the requirements in RESPONSE OUTPUT REQUIREMENTS.\n",
"IMPORTANT INFORMATION contains useful information that you can use to aid your knowledge.\n",
- "CONVERSATION HISTORY contains the previous question and answer pairs in the conversation in JSON format. Do not use this information to answer the question, but to provide context on what was asked previously.\n",
+ "CHAT HISTORY contains the previous question and answer pairs in the conversation in JSON format. Do not use this information to answer the question, but to provide context on what was asked previously.\n",
"\n",
"[IMPORTANT INFORMATION]\n",
"\n",
@@ -363,7 +364,7 @@
"\n",
" 3. Information Sources:\n",
" Use only information from the provided functions and specified important information.\n",
- " Do not use any external sources or the conversation history for constructing the response.\n",
+ " Do not use any external sources or the chat history for constructing the response.\n",
" In case of conflicting information, prioritize data from the SQL Database as the primary source of truth.\n",
"\n",
" 4. Calculations:\n",
@@ -407,52 +408,48 @@
" [END SOURCES PROPERTY REQUIREMENTS]\n",
"\n",
"[END RESPONSE OUTPUT REQUIREMENTS]\n",
- "\n",
- "[CONVERSATION HISTORY]\n",
- "\n",
- " \n",
- "\n",
- "[END CONVERSATION HISTORY]\n",
"\n",
+ "\n",
"What are the different product categories we have? as xml, treating as text, error was: not well-formed (invalid token): line 75, column 78\n",
"INFO:httpx:HTTP Request: POST https://open-ai-gpt-001.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-01 \"HTTP/1.1 200 OK\"\n",
- "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=37, prompt_tokens=2621, total_tokens=2658)\n",
+ "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=37, prompt_tokens=2605, total_tokens=2642)\n",
"INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_chat_completion_base:processing 1 tool calls in parallel.\n",
"INFO:semantic_kernel.kernel:Calling SQL-GetEntitySchema function with args: {\"entity_name\": \"GET ALL CATEGORIES\"}\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-GetEntitySchema invoking.\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-GetEntitySchema succeeded.\n",
- "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.000754s\n",
+ "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.000877s\n",
"INFO:httpx:HTTP Request: POST https://open-ai-gpt-001.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-01 \"HTTP/1.1 200 OK\"\n",
- "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=38, prompt_tokens=2914, total_tokens=2952)\n",
+ "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=34, prompt_tokens=2898, total_tokens=2932)\n",
"INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_chat_completion_base:processing 1 tool calls in parallel.\n",
- "INFO:semantic_kernel.kernel:Calling SQL-RunSQLQuery function with args: {\"sql_query\":\"SELECT ProductCategoryID, ParentProductCategoryName, ProductCategoryName FROM SalesLT.vGetAllCategories;\"}\n",
+ "INFO:semantic_kernel.kernel:Calling SQL-RunSQLQuery function with args: {\"sql_query\":\"SELECT ProductCategoryName, ParentProductCategoryName FROM SalesLT.vGetAllCategories;\"}\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-RunSQLQuery invoking.\n",
"INFO:root:Executing SQL Query\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-RunSQLQuery succeeded.\n",
- "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.564825s\n",
+ "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 1.153722s\n",
"INFO:httpx:HTTP Request: POST https://open-ai-gpt-001.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-01 \"HTTP/1.1 200 OK\"\n",
- "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=786, prompt_tokens=3952, total_tokens=4738)\n",
+ "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=630, prompt_tokens=3636, total_tokens=4266)\n",
"INFO:semantic_kernel.functions.kernel_function:Function ChatBot-Chat succeeded.\n",
- "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 10.977118s\n",
- "INFO:root:Answer: \n",
- "{ \n",
- " \"answer\": \"The product categories available in our database are organised under four main parent categories: Accessories, Clothing, Components, and Bikes. Below is a detailed list of these categories and their subcategories:\\n\\n### Accessories\\n- Bike Racks\\n- Bike Stands\\n- Bottles and Cages\\n- Cleaners\\n- Fenders\\n- Helmets\\n- Hydration Packs\\n- Lights\\n- Locks\\n- Panniers\\n- Pumps\\n- Tires and Tubes\\n\\n### Clothing\\n- Bib-Shorts\\n- Caps\\n- Gloves\\n- Jerseys\\n- Shorts\\n- Socks\\n- Tights\\n- Vests\\n\\n### Components\\n- Handlebars\\n- Bottom Brackets\\n- Brakes\\n- Chains\\n- Cranksets\\n- Derailleurs\\n- Forks\\n- Headsets\\n- Mountain Frames\\n- Pedals\\n- Road Frames\\n- Saddles\\n- Touring Frames\\n- Wheels\\n\\n### Bikes\\n- Mountain Bikes\\n- Road Bikes\\n- Touring Bikes\\n\", \n",
- " \"sources\": [ \n",
+ "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 9.404514s\n",
+ "INFO:root:Answer: { \n",
+ " \"answer\": \"### Product Categories and Subcategories\\n\\nThe product categories and their corresponding subcategories in our database are as follows:\\n\\n#### Accessories\\n- Bike Racks\\n- Bike Stands\\n- Bottles and Cages\\n- Cleaners\\n- Fenders\\n- Helmets\\n- Hydration Packs\\n- Lights\\n- Locks\\n- Panniers\\n- Pumps\\n- Tires and Tubes\\n\\n#### Clothing\\n- Bib-Shorts\\n- Caps\\n- Gloves\\n- Jerseys\\n- Shorts\\n- Socks\\n- Tights\\n- Vests\\n\\n#### Components\\n- Handlebars\\n- Bottom Brackets\\n- Brakes\\n- Chains\\n- Cranksets\\n- Derailleurs\\n- Forks\\n- Headsets\\n- Mountain Frames\\n- Pedals\\n- Road Frames\\n- Saddles\\n- Touring Frames\\n- Wheels\\n\\n#### Bikes\\n- Mountain Bikes\\n- Road Bikes\\n- Touring Bikes\\n\\nThese categories and subcategories help in organising and categorising our products effectively, facilitating a better understanding and management of our inventory.\",\n",
+ " \"sources\": [\n",
" {\n",
- " \"title\": \"Get All Categories\", \n",
- " \"chunk\": \"| ProductCategoryID | ParentProductCategoryName | ProductCategoryName |\\n|-------------------|----------------------------|---------------------|\\n| 30 | Accessories | Bike Racks |\\n| 31 | Accessories | Bike Stands |\\n| 32 | Accessories | Bottles and Cages |\\n| 33 | Accessories | Cleaners |\\n| 34 | Accessories | Fenders |\\n| 35 | Accessories | Helmets |\\n| 36 | Accessories | Hydration Packs |\\n| 37 | Accessories | Lights |\\n| 38 | Accessories | Locks |\\n| 39 | Accessories | Panniers |\\n| 40 | Accessories | Pumps |\\n| 41 | Accessories | Tires and Tubes |\\n| 22 | Clothing | Bib-Shorts |\\n| 23 | Clothing | Caps |\\n| 24 | Clothing | Gloves |\\n| 25 | Clothing | Jerseys |\\n| 26 | Clothing | Shorts |\\n| 27 | Clothing | Socks |\\n| 28 | Clothing | Tights |\\n| 29 | Clothing | Vests |\\n| 8 | Components | Handlebars |\\n| 9 | Components | Bottom Brackets |\\n| 10 | Components | Brakes |\\n| 11 | Components | Chains |\\n| 12 | Components | Cranksets |\\n| 13 | Components | Derailleurs |\\n| 14 | Components | Forks |\\n| 15 | Components | Headsets |\\n| 16 | Components | Mountain Frames |\\n| 17 | Components | Pedals |\\n| 18 | Components | Road Frames |\\n| 19 | Components | Saddles |\\n| 20 | Components | Touring Frames |\\n| 21 | Components | Wheels |\\n| 5 | Bikes | Mountain Bikes |\\n| 6 | Bikes | Road Bikes |\\n| 7 | Bikes | Touring Bikes |\\n\", \n",
- " \"reference\": \"SELECT ProductCategoryID, ParentProductCategoryName, ProductCategoryName FROM SalesLT.vGetAllCategories;\" \n",
- " } \n",
- " ] \n",
+ " \"title\": \"Get All Categories\",\n",
+ " \"chunk\": \"| ProductCategoryName | ParentProductCategoryName |\\n|---------------------|---------------------------|\\n| Bike Racks | Accessories |\\n| Bike Stands | Accessories |\\n| Bottles and Cages | Accessories |\\n| Cleaners | Accessories |\\n| Fenders | Accessories |\\n| Helmets | Accessories |\\n| Hydration Packs | Accessories |\\n| Lights | Accessories |\\n| Locks | Accessories |\\n| Panniers | Accessories |\\n| Pumps | Accessories |\\n| Tires and Tubes | Accessories |\\n| Bib-Shorts | Clothing |\\n| Caps | Clothing |\\n| Gloves | Clothing |\\n| Jerseys | Clothing |\\n| Shorts | Clothing |\\n| Socks | Clothing |\\n| Tights | Clothing |\\n| Vests | Clothing |\\n| Handlebars | Components |\\n| Bottom Brackets | Components |\\n| Brakes | Components |\\n| Chains | Components |\\n| Cranksets | Components |\\n| Derailleurs | Components |\\n| Forks | Components |\\n| Headsets | Components |\\n| Mountain Frames | Components |\\n| Pedals | Components |\\n| Road Frames | Components |\\n| Saddles | Components |\\n| Touring Frames | Components |\\n| Wheels | Components |\\n| Mountain Bikes | Bikes |\\n| Road Bikes | Bikes |\\n| Touring Bikes | Bikes |\\n\",\n",
+ " \"reference\": \"SELECT ProductCategoryName, ParentProductCategoryName FROM SalesLT.vGetAllCategories;\"\n",
+ " }\n",
+ " ]\n",
"}\n"
]
},
{
"data": {
"text/markdown": [
- "The product categories available in our database are organised under four main parent categories: Accessories, Clothing, Components, and Bikes. Below is a detailed list of these categories and their subcategories:\n",
+ "### Product Categories and Subcategories\n",
+ "\n",
+ "The product categories and their corresponding subcategories in our database are as follows:\n",
"\n",
- "### Accessories\n",
+ "#### Accessories\n",
"- Bike Racks\n",
"- Bike Stands\n",
"- Bottles and Cages\n",
@@ -466,7 +463,7 @@
"- Pumps\n",
"- Tires and Tubes\n",
"\n",
- "### Clothing\n",
+ "#### Clothing\n",
"- Bib-Shorts\n",
"- Caps\n",
"- Gloves\n",
@@ -476,7 +473,7 @@
"- Tights\n",
"- Vests\n",
"\n",
- "### Components\n",
+ "#### Components\n",
"- Handlebars\n",
"- Bottom Brackets\n",
"- Brakes\n",
@@ -492,10 +489,12 @@
"- Touring Frames\n",
"- Wheels\n",
"\n",
- "### Bikes\n",
+ "#### Bikes\n",
"- Mountain Bikes\n",
"- Road Bikes\n",
- "- Touring Bikes\n"
+ "- Touring Bikes\n",
+ "\n",
+ "These categories and subcategories help in organising and categorising our products effectively, facilitating a better understanding and management of our inventory."
],
"text/plain": [
""
@@ -530,7 +529,7 @@
"\n",
"The response to the user must meet the requirements in RESPONSE OUTPUT REQUIREMENTS.\n",
"IMPORTANT INFORMATION contains useful information that you can use to aid your knowledge.\n",
- "CONVERSATION HISTORY contains the previous question and answer pairs in the conversation in JSON format. Do not use this information to answer the question, but to provide context on what was asked previously.\n",
+ "CHAT HISTORY contains the previous question and answer pairs in the conversation in JSON format. Do not use this information to answer the question, but to provide context on what was asked previously.\n",
"\n",
"[IMPORTANT INFORMATION]\n",
"\n",
@@ -612,7 +611,7 @@
"\n",
" 3. Information Sources:\n",
" Use only information from the provided functions and specified important information.\n",
- " Do not use any external sources or the conversation history for constructing the response.\n",
+ " Do not use any external sources or the chat history for constructing the response.\n",
" In case of conflicting information, prioritize data from the SQL Database as the primary source of truth.\n",
"\n",
" 4. Calculations:\n",
@@ -656,52 +655,47 @@
" [END SOURCES PROPERTY REQUIREMENTS]\n",
"\n",
"[END RESPONSE OUTPUT REQUIREMENTS]\n",
- "\n",
- "[CONVERSATION HISTORY]\n",
- "\n",
- " What are the different product categories we have?\n",
- "\n",
- "[END CONVERSATION HISTORY]\n",
"\n",
+ "What are the different product categories we have?\n",
"What is the top performing product by quantity of units sold? as xml, treating as text, error was: not well-formed (invalid token): line 75, column 78\n",
"INFO:httpx:HTTP Request: POST https://open-ai-gpt-001.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-01 \"HTTP/1.1 200 OK\"\n",
- "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=57, prompt_tokens=2653, total_tokens=2710)\n",
+ "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=57, prompt_tokens=2637, total_tokens=2694)\n",
"INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_chat_completion_base:processing 2 tool calls in parallel.\n",
"INFO:semantic_kernel.kernel:Calling SQL-GetEntitySchema function with args: {\"entity_name\": \"SALES ORDER DETAIL\"}\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-GetEntitySchema invoking.\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-GetEntitySchema succeeded.\n",
- "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.001386s\n",
+ "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.001175s\n",
"INFO:semantic_kernel.kernel:Calling SQL-GetEntitySchema function with args: {\"entity_name\": \"PRODUCT AND DESCRIPTION\"}\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-GetEntitySchema invoking.\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-GetEntitySchema succeeded.\n",
- "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.000964s\n",
+ "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.002015s\n",
"INFO:httpx:HTTP Request: POST https://open-ai-gpt-001.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-01 \"HTTP/1.1 200 OK\"\n",
- "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=50, prompt_tokens=3507, total_tokens=3557)\n",
+ "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=48, prompt_tokens=3491, total_tokens=3539)\n",
"INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_chat_completion_base:processing 1 tool calls in parallel.\n",
- "INFO:semantic_kernel.kernel:Calling SQL-RunSQLQuery function with args: {\"sql_query\":\"SELECT TOP 1 ProductID, SUM(OrderQty) AS TotalUnitsSold FROM SalesLT.SalesOrderDetail GROUP BY ProductID ORDER BY TotalUnitsSold DESC;\"}\n",
+ "INFO:semantic_kernel.kernel:Calling SQL-RunSQLQuery function with args: {\"sql_query\":\"SELECT TOP 1 ProductID, SUM(OrderQty) AS TotalQuantity FROM SalesLT.SalesOrderDetail GROUP BY ProductID ORDER BY TotalQuantity DESC;\"}\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-RunSQLQuery invoking.\n",
"INFO:root:Executing SQL Query\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-RunSQLQuery succeeded.\n",
- "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.261263s\n",
+ "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.568917s\n",
"INFO:httpx:HTTP Request: POST https://open-ai-gpt-001.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-01 \"HTTP/1.1 200 OK\"\n",
- "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=36, prompt_tokens=3584, total_tokens=3620)\n",
+ "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=33, prompt_tokens=3565, total_tokens=3598)\n",
"INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_chat_completion_base:processing 1 tool calls in parallel.\n",
- "INFO:semantic_kernel.kernel:Calling SQL-RunSQLQuery function with args: {\"sql_query\":\"SELECT Name, ProductModel FROM SalesLT.vProductAndDescription WHERE ProductID = 864;\"}\n",
+ "INFO:semantic_kernel.kernel:Calling SQL-RunSQLQuery function with args: {\"sql_query\":\"SELECT Name FROM SalesLT.vProductAndDescription WHERE ProductID = 864;\"}\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-RunSQLQuery invoking.\n",
"INFO:root:Executing SQL Query\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-RunSQLQuery succeeded.\n",
- "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 1.947046s\n",
+ "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.882085s\n",
"INFO:httpx:HTTP Request: POST https://open-ai-gpt-001.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-01 \"HTTP/1.1 200 OK\"\n",
- "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=191, prompt_tokens=3735, total_tokens=3926)\n",
+ "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=166, prompt_tokens=3665, total_tokens=3831)\n",
"INFO:semantic_kernel.functions.kernel_function:Function ChatBot-Chat succeeded.\n",
- "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 6.849564s\n",
- "INFO:root:Answer: { \"answer\": \"The top-performing product by quantity of units sold is the **Classic Vest, S** from the **Classic Vest** product model, with a total of 87 units sold [1][2].\", \"sources\": [ { \"title\": \"Sales Order Detail\", \"chunk\": \"| ProductID | TotalUnitsSold |\\n|-----------|----------------|\\n| 864 | 87 |\\n\", \"reference\": \"SELECT TOP 1 ProductID, SUM(OrderQty) AS TotalUnitsSold FROM SalesLT.SalesOrderDetail GROUP BY ProductID ORDER BY TotalUnitsSold DESC;\" }, { \"title\": \"Product and Description\", \"chunk\": \"| Name | ProductModel |\\n|----------------|---------------|\\n| Classic Vest, S| Classic Vest |\\n\", \"reference\": \"SELECT Name, ProductModel FROM SalesLT.vProductAndDescription WHERE ProductID = 864;\" } ] }\n"
+ "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 6.536541s\n",
+ "INFO:root:Answer: { \"answer\": \"The top performing product by quantity of units sold is the **Classic Vest, S**, with a total of 87 units sold [1][2].\", \"sources\": [ { \"title\": \"Sales Order Detail\", \"chunk\": \"| ProductID | TotalQuantity |\\n|-----------|---------------|\\n| 864 | 87 |\\n\", \"reference\": \"SELECT TOP 1 ProductID, SUM(OrderQty) AS TotalQuantity FROM SalesLT.SalesOrderDetail GROUP BY ProductID ORDER BY TotalQuantity DESC;\" }, { \"title\": \"Product and Description\", \"chunk\": \"| Name |\\n|---------------|\\n| Classic Vest, S |\\n\", \"reference\": \"SELECT Name FROM SalesLT.vProductAndDescription WHERE ProductID = 864;\" } ] }\n"
]
},
{
"data": {
"text/markdown": [
- "The top-performing product by quantity of units sold is the **Classic Vest, S** from the **Classic Vest** product model, with a total of 87 units sold [1][2]."
+ "The top performing product by quantity of units sold is the **Classic Vest, S**, with a total of 87 units sold [1][2]."
],
"text/plain": [
""
@@ -736,7 +730,7 @@
"\n",
"The response to the user must meet the requirements in RESPONSE OUTPUT REQUIREMENTS.\n",
"IMPORTANT INFORMATION contains useful information that you can use to aid your knowledge.\n",
- "CONVERSATION HISTORY contains the previous question and answer pairs in the conversation in JSON format. Do not use this information to answer the question, but to provide context on what was asked previously.\n",
+ "CHAT HISTORY contains the previous question and answer pairs in the conversation in JSON format. Do not use this information to answer the question, but to provide context on what was asked previously.\n",
"\n",
"[IMPORTANT INFORMATION]\n",
"\n",
@@ -818,7 +812,7 @@
"\n",
" 3. Information Sources:\n",
" Use only information from the provided functions and specified important information.\n",
- " Do not use any external sources or the conversation history for constructing the response.\n",
+ " Do not use any external sources or the chat history for constructing the response.\n",
" In case of conflicting information, prioritize data from the SQL Database as the primary source of truth.\n",
"\n",
" 4. Calculations:\n",
@@ -862,54 +856,39 @@
" [END SOURCES PROPERTY REQUIREMENTS]\n",
"\n",
"[END RESPONSE OUTPUT REQUIREMENTS]\n",
- "\n",
- "[CONVERSATION HISTORY]\n",
- "\n",
- " What are the different product categories we have?What is the top performing product by quantity of units sold?\n",
- "\n",
- "[END CONVERSATION HISTORY]\n",
"\n",
+ "What are the different product categories we have?What is the top performing product by quantity of units sold?\n",
"Which country did we sell the most to in June 2008? as xml, treating as text, error was: not well-formed (invalid token): line 75, column 78\n",
"INFO:httpx:HTTP Request: POST https://open-ai-gpt-001.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-01 \"HTTP/1.1 200 OK\"\n",
- "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=55, prompt_tokens=2684, total_tokens=2739)\n",
+ "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=55, prompt_tokens=2668, total_tokens=2723)\n",
"INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_chat_completion_base:processing 2 tool calls in parallel.\n",
"INFO:semantic_kernel.kernel:Calling SQL-GetEntitySchema function with args: {\"entity_name\": \"SALES ORDER HEADER\"}\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-GetEntitySchema invoking.\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-GetEntitySchema succeeded.\n",
- "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.001063s\n",
+ "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.000949s\n",
"INFO:semantic_kernel.kernel:Calling SQL-GetEntitySchema function with args: {\"entity_name\": \"ADDRESS\"}\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-GetEntitySchema invoking.\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-GetEntitySchema succeeded.\n",
- "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.000960s\n",
+ "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.000836s\n",
"INFO:httpx:HTTP Request: POST https://open-ai-gpt-001.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-01 \"HTTP/1.1 200 OK\"\n",
- "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=108, prompt_tokens=4086, total_tokens=4194)\n",
+ "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=89, prompt_tokens=4070, total_tokens=4159)\n",
"INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_chat_completion_base:processing 1 tool calls in parallel.\n",
- "INFO:semantic_kernel.kernel:Calling SQL-RunSQLQuery function with args: {\"sql_query\":\"SELECT a.CountryRegion, SUM(sod.OrderQty) AS TotalQuantity FROM SalesLT.SalesOrderHeader soh JOIN SalesLT.SalesOrderDetail sod ON soh.SalesOrderID = sod.SalesOrderID JOIN SalesLT.Address a ON soh.ShipToAddressID = a.AddressID WHERE soh.OrderDate BETWEEN '2008-06-01' AND '2008-06-30' GROUP BY a.CountryRegion ORDER BY TotalQuantity DESC;\"}\n",
+ "INFO:semantic_kernel.kernel:Calling SQL-RunSQLQuery function with args: {\"sql_query\":\"SELECT a.CountryRegion, SUM(soh.TotalDue) as TotalSales FROM SalesLT.SalesOrderHeader soh JOIN SalesLT.Address a ON soh.ShipToAddressID = a.AddressID WHERE soh.OrderDate BETWEEN '2008-06-01' AND '2008-06-30' GROUP BY a.CountryRegion ORDER BY TotalSales DESC;\"}\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-RunSQLQuery invoking.\n",
"INFO:root:Executing SQL Query\n",
"INFO:semantic_kernel.functions.kernel_function:Function SQL-RunSQLQuery succeeded.\n",
- "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.248642s\n",
+ "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 0.708600s\n",
"INFO:httpx:HTTP Request: POST https://open-ai-gpt-001.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-01 \"HTTP/1.1 200 OK\"\n",
- "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=205, prompt_tokens=4237, total_tokens=4442)\n",
+ "INFO:semantic_kernel.connectors.ai.open_ai.services.open_ai_handler:OpenAI usage: CompletionUsage(completion_tokens=178, prompt_tokens=4210, total_tokens=4388)\n",
"INFO:semantic_kernel.functions.kernel_function:Function ChatBot-Chat succeeded.\n",
- "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 5.787196s\n",
- "INFO:root:Answer: \n",
- "{ \n",
- " \"answer\": \"In June 2008, the country to which we sold the most was the United Kingdom, with a total of 1,172 units sold [1].\", \n",
- " \"sources\": [ \n",
- " {\n",
- " \"title\": \"Sales Order Header\", \n",
- " \"chunk\": \"| CountryRegion | TotalQuantity |\\n|----------------|---------------|\\n| United Kingdom | 1172 |\\n| United States | 915 |\\n\", \n",
- " \"reference\": \"SELECT a.CountryRegion, SUM(sod.OrderQty) AS TotalQuantity FROM SalesLT.SalesOrderHeader soh JOIN SalesLT.SalesOrderDetail sod ON soh.SalesOrderID = sod.SalesOrderID JOIN SalesLT.Address a ON soh.ShipToAddressID = a.AddressID WHERE soh.OrderDate BETWEEN '2008-06-01' AND '2008-06-30' GROUP BY a.CountryRegion ORDER BY TotalQuantity DESC;\"\n",
- " } \n",
- " ] \n",
- "}\n"
+ "INFO:semantic_kernel.functions.kernel_function:Function completed. Duration: 5.218919s\n",
+ "INFO:root:Answer: { \"answer\": \"The country with the highest sales in June 2008 was the United Kingdom, with a total sales amount of \u00a3572,496.56 [1].\", \"sources\": [ {\"title\": \"Sales Order Header\", \"chunk\": \"| CountryRegion | TotalSales |\\n|-------------------|--------------|\\n| United Kingdom | 572496.5594 |\\n| United States | 383807.0355 |\\n\", \"reference\": \"SELECT a.CountryRegion, SUM(soh.TotalDue) as TotalSales FROM SalesLT.SalesOrderHeader soh JOIN SalesLT.Address a ON soh.ShipToAddressID = a.AddressID WHERE soh.OrderDate BETWEEN '2008-06-01' AND '2008-06-30' GROUP BY a.CountryRegion ORDER BY TotalSales DESC;\" } ] }\n"
]
},
{
"data": {
"text/markdown": [
- "In June 2008, the country to which we sold the most was the United Kingdom, with a total of 1,172 units sold [1]."
+ "The country with the highest sales in June 2008 was the United Kingdom, with a total sales amount of \u00a3572,496.56 [1]."
],
"text/plain": [
""
@@ -950,7 +929,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.11.9"
+ "version": "3.12.3"
},
"microsoft": {
"host": {