Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -47,9 +47,10 @@ def retrieve_thoughts(query, ):
|
|
47 |
df = pd.concat((df, pd.DataFrame([doc[1] for doc in docs_with_score], columns = ['score'])), axis = 1)
|
48 |
|
49 |
# TO-DO: What if user query doesn't match what we provide as documents
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
53 |
|
54 |
tier_1
|
55 |
chunks_1 = tier_1.groupby(['title', 'url', ]).apply(lambda x: "\n...\n".join(x.sort_values('id')['page_content'].values[:min(4, len(x.sort_values('id')['page_content'].values))])).values
|
@@ -64,7 +65,7 @@ def retrieve_thoughts(query, ):
|
|
64 |
# tier_1 = [doc[0] for doc in docs if ((doc[1] < 1))][:5]
|
65 |
# tier_2 = [doc[0] for doc in docs if ((doc[1] > 0.7)*(doc[1] < 1.5))][10:15]
|
66 |
|
67 |
-
return {'tier 1':tier_1_adjusted
|
68 |
|
69 |
def get_references(query):
|
70 |
# TO-DO FINSIH UPP.
|
|
|
47 |
df = pd.concat((df, pd.DataFrame([doc[1] for doc in docs_with_score], columns = ['score'])), axis = 1)
|
48 |
|
49 |
# TO-DO: What if user query doesn't match what we provide as documents
|
50 |
+
df.sort_values("score", inplace = True)
|
51 |
+
|
52 |
+
tier_1 = df[df['score'] < 0.85].iloc[:30]
|
53 |
+
tier_2 = df[((df['score'] < 1) * (df["score"] > 0.8))]
|
54 |
|
55 |
tier_1
|
56 |
chunks_1 = tier_1.groupby(['title', 'url', ]).apply(lambda x: "\n...\n".join(x.sort_values('id')['page_content'].values[:min(4, len(x.sort_values('id')['page_content'].values))])).values
|
|
|
65 |
# tier_1 = [doc[0] for doc in docs if ((doc[1] < 1))][:5]
|
66 |
# tier_2 = [doc[0] for doc in docs if ((doc[1] > 0.7)*(doc[1] < 1.5))][10:15]
|
67 |
|
68 |
+
return {'tier 1':tier_1_adjusted, 'tier 2': tier_2_adjusted.loc[:5]}
|
69 |
|
70 |
def get_references(query):
|
71 |
# TO-DO FINSIH UPP.
|