matthewfarant commited on
Commit
f4bb96c
·
verified ·
1 Parent(s): e7334fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -22
app.py CHANGED
@@ -40,22 +40,15 @@ firecrawl_app = FirecrawlApp(api_key=os.getenv('FIRECRAWL_KEY'))
40
  # Keyword Generation
41
  query_prompt = PromptTemplate(
42
  template="""
43
-
44
  <|begin_of_text|>
45
-
46
  <|start_header_id|>system<|end_header_id|>
47
-
48
  You are an expert at crafting web search queries for fact checking.
49
  More often than not, a user will provide an information that they wish to fact check, however it might not be in the best format.
50
  Reword their query to be the most effective web search string possible.
51
  Return the JSON with a single key 'query' with no premable or explanation.
52
-
53
  Information to transform: {question}
54
-
55
  <|eot_id|>
56
-
57
  <|start_header_id|>assistant<|end_header_id|>
58
-
59
  """,
60
  input_variables=["question"],
61
  )
@@ -75,20 +68,13 @@ def search_and_scrape(keyword):
75
  # Summarizer
76
  summarize_prompt = PromptTemplate(
77
  template="""
78
-
79
  <|begin_of_text|>
80
-
81
  <|start_header_id|>system<|end_header_id|>
82
-
83
  You are an expert at summarizing web crawling results. The user will give you multiple web search result with different topics. Your task is to summarize all the important information
84
  from the article in a readable paragraph. It is okay if one paragraph contains multiple topics.
85
-
86
  Information to transform: {question}
87
-
88
  <|eot_id|>
89
-
90
  <|start_header_id|>assistant<|end_header_id|>
91
-
92
  """,
93
  input_variables=["question"],
94
  )
@@ -98,11 +84,8 @@ summarize_chain = summarize_prompt | llama3 | StrOutputParser()
98
  # Fact Checker
99
  generate_prompt = PromptTemplate(
100
  template="""
101
-
102
  <|begin_of_text|>
103
-
104
  <|start_header_id|>system<|end_header_id|>
105
-
106
  You are a fact-checker AI assistant that receives an information from the user, synthesizes web search results for that information, and verify whether the user's information is a fact or possibly a hoax.
107
  Strictly use the following pieces of web search context to answer the question. If you don't know the answer, just give "Possibly Hoax" verdict. Only make direct references to material if provided in the context.
108
  Return a JSON output with these keys, with no premable:
@@ -110,17 +93,12 @@ generate_prompt = PromptTemplate(
110
  2. system_verdict: is the user question above a fact? choose only between "Fact" or "Possibly Hoax"
111
  3. explanation: a short explanation on why the verdict was chosen
112
  If the context does not relate with the information provided by user, you can give "Possibly Hoax" result and tell the user that based on web search, it seems that the provided information is a false information.
113
-
114
  <|eot_id|>
115
-
116
  <|start_header_id|>user<|end_header_id|>
117
-
118
  User Information: {question}
119
  Web Search Context: {context}
120
  JSON Verdict and Explanation:
121
-
122
  <|eot_id|>
123
-
124
  <|start_header_id|>assistant<|end_header_id|>
125
  """,
126
  input_variables=["question", "context"],
 
40
  # Keyword Generation
41
  query_prompt = PromptTemplate(
42
  template="""
 
43
  <|begin_of_text|>
 
44
  <|start_header_id|>system<|end_header_id|>
 
45
  You are an expert at crafting web search queries for fact checking.
46
  More often than not, a user will provide an information that they wish to fact check, however it might not be in the best format.
47
  Reword their query to be the most effective web search string possible.
48
  Return the JSON with a single key 'query' with no premable or explanation.
 
49
  Information to transform: {question}
 
50
  <|eot_id|>
 
51
  <|start_header_id|>assistant<|end_header_id|>
 
52
  """,
53
  input_variables=["question"],
54
  )
 
68
  # Summarizer
69
  summarize_prompt = PromptTemplate(
70
  template="""
 
71
  <|begin_of_text|>
 
72
  <|start_header_id|>system<|end_header_id|>
 
73
  You are an expert at summarizing web crawling results. The user will give you multiple web search result with different topics. Your task is to summarize all the important information
74
  from the article in a readable paragraph. It is okay if one paragraph contains multiple topics.
 
75
  Information to transform: {question}
 
76
  <|eot_id|>
 
77
  <|start_header_id|>assistant<|end_header_id|>
 
78
  """,
79
  input_variables=["question"],
80
  )
 
84
  # Fact Checker
85
  generate_prompt = PromptTemplate(
86
  template="""
 
87
  <|begin_of_text|>
 
88
  <|start_header_id|>system<|end_header_id|>
 
89
  You are a fact-checker AI assistant that receives an information from the user, synthesizes web search results for that information, and verify whether the user's information is a fact or possibly a hoax.
90
  Strictly use the following pieces of web search context to answer the question. If you don't know the answer, just give "Possibly Hoax" verdict. Only make direct references to material if provided in the context.
91
  Return a JSON output with these keys, with no premable:
 
93
  2. system_verdict: is the user question above a fact? choose only between "Fact" or "Possibly Hoax"
94
  3. explanation: a short explanation on why the verdict was chosen
95
  If the context does not relate with the information provided by user, you can give "Possibly Hoax" result and tell the user that based on web search, it seems that the provided information is a false information.
 
96
  <|eot_id|>
 
97
  <|start_header_id|>user<|end_header_id|>
 
98
  User Information: {question}
99
  Web Search Context: {context}
100
  JSON Verdict and Explanation:
 
101
  <|eot_id|>
 
102
  <|start_header_id|>assistant<|end_header_id|>
103
  """,
104
  input_variables=["question", "context"],