File size: 1,040 Bytes
825e58e f8aef6b fb48099 0c89ce8 9fe1a83 0c89ce8 9fe1a83 0c89ce8 d85fd16 0c89ce8 9fe1a83 0c89ce8 9fe1a83 0c89ce8 fb48099 0c89ce8 fb48099 f8aef6b 7569d93 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 32 33 34 35 36 37 |
import os
import gradio as gr
os.environ.get("var2")
def main(user):
chatbot = Chatbot(api_key=os.environ.get("test2"))
# Start chat
def get_input(var1):
# Display the prompt
print(user, end="")
# Initialize an empty list to store the input lines
lines = []
# Read lines of input until the user enters an empty line
while True:
line = ""
if line == "":
break
lines.append(line)
# Join the lines, separated by newlines, and store the result
user_input = "\n".join(lines)
# Return the input
return user_input
while True:
PROMPT = get_input("\nUser:\n")
# if PROMPT.startswith("!"):
# if chatbot_commands(PROMPT):
# continue
response = chatbot.ask(PROMPT)
response = response["choices"][0]["text"]
return response
iface = gr.Interface(fn=main, inputs="text", outputs="text")
iface.launch() |