DHEIVER commited on
Commit
ad8c1ef
1 Parent(s): a004f60

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -21
app.py CHANGED
@@ -1,28 +1,23 @@
1
  import gradio as gr
2
- import requests
3
 
4
- API_URL = "https://api-inference.huggingface.co/models/bigscience/bloom"
5
- headers = {"Authorization": "Bearer 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"}
 
 
 
 
6
 
7
- def query(payload):
8
- response = requests.post(API_URL, headers=headers, json=payload)
9
- return response.json()
 
 
 
 
 
 
10
 
11
- def chatbot(question):
12
- response = query({
13
- "inputs": question
14
- })
15
- generated_text = response[0]["generated_text"].strip()
16
- return generated_text
17
-
18
- iface = gr.Interface(
19
- fn=chatbot,
20
- inputs=gr.inputs.Textbox(),
21
- outputs=gr.outputs.Textbox(),
22
- live=True,
23
- title="Chatbot de Vestibular",
24
- description="Digite sua pergunta sobre vestibulares e receba respostas do nosso assistente de vestibular.",
25
- )
26
 
27
  if __name__ == "__main__":
28
  iface.launch()
 
1
  import gradio as gr
 
2
 
3
+ def create_gradio_app(model, tokenizer):
4
+ def gradio_fn(question):
5
+ inputs = tokenizer(question, return_tensors="pt")
6
+ outputs = model(inputs)[0]
7
+ generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
8
+ return generated_text
9
 
10
+ iface = gr.Interface(
11
+ fn=gradio_fn,
12
+ inputs=gr.inputs.Textbox(),
13
+ outputs=gr.outputs.Textbox(),
14
+ live=True,
15
+ title="Gradio App",
16
+ description="Create a gradio app using the Quokka-7b model.",
17
+ )
18
+ return iface
19
 
20
+ iface = create_gradio_app(model, tokenizer)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  if __name__ == "__main__":
23
  iface.launch()