SHAILJA1 commited on
Commit
3c076f7
·
verified ·
1 Parent(s): 9592e34

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -16
app.py CHANGED
@@ -1,21 +1,26 @@
1
-
2
-
3
- from transformers import pipeline, Conversation
4
  import gradio as gr
5
 
6
- # Load chatbot pipeline
7
- chatbot = pipeline("conversational", model="microsoft/DialoGPT-small")
8
-
9
- # Chat function for Gradio
10
- def chat_fn(message, history):
11
- conversation = Conversation(message)
12
- response = chatbot(conversation)
13
- return response.generated_responses[-1]
 
 
 
14
 
15
- # Gradio UI
16
- with gr.Blocks() as demo:
17
- gr.Markdown("## 🤖 Simple Chatbot (DialoGPT)")
18
- chatbot_ui = gr.ChatInterface(fn=chat_fn)
 
 
 
 
 
 
19
 
20
- # Launch app
21
  demo.launch()
 
 
 
 
1
  import gradio as gr
2
 
3
+ def calculator(num1, num2, operation):
4
+ if operation == "Addition (+)":
5
+ return num1 + num2
6
+ elif operation == "Subtraction (-)":
7
+ return num1 - num2
8
+ elif operation == "Multiplication (*)":
9
+ return num1 * num2
10
+ elif operation == "Division (/)" and num2 != 0:
11
+ return num1 / num2
12
+ else:
13
+ return "Error: Division by zero"
14
 
15
+ demo = gr.Interface(
16
+ fn=calculator,
17
+ inputs=[
18
+ gr.Number(label="Number 1"),
19
+ gr.Number(label="Number 2"),
20
+ gr.Radio(["Addition (+)", "Subtraction (-)", "Multiplication (*)", "Division (/)"], label="Operation")
21
+ ],
22
+ outputs="text",
23
+ title="Simple Calculator"
24
+ )
25
 
 
26
  demo.launch()