Al-Alcoba-Inciarte commited on
Commit
4d24f6b
1 Parent(s): 49648c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -1,7 +1,20 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  def greet(name):
4
  return "Hello " + name + "!!"
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
  iface.launch()
 
1
  import gradio as gr
2
+ from getpass import getpass
3
+
4
+ hf_token = getpass("Enter Hugging Face API key:")
5
+
6
+ from haystack.components.generators import HuggingFaceTGIGenerator
7
+
8
+ generator = HuggingFaceTGIGenerator("mistralai/Mixtral-8x7B-Instruct-v0.1", token=hf_token)
9
+ generator.warm_up()
10
+
11
+ def respond(prompt):
12
+ result = generator.run("What is a diplomatic element?", generation_kwargs={"max_new_tokens": 350})
13
+ return result["replies"][0]
14
+
15
 
16
  def greet(name):
17
  return "Hello " + name + "!!"
18
 
19
+ iface = gr.Interface(fn=respond, inputs="text", outputs="text")
20
  iface.launch()