bijoy01 commited on
Commit
b3d020d
·
verified ·
1 Parent(s): 1a4b274

second commit for chat bot-1

Browse files
Files changed (1) hide show
  1. app.py +34 -9
app.py CHANGED
@@ -1,21 +1,46 @@
1
  import gradio as gr
2
- from transformers import pipeline
3
 
4
- # একটি প্রি-ট্রেন মডল লোড করুন (যেমন: GPT-2)
5
- chatbot = pipeline("text-generation", model="gpt2")
 
 
 
 
 
 
 
 
 
6
 
7
- # চ্যাটবট ফাংশন তৈরি করুন
8
  def chat(input_text):
9
- response = chatbot(input_text, max_length=50, num_return_sequences=1)
10
- return response[0]['generated_text']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- # Gradio ইন্টারফেস তৈরি করুন
13
  interface = gr.Interface(
14
  fn=chat,
15
  inputs="text",
16
  outputs="text",
17
- title="আমার চ্যাটবট",
18
- description="এটি একটি সাধারণ চ্যাটবট।"
19
  )
20
 
21
  # অ্যাপ রান করুন
 
1
  import gradio as gr
 
2
 
3
+ # JSON ডেটা
4
+ data = {
5
+ "country": "Bangladesh",
6
+ "capital": "Dhaka",
7
+ "location": "South Asia",
8
+ "population": "166 million",
9
+ "official_language": "Bengali",
10
+ "currency": "Taka",
11
+ "landmarks": ["Sundarbans", "Cox's Bazar", "Dhaka's National Museum"],
12
+ "economy": "Textiles, agriculture, remittances"
13
+ }
14
 
15
+ # চ্যাটবট ফাংশন
16
  def chat(input_text):
17
+ input_text = input_text.lower() # প্রশ্নটি ছোট হাতের অক্ষরে রূপান্তর করুন
18
+ if "country" in input_text:
19
+ return f"Country: {data['country']}"
20
+ elif "capital" in input_text:
21
+ return f"Capital: {data['capital']}"
22
+ elif "location" in input_text:
23
+ return f"Location: {data['location']}"
24
+ elif "population" in input_text:
25
+ return f"Population: {data['population']}"
26
+ elif "official language" in input_text:
27
+ return f"Official Language: {data['official_language']}"
28
+ elif "currency" in input_text:
29
+ return f"Currency: {data['currency']}"
30
+ elif "landmarks" in input_text:
31
+ return f"Landmarks: {', '.join(data['landmarks'])}"
32
+ elif "economy" in input_text:
33
+ return f"Economy: {data['economy']}"
34
+ else:
35
+ return "Sorry, I don't have information about that."
36
 
37
+ # Gradio ইন্টারফেস
38
  interface = gr.Interface(
39
  fn=chat,
40
  inputs="text",
41
  outputs="text",
42
+ title="Bangladesh Info Chatbot",
43
+ description="Ask me about Bangladesh!"
44
  )
45
 
46
  # অ্যাপ রান করুন