File size: 886 Bytes
825e58e
f8aef6b
be62125
 
 
993833c
be62125
fb48099
 
0755e92
 
 
 
 
 
 
 
 
 
 
 
 
 
0c89ce8
0755e92
 
 
 
fb48099
 
f8aef6b
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
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()