Youssouf Traore commited on
Commit
5f6428d
·
1 Parent(s): 63ab98e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -8
app.py CHANGED
@@ -1,5 +1,10 @@
1
- import requests
2
  import gradio as gr
 
 
 
 
 
 
3
 
4
 
5
  def infer(im):
@@ -27,10 +32,39 @@ def infer(im):
27
  return text
28
 
29
 
30
- iface = gr.Interface(
31
- fn=infer,
32
- title="Mariam - Beta",
33
- description=" La maj du siècle. ",
34
- inputs=[gr.Image(type="pil")],
35
- outputs=["text"],
36
- ).launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import openai
3
+ title = "Multiple Interfaces"
4
+
5
+ #app 1
6
+
7
+ import requests
8
 
9
 
10
  def infer(im):
 
32
  return text
33
 
34
 
35
+
36
+
37
+
38
+
39
+ #app 2
40
+
41
+ openai.api_key = "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"
42
+
43
+ def gpt(prompt):
44
+ if not prompt:
45
+ return "Veuillez saisir une question."
46
+ f_prompt = f"""
47
+ {prompt}. """
48
+
49
+ response = openai.Completion.create(
50
+ model="text-davinci-003",
51
+ prompt=f_prompt,
52
+ temperature=0.9,
53
+ max_tokens=3500,
54
+ top_p=1)
55
+
56
+ answer = response.choices[0].text.strip()
57
+ print(answer)
58
+ return answer
59
+
60
+
61
+
62
+ #interface 1
63
+ app1 = gr.Interface(fn = infer,title="Mariam -Ocr ", inputs=[gr.Image(type="pil")], outputs=["text"])
64
+ #interface 2
65
+
66
+ app2 = gr.Interface(fn = gpt, inputs=gr.TextBox(label="Question:",lines=8), outputs=gr.Textbox())
67
+
68
+ demo = gr.TabbedInterface([app1, app2], ["Welcome", "What to do"])
69
+
70
+ demo.launch()