Rams901 commited on
Commit
62d92d6
1 Parent(s): 6036c00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -56,7 +56,7 @@ def retrieve_thoughts(query, ):
56
  chunks_1 = tier_1.groupby(['title', 'url', ]).apply(lambda x: "\n...\n".join(x.sort_values('score').iloc[:3].sort_values('id')['page_content'].values)).values
57
  score = tier_1.groupby(['title', 'url', ]).apply(lambda x: x.sort_values('score').iloc[:3]['score'].mean()).values
58
 
59
- tier_1_adjusted = tier_1.groupby(['title', 'url', ]).first().reset_index()[[ 'title', 'url']]
60
  tier_1_adjusted['content'] = chunks_1
61
  tier_1_adjusted['score'] = score
62
 
@@ -77,7 +77,7 @@ def get_references(query):
77
  thoughts = retrieve_thoughts(query)
78
  print(thoughts.keys())
79
  tier_1 = thoughts['tier 1']
80
- reference = tier_1[['ref', 'url', 'title']].to_dict('records')
81
  return reference
82
  def qa_themes(query,):
83
 
@@ -98,9 +98,9 @@ def qa_themes(query,):
98
  tier_1 = thoughts['tier 1']
99
  tier_2 = thoughts['tier 2']
100
 
101
- reference = tier_1[['ref', 'url', 'title']].to_dict('records')
102
 
103
- tier_1 = list(tier_1.apply(lambda x: f"[{int(x['ref'])}] title: {x['title']}\n Content: {x.content}", axis = 1).values)
104
  tier_2 = list(tier_2.apply(lambda x: f"title: {x['title']}\n Content: {x.content}", axis = 1).values)
105
  print(f"QUERY: {query}\nTIER 1: {tier_1}\nTIER2: {tier_2}")
106
 
@@ -164,7 +164,7 @@ def qa_retrieve(query,):
164
 
165
  reference = tier_1[['ref', 'url', 'title']].to_dict('records')
166
 
167
- tier_1 = list(tier_1.apply(lambda x: f"[{int(x['ref'])}] title: {x['title']}\n Content: {x.content}", axis = 1).values)
168
  tier_2 = list(tier_2.apply(lambda x: f"title: {x['title']}\n Content: {x.content}", axis = 1).values)
169
  print(f"QUERY: {query}\nTIER 1: {tier_1}\nTIER2: {tier_2}")
170
 
@@ -226,7 +226,7 @@ def qa_intro(query, cynthesis, tier_1,):
226
 
227
  llm = ClaudeLLM()
228
  llm_4 = ChatOpenAI(
229
- temperature=0,
230
  model='gpt-3.5-turbo-16k'
231
  )
232
 
@@ -235,7 +235,7 @@ def qa_intro(query, cynthesis, tier_1,):
235
  prompt = PromptTemplate(
236
  input_variables=["query", "cynthesis", "articles"],
237
  template="""
238
- Give me an introduction to the following consensus without repeating how it starts. Consider this an abstract. And after finishing the introduction, pick one quote from the sources given below.
239
 
240
  query: {query}
241
  Here's the consensus: {cynthesis}
 
56
  chunks_1 = tier_1.groupby(['title', 'url', ]).apply(lambda x: "\n...\n".join(x.sort_values('score').iloc[:3].sort_values('id')['page_content'].values)).values
57
  score = tier_1.groupby(['title', 'url', ]).apply(lambda x: x.sort_values('score').iloc[:3]['score'].mean()).values
58
 
59
+ tier_1_adjusted = tier_1.groupby(['title', 'url', ]).first().reset_index()[[ 'title', 'url', 'author']]
60
  tier_1_adjusted['content'] = chunks_1
61
  tier_1_adjusted['score'] = score
62
 
 
77
  thoughts = retrieve_thoughts(query)
78
  print(thoughts.keys())
79
  tier_1 = thoughts['tier 1']
80
+ reference = tier_1[['ref', 'url', 'title', 'author']].to_dict('records')
81
  return reference
82
  def qa_themes(query,):
83
 
 
98
  tier_1 = thoughts['tier 1']
99
  tier_2 = thoughts['tier 2']
100
 
101
+ reference = tier_1[['ref', 'url', 'title', 'author']].to_dict('records')
102
 
103
+ tier_1 = list(tier_1.apply(lambda x: f"[{int(x['ref'])}] title: {x['title']}\n author: {x.author}\n content: {x.content}", axis = 1).values)
104
  tier_2 = list(tier_2.apply(lambda x: f"title: {x['title']}\n Content: {x.content}", axis = 1).values)
105
  print(f"QUERY: {query}\nTIER 1: {tier_1}\nTIER2: {tier_2}")
106
 
 
164
 
165
  reference = tier_1[['ref', 'url', 'title']].to_dict('records')
166
 
167
+ tier_1 = list(tier_1.apply(lambda x: f"[{int(x['ref'])}] title: {x['title']}\n author: {x.author}\n content: {x.content}", axis = 1).values)
168
  tier_2 = list(tier_2.apply(lambda x: f"title: {x['title']}\n Content: {x.content}", axis = 1).values)
169
  print(f"QUERY: {query}\nTIER 1: {tier_1}\nTIER2: {tier_2}")
170
 
 
226
 
227
  llm = ClaudeLLM()
228
  llm_4 = ChatOpenAI(
229
+ temperature=0.5,
230
  model='gpt-3.5-turbo-16k'
231
  )
232
 
 
235
  prompt = PromptTemplate(
236
  input_variables=["query", "cynthesis", "articles"],
237
  template="""
238
+ Give me an introduction to the following consensus without repeating how it starts. Consider what you will write an abstract. And after finishing the introduction, pick one quote from the sources given below.
239
 
240
  query: {query}
241
  Here's the consensus: {cynthesis}