Testing3 / app.py
tommy24's picture
Update app.py
36e603c
raw
history blame
886 Bytes
import os
import gradio as gr
import importlib
var2 = os.environ.get("var2")
if var2:
chatbot_module = importlib.import_module(var2)
ChatBot = getattr(chatbot_module, "Chatbot")
def main(user):
if "/web" in user:
return True
else:
chatbot = Chatbot(api_key=os.environ.get("test2"))
def get_input(var1):
print(user, end="")
lines = []
while True:
line = ""
if line == "":
break
lines.append(line)
user_input = "\n".join(lines)
return user_input
while True:
PROMPT = get_input("\nUser:\n")
response = chatbot.ask(PROMPT)
response = response["choices"][0]["text"]
return response
iface = gr.Interface(fn=main, inputs="text", outputs="text")
iface.launch()