InfiniteValueMe commited on
Commit
7e21d3e
·
verified ·
1 Parent(s): 678a405

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -15
app.py CHANGED
@@ -120,28 +120,28 @@ with gr.Blocks(title="Infinite Agent", css=open(css_path).read()) as demo:
120
  #Language selector
121
  language = gr.Dropdown(["English", "Svenska", "Türkçe"], label="Choose language", value="English")
122
 
123
- #Chatbot with welcome message
124
  chatbot = gr.Chatbot(type="messages", value=[
125
  {"role": "system", "content": "🌙 Welcome to Infinite Agent — your guide to emotional clarity, self-worth, and life direction."}
126
  ])
127
 
128
- #Input textbox and clear button
129
  msg = gr.Textbox(placeholder="Ask about your emotions, direction, or purpose...")
130
  clear = gr.Button("Clear")
131
 
132
- #Submit & clear actions
133
  msg.submit(chat_with_infinite_agent, [msg, language, chatbot], [chatbot, chatbot])
134
- clear.click(lambda: [], None, chatbot, queue=False) # clears chat
135
-
136
- #Hidden API interface
137
- def api_predict(message, lang="English"):
138
- history, _ = chat_with_infinite_agent(message, lang, [])
139
- return history[-1]["content"]
140
-
141
- api_input = gr.Textbox(visible=False)
142
- api_output = gr.Textbox(visible=False)
143
- api_button = gr.Button(visible=False)
144
-
145
- api_button.click(api_predict, inputs=api_input, outputs=api_output)
 
 
146
 
147
  demo.launch()
 
120
  #Language selector
121
  language = gr.Dropdown(["English", "Svenska", "Türkçe"], label="Choose language", value="English")
122
 
123
+ #Chatbot
124
  chatbot = gr.Chatbot(type="messages", value=[
125
  {"role": "system", "content": "🌙 Welcome to Infinite Agent — your guide to emotional clarity, self-worth, and life direction."}
126
  ])
127
 
 
128
  msg = gr.Textbox(placeholder="Ask about your emotions, direction, or purpose...")
129
  clear = gr.Button("Clear")
130
 
 
131
  msg.submit(chat_with_infinite_agent, [msg, language, chatbot], [chatbot, chatbot])
132
+ clear.click(lambda: [], None, chatbot, queue=False)
133
+
134
+ #API endpoint
135
+ def api_predict(message, lang="English"):
136
+ history, _ = chat_with_infinite_agent(message, lang, [])
137
+ return history[-1]["content"]
138
+
139
+ #Hidden Interface for /api/predict
140
+ api_interface = gr.Interface(
141
+ fn=api_predict,
142
+ inputs=[gr.Textbox(label="Message"), gr.Textbox(label="Language", value="English")],
143
+ outputs=gr.Textbox(label="Response"),
144
+ allow_flagging="never",
145
+ )
146
 
147
  demo.launch()