Spaces:
Sleeping
Sleeping
File size: 943 Bytes
f338432 |
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 |
import gradio as gr
from gradio_client import Client
client = Client("TejAndrewsACC/Z3ta")
context = ""
system_instructions = (
"None"
)
def chat_function(message, history):
global context
modified_input = (
f"System Instructions: {system_instructions}\n"
f"Previous Context: {context}\n"
f"User Input: {message}"
)
try:
response = client.predict(
message=modified_input,
api_name="/chat_function"
)
context += f"User: {message}\nAI: {response}\n"
history.append((message, response))
return response, history
except Exception as e:
return f"Error: {e}", history
with gr.Blocks(theme=gr.themes.Glass()) as demo:
chatbot = gr.Chatbot()
msg = gr.Textbox(placeholder="Type something...")
clear = gr.ClearButton([msg, chatbot])
msg.submit(chat_function, [msg, chatbot], [msg, chatbot])
demo.launch() |