BlitzenPrancer commited on
Commit
22f759a
·
1 Parent(s): d0699d2

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import gradio as gr
3
+ from EdgeGPT import Chatbot, ConversationStyle
4
+
5
+ bot = None
6
+
7
+ async def generate_response(prompt):
8
+ global bot
9
+ if bot is None:
10
+ bot = await Chatbot.create()
11
+ response = await bot.ask(prompt='' + prompt, conversation_style=ConversationStyle.creative)
12
+ message = response['item']['messages'][-1]['text']
13
+ bot = await Chatbot.create() # Create a new instance for the next prompt
14
+ return message
15
+
16
+ desc = "Interact with Bing AI, you can ask questions in this chat)"
17
+
18
+ iface = gr.Interface(
19
+ fn=generate_response,
20
+ inputs="text",
21
+ outputs="text",
22
+ title="Bing AI Chatbot",
23
+ description=desc
24
+ )