Spaces:
Runtime error
Runtime error
safer args + better doc strings
Browse files
app.py
CHANGED
@@ -43,7 +43,14 @@ def chat(
|
|
43 |
Yields:
|
44 |
tuple: chat gradio format, chat openai format, sources used.
|
45 |
"""
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
docs = retriever.retrieve(query=query, top_k=10)
|
48 |
|
49 |
messages = history + [{"role": "user", "content": query}]
|
|
|
43 |
Yields:
|
44 |
tuple: chat gradio format, chat openai format, sources used.
|
45 |
"""
|
46 |
+
|
47 |
+
if report_type == "All available":
|
48 |
+
retriever = retrieve_all
|
49 |
+
elif report_type == "IPCC only":
|
50 |
+
retriever = retrieve_giec
|
51 |
+
else:
|
52 |
+
raise Exception("report_type arg should be in (All available, IPCC only)")
|
53 |
+
|
54 |
docs = retriever.retrieve(query=query, top_k=10)
|
55 |
|
56 |
messages = history + [{"role": "user", "content": query}]
|
utils.py
CHANGED
@@ -9,11 +9,11 @@ def is_climate_change_related(sentence: str, classifier) -> bool:
|
|
9 |
"""_summary_
|
10 |
|
11 |
Args:
|
12 |
-
sentence (str):
|
13 |
-
classifier (_type_):
|
14 |
|
15 |
Returns:
|
16 |
-
bool:
|
17 |
"""
|
18 |
results = classifier(
|
19 |
sequences=sentence,
|
@@ -26,9 +26,9 @@ def is_climate_change_related(sentence: str, classifier) -> bool:
|
|
26 |
def make_pairs(lst):
|
27 |
"""From a list of even lenght, make tupple pairs
|
28 |
Args:
|
29 |
-
lst (list):
|
30 |
Returns:
|
31 |
-
list:
|
32 |
"""
|
33 |
return [(lst[i], lst[i + 1]) for i in range(0, len(lst), 2)]
|
34 |
|
|
|
9 |
"""_summary_
|
10 |
|
11 |
Args:
|
12 |
+
sentence (str): your sentence to classify
|
13 |
+
classifier (_type_): zero shot hugging face pipeline classifier
|
14 |
|
15 |
Returns:
|
16 |
+
bool: is_climate_change_related or not
|
17 |
"""
|
18 |
results = classifier(
|
19 |
sequences=sentence,
|
|
|
26 |
def make_pairs(lst):
|
27 |
"""From a list of even lenght, make tupple pairs
|
28 |
Args:
|
29 |
+
lst (list): a list of even lenght
|
30 |
Returns:
|
31 |
+
list: the list as tupple pairs
|
32 |
"""
|
33 |
return [(lst[i], lst[i + 1]) for i in range(0, len(lst), 2)]
|
34 |
|