diff --git a/assets/large_language_models/rag/components/src/flow_creation.py b/assets/large_language_models/rag/components/src/flow_creation.py index a911c6c790..4c8b86d0b9 100644 --- a/assets/large_language_models/rag/components/src/flow_creation.py +++ b/assets/large_language_models/rag/components/src/flow_creation.py @@ -8,6 +8,7 @@ import uuid import requests +import textwrap import traceback import time from pathlib import Path @@ -280,6 +281,9 @@ def main(args, ws, current_run, activity_logger: Logger): print(mlindex_asset_id) print(top_prompts) + with open(mlindex_asset_id, "r") as f: + mlindex_content = f.read() + if isinstance(top_prompts, str): top_prompts = [top_prompts, top_prompts, top_prompts] @@ -311,6 +315,8 @@ def main(args, ws, current_run, activity_logger: Logger): "@@Completion_Provider", completion_provider) flow_with_variants = flow_with_variants.replace( "@@MLIndex_Asset_Id", mlindex_asset_id) + flow_with_variants = flow_with_variants.replace( + "@@MLIndex_Content", textwrap.indent(mlindex_content, ' ')) api_name = "chat" if completion_model_name.startswith("gpt-") else "completion" flow_with_variants = flow_with_variants.replace("@@API", api_name) diff --git a/assets/large_language_models/rag/components/src/flow_yamls/chat_flow.dag.yaml b/assets/large_language_models/rag/components/src/flow_yamls/chat_flow.dag.yaml index 72cccf538f..26364d6360 100644 --- a/assets/large_language_models/rag/components/src/flow_yamls/chat_flow.dag.yaml +++ b/assets/large_language_models/rag/components/src/flow_yamls/chat_flow.dag.yaml @@ -34,33 +34,24 @@ nodes: api: @@API module: promptflow.tools.aoai use_variants: false -- name: embed_the_question +- name: lookup_question_from_indexed_docs type: python source: type: package - tool: promptflow.tools.embedding.embedding + tool: promptflow_vectordb.tool.common_index_lookup.search inputs: - connection: @@Embedding_Connection - deployment_name: @@Embedding_Deployment_Name - input: ${modify_query_with_history.output} - aggregation: false -- name: search_question_from_indexed_docs - type: python - source: - type: package - tool: promptflow_vectordb.tool.vector_index_lookup.VectorIndexLookup.search - inputs: - path: @@MLIndex_Asset_Id - query: ${embed_the_question.output} + mlindex_content: > +@@MLIndex_Content + queries: ${modify_query_with_history.output} + query_type: Vector top_k: 2 - aggregation: false - name: generate_prompt_context type: python source: type: code path: generate_prompt_context.py inputs: - search_result: ${search_question_from_indexed_docs.output} + search_result: ${lookup_question_from_indexed_docs.output} aggregation: false - name: Prompt_variants use_variants: true diff --git a/assets/large_language_models/rag/components/src/flow_yamls/flow.dag.yaml b/assets/large_language_models/rag/components/src/flow_yamls/flow.dag.yaml index 3d8c7606b9..a857f4db7a 100644 --- a/assets/large_language_models/rag/components/src/flow_yamls/flow.dag.yaml +++ b/assets/large_language_models/rag/components/src/flow_yamls/flow.dag.yaml @@ -8,33 +8,24 @@ outputs: reference: ${answer_the_question_with_context.output} evaluation_only: false nodes: -- name: embed_the_question +- name: lookup_question_from_indexed_docs type: python source: type: package - tool: promptflow.tools.embedding.embedding + tool: promptflow_vectordb.tool.common_index_lookup.search inputs: - connection: @@Embedding_Connection - deployment_name: @@Embedding_Deployment_Name - input: ${flow.question} - aggregation: false -- name: search_question_from_indexed_docs - type: python - source: - type: package - tool: promptflow_vectordb.tool.vector_index_lookup.VectorIndexLookup.search - inputs: - path: @@MLIndex_Asset_Id - query: ${embed_the_question.output} + mlindex_content: > +@@MLIndex_Content + queries: ${flow.question} + query_type: Vector top_k: 2 - aggregation: false - name: generate_prompt_context type: python source: type: code path: generate_prompt_context.py inputs: - search_result: ${search_question_from_indexed_docs.output} + search_result: ${lookup_question_from_indexed_docs.output} aggregation: false - name: Prompt_variants use_variants: true