Created
May 8, 2024 13:53
-
-
Save rohit-lakhanpal/4bc5784b7878c31962a20b725a7919ee to your computer and use it in GitHub Desktop.
eval_data_transformation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from promptflow import tool | |
def transform_data(data: list, question: str, answer: str) -> list: | |
transformed = [ | |
{ | |
"role": "user", | |
"content": question | |
}, | |
{ | |
"role": "assistant", | |
"content": answer, | |
"context": { | |
"citations": [ | |
{ | |
"id": item["metadata"]["chunk_id"], | |
"title": item["metadata"]["title"], | |
"content": item["text"] | |
} | |
for item in data | |
] | |
} | |
} | |
] | |
return transformed | |
@tool | |
def my_python_tool(source_data: list, question: str, answer: str) -> list: | |
return transform_data(source_data, question, answer) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment