lruizap commited on
Commit
769e23e
·
1 Parent(s): 70ee064

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -14,19 +14,20 @@ pipe = pipeline("text-generation", model="HuggingFaceH4/zephyr-7b-alpha",
14
  torch_dtype=torch.bfloat16, device_map="auto")
15
 
16
 
17
- def useZephyr(prompt):
18
  messages = [
19
  {
20
  "role": "system",
21
  "content": "you are a chatbot who always responds politely and in the shortest possible way",
22
  },
23
- {"role": "user", "content": "{prompt}"},
 
24
  ]
25
  # https://huggingface.co/docs/transformers/main/en/chat_templating
26
- prompt = pipe.tokenizer.apply_chat_template(
27
  messages, tokenize=False, add_generation_prompt=True)
28
 
29
- outputs = pipe(prompt)
30
  return outputs[0]["generated_text"]
31
 
32
 
@@ -44,8 +45,9 @@ def generatePrompt(prompt):
44
  # Interface
45
 
46
 
47
- input_prompt = gr.Textbox(label="Prompt", value="photographer")
48
- output_component = gr.Textbox(label="Output")
 
49
  examples = [["photographer"], ["developer"], ["teacher"], [
50
  "human resources staff"], ["recipe for ham croquettes"]]
51
  description = ""
 
14
  torch_dtype=torch.bfloat16, device_map="auto")
15
 
16
 
17
+ def useZephyr(prompt, promptdos):
18
  messages = [
19
  {
20
  "role": "system",
21
  "content": "you are a chatbot who always responds politely and in the shortest possible way",
22
  },
23
+ {"role": "user", "content": prompt},
24
+ {"role": "user", "content": promptdos},
25
  ]
26
  # https://huggingface.co/docs/transformers/main/en/chat_templating
27
+ new_prompt = pipe.tokenizer.apply_chat_template(
28
  messages, tokenize=False, add_generation_prompt=True)
29
 
30
+ outputs = pipe(new_prompt)
31
  return outputs[0]["generated_text"]
32
 
33
 
 
45
  # Interface
46
 
47
 
48
+ input_prompt = gr.Textbox(label="Actua como: ", value="Chef")
49
+ input_promptdos = gr.Textbox(label="Prompt: ", value="Recipe for ham croquettes")
50
+ output_component = gr.Textbox(label="Output: ")
51
  examples = [["photographer"], ["developer"], ["teacher"], [
52
  "human resources staff"], ["recipe for ham croquettes"]]
53
  description = ""