derek-thomas HF staff commited on
Commit
7bda49c
1 Parent(s): e2c631c

Updating for latest handler

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -45,7 +45,7 @@ def bot(history, hyde=False):
45
  # Retrieve documents relevant to query
46
  document_start = perf_counter()
47
  if hyde:
48
- hyde_document = generate(f"Write a wikipedia article intro paragraph to answer this query: {query}")[-1]
49
 
50
  logger.warning(hyde_document)
51
  documents = retriever(hyde_document, top_k=top_k)
@@ -72,9 +72,9 @@ def bot(history, hyde=False):
72
  prompt_html = template_html.render(documents=documents, query=query)
73
 
74
  history[-1][1] = ""
75
- for character in generate(prompt):
76
- history[-1][1] = character
77
- yield history, prompt_html
78
 
79
 
80
  with gr.Blocks() as demo:
 
45
  # Retrieve documents relevant to query
46
  document_start = perf_counter()
47
  if hyde:
48
+ hyde_document = generate(f"Write a wikipedia article intro paragraph to answer this query: {query}").split('### Response: [|AI|]')[-1]
49
 
50
  logger.warning(hyde_document)
51
  documents = retriever(hyde_document, top_k=top_k)
 
72
  prompt_html = template_html.render(documents=documents, query=query)
73
 
74
  history[-1][1] = ""
75
+ response = generate(prompt)
76
+ history[-1][1] = response.split('### Response: [|AI|]')[-1]
77
+ return history, prompt_html
78
 
79
 
80
  with gr.Blocks() as demo: