File size: 2,358 Bytes
e641e34 92ad35f 42ea31f d2525f1 f3af7d2 91cbc82 cbad031 70d6d78 e762edb cbad031 e762edb e641e34 85a602b 70a77fc 85a602b 70a77fc 85a602b 12655ff 85a602b 12655ff 70a77fc 85a602b ee46b6a 7e7deeb f345069 7e7deeb d2525f1 3fbe171 d2525f1 7e7deeb 0bc676a 31f8607 85a602b 7e7deeb 85a602b 42ea31f 7845b8a e641e34 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
import gradio as gr
import wikipedia
import requests
from bs4 import BeautifulSoup
import pyjokes
def joke():
# importing installed library
My_joke = pyjokes.get_joke(language="en", category="neutral")
return My_joke
def wiki(name):
text = name
text = text.split("the")[-1]
text = text.split("is a")[-1]
text = text.split("by")[-1]
#print(wikipedia.search(text, results=20))
#print(text)
out = "try this key words :\n"+str(wikipedia.search(text, results=10))+"\n\n"
for i in wikipedia.search(text, results=3):
try:
result = wikipedia.summary(i)
if " " in result.lower():
#print(result)
#print()
out = out + result+"\n"
except:
continue
return out
def google(name):
result = {"",""}
text = ""
url = "https://www.google.com/search?q="+name
r = requests.get(url)
soup = BeautifulSoup(r.text,"html.parser")
heading_object=soup.find_all('div')
for info in heading_object:
if '<div class="BNeawe s3v9rd AP7Wnd"><div><div><div class="BNeawe s3v9rd AP7Wnd">' in str(info):
if '›' not in str(info.text) :
result.add(info.text)
n=0
for i in result:
if n!==0:
text = text +str(n)+"\t"+i+"\n\n"
n=n+1
return text
def greet(name1):
name = name1.lower()
#n=
if "who are you" in name or "what is you" in name or "your name" in name or"who r u" in name:
return "Im Ai Based Chatbot Created by ssebowa.org"
if "tell me a joke" in name or "the joke" in name:
return joke()
if "love you" in name or "i love" in name:
return "me too"
if "marry me" in name or "marry" in name:
return "im not intrested"
if "your age" in name or "what is your age" in name:
return "Im not a human so i don't have age"
if "thank u" in name or "thanks" in name or "thank you" in name:
return "ok welcome ....!"
return google(name)
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch() |