Skip to content

Commit

Permalink
switch flows to using Index Lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
Adarsh-Ramanathan committed Feb 2, 2024
1 parent 9b2e768 commit dbdcb9d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import uuid

import requests
import textwrap
import traceback
import time
from pathlib import Path
Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit dbdcb9d

Please sign in to comment.