Avo-k commited on
Commit
9f6c9bd
1 Parent(s): 0b4f4a2

safer args + better doc strings

Browse files
Files changed (2) hide show
  1. app.py +8 -1
  2. utils.py +5 -5
app.py CHANGED
@@ -43,7 +43,14 @@ def chat(
43
  Yields:
44
  tuple: chat gradio format, chat openai format, sources used.
45
  """
46
- retriever = retrieve_all if report_type == "All available" else retrieve_giec
 
 
 
 
 
 
 
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): _description_
13
- classifier (_type_): _description_
14
 
15
  Returns:
16
- bool: _description_
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): _description_
30
  Returns:
31
- list: _description_
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