Spaces:
Sleeping
Sleeping
File size: 1,425 Bytes
83a18c0 0cfb154 83a18c0 0cfb154 83a18c0 0cfb154 83a18c0 0cfb154 83a18c0 0cfb154 83a18c0 0cfb154 83a18c0 0cfb154 83a18c0 0cfb154 83a18c0 0cfb154 83a18c0 0cfb154 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | from typing import TypedDict, AnyStr
from .prompt import highlight_explain_chain, highlight_explain_question_generate_chain
async def highlight_explain(
domain,
question,
highlight_terms,
before_highlight_paragraph,
after_highlight_paragraph,
language,
):
adjacent_paragraphs = (
before_highlight_paragraph
+ "**"
+ highlight_terms
+ "**"
+ after_highlight_paragraph
)
response = await highlight_explain_chain.ainvoke(
{
"domain": domain,
"highlight_terms": highlight_terms,
"adjacent_paragraphs": adjacent_paragraphs,
"question": question,
"language": language,
}
)
return response.explanation
async def highlight_explain_question_generate(
domain,
question,
highlight_terms,
before_highlight_paragraph,
after_highlight_paragraph,
language,
):
adjacent_paragraphs = (
before_highlight_paragraph
+ "**"
+ highlight_terms
+ "**"
+ after_highlight_paragraph
)
response = await highlight_explain_question_generate_chain.ainvoke(
{
"domain": domain,
"highlight_terms": highlight_terms,
"adjacent_paragraphs": adjacent_paragraphs,
"question": question,
"language": language,
}
)
return response.questions
|