davanstrien HF Staff commited on
Commit
3961ac6
·
1 Parent(s): be2e1b0

chore: Refactor generate_instruction_response function and optimize Gradio demo description

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -48,7 +48,8 @@ def generate_instruction_response():
48
  len(extract_input) :
49
  ].split("\n")[0]
50
 
51
- yield "## Generated instructions: \n" + sanitized_instruction
 
52
 
53
  response_template = f"""<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n{sanitized_instruction}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"""
54
 
@@ -63,7 +64,7 @@ def generate_instruction_response():
63
 
64
  assistant_response = response[0]["generated_text"][len(response_template) :]
65
 
66
- yield "## Generated response: \n" + assistant_response
67
 
68
 
69
  title = "Magpie demo"
 
48
  len(extract_input) :
49
  ].split("\n")[0]
50
 
51
+ first_rep = "## Generated instructions:\n\n" + sanitized_instruction
52
+ yield first_rep + "\n\n generating LLM response..."
53
 
54
  response_template = f"""<|begin_of_text|><|start_header_id|>user<|end_header_id|>\n\n{sanitized_instruction}<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n"""
55
 
 
64
 
65
  assistant_response = response[0]["generated_text"][len(response_template) :]
66
 
67
+ yield (first_rep + "\n\n## Generated response:\n\n" + assistant_response)
68
 
69
 
70
  title = "Magpie demo"