gabrielaltay commited on
Commit
b2c7bf9
1 Parent(s): a26c328

deterministic sort order

Browse files
Files changed (3) hide show
  1. app.py +2 -4
  2. doc_format_mod.py +4 -1
  3. sidebar_mod.py +2 -1
app.py CHANGED
@@ -231,7 +231,7 @@ def get_llm(gen_config: dict):
231
  max_output_tokens=gen_config["max_output_tokens"],
232
  top_p=gen_config["top_p"],
233
  )
234
-
235
  case _:
236
  raise ValueError()
237
 
@@ -304,9 +304,7 @@ def render_response(
304
  st.write(f"Response ({tag})")
305
  st.info(response_text)
306
 
307
- usage_mod.display_api_usage(
308
- response["aimessage"], model_info, provider, tag=tag
309
- )
310
  doc_format_mod.render_retrieved_chunks(response["docs"], tag=tag)
311
 
312
 
 
231
  max_output_tokens=gen_config["max_output_tokens"],
232
  top_p=gen_config["top_p"],
233
  )
234
+
235
  case _:
236
  raise ValueError()
237
 
 
304
  st.write(f"Response ({tag})")
305
  st.info(response_text)
306
 
307
+ usage_mod.display_api_usage(response["aimessage"], model_info, provider, tag=tag)
 
 
308
  doc_format_mod.render_retrieved_chunks(response["docs"], tag=tag)
309
 
310
 
doc_format_mod.py CHANGED
@@ -37,7 +37,10 @@ def group_docs(docs) -> list[tuple[str, list[Document]]]:
37
  # sort groups by number of docs
38
  doc_grps = sorted(
39
  tuple(doc_grps.items()),
40
- key=lambda x: -len(x[1]),
 
 
 
41
  )
42
 
43
  return doc_grps
 
37
  # sort groups by number of docs
38
  doc_grps = sorted(
39
  tuple(doc_grps.items()),
40
+ key=lambda x: (
41
+ -len(x[1]), # length of x[1] = number of chunks
42
+ x[0], # legis_id for deterministic sort
43
+ ),
44
  )
45
 
46
  return doc_grps
sidebar_mod.py CHANGED
@@ -20,7 +20,8 @@ def render_outreach_links():
20
  st.subheader(f":hut: Inference [anthropic]({anthropic_url})")
21
  st.subheader(f":sparkles: Inference [openai]({openai_url})")
22
  st.subheader(f":parrot: Orchestration [langchain]({langchain_url})")
23
-
 
24
  def render_sidebar():
25
  with st.container(border=True):
26
  render_outreach_links()
 
20
  st.subheader(f":hut: Inference [anthropic]({anthropic_url})")
21
  st.subheader(f":sparkles: Inference [openai]({openai_url})")
22
  st.subheader(f":parrot: Orchestration [langchain]({langchain_url})")
23
+
24
+
25
  def render_sidebar():
26
  with st.container(border=True):
27
  render_outreach_links()