File size: 889 Bytes
f154798
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from langchain.prompts import PromptTemplate
from langchain_core.output_parsers import JsonOutputParser
from helper.configure_llm import LLM

import sys
sys.dont_write_bytecode = True

llm = LLM

QUERY_PROMPT = PromptTemplate(
    template = """

    <|begin_of_text|>

    <|start_header_id|>system<|end_header_id|>

    You are a expert at crafting web search queries for research questions.
    More often that not, a user will ask a basic question that they wish to learn more about; however, it might not be in the best format.
    Reword their query to be the most effective web search string possible.
    Return the JSON with a single key 'query' with no premable or explanation.

    Question to transform: {question}

    <|eot_id|>

    <|start_header_id|>user<|end_header_id|>

    """,
    input_variables=["question"],
)

QUERY_CHAIN = QUERY_PROMPT | llm | JsonOutputParser()