david-oplatka
commited on
Commit
•
86fb75b
1
Parent(s):
069ea9c
New Input Approach
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import threading
|
|
3 |
from markdown_it import MarkdownIt
|
4 |
from mdit_py_plugins import front_matter
|
5 |
|
6 |
-
from reactpy import component, html, hooks,
|
7 |
from reactpy.backend.starlette import configure
|
8 |
from starlette.applications import Starlette
|
9 |
from vectara_agentic.agent import AgentStatusType
|
@@ -33,6 +33,7 @@ def App():
|
|
33 |
messages, set_messages = hooks.use_state([])
|
34 |
|
35 |
message, set_message = hooks.use_state("")
|
|
|
36 |
|
37 |
def use_agent_logger():
|
38 |
agent_log_entries, set_agent_log_entries = hooks.use_state([])
|
@@ -92,6 +93,7 @@ def App():
|
|
92 |
if message.strip():
|
93 |
sent_message = message
|
94 |
set_message("")
|
|
|
95 |
set_show_logs_button(False)
|
96 |
set_show_logs(False)
|
97 |
reset_log_entries()
|
@@ -110,18 +112,24 @@ def App():
|
|
110 |
|
111 |
asyncio.create_task(send_message_async(sent_message))
|
112 |
|
113 |
-
# New Code Suggestion from Claude
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
def handle_input(event):
|
115 |
-
|
|
|
116 |
|
117 |
def handle_key_down(event):
|
118 |
if event['key'] == 'Enter':
|
119 |
send_message()
|
120 |
|
121 |
-
|
122 |
-
# handle_key_down = use_callback(lambda event:
|
123 |
-
# send_message() if event['key'] == 'Enter' else None,
|
124 |
-
# [send_message])
|
125 |
|
126 |
@component
|
127 |
def Header(demo_name: str, short_description: str, extra_info: str):
|
|
|
3 |
from markdown_it import MarkdownIt
|
4 |
from mdit_py_plugins import front_matter
|
5 |
|
6 |
+
from reactpy import component, html, hooks, use_effect, svg
|
7 |
from reactpy.backend.starlette import configure
|
8 |
from starlette.applications import Starlette
|
9 |
from vectara_agentic.agent import AgentStatusType
|
|
|
33 |
messages, set_messages = hooks.use_state([])
|
34 |
|
35 |
message, set_message = hooks.use_state("")
|
36 |
+
input_value, set_input_value = hooks.use_state("")
|
37 |
|
38 |
def use_agent_logger():
|
39 |
agent_log_entries, set_agent_log_entries = hooks.use_state([])
|
|
|
93 |
if message.strip():
|
94 |
sent_message = message
|
95 |
set_message("")
|
96 |
+
set_input_value("")
|
97 |
set_show_logs_button(False)
|
98 |
set_show_logs(False)
|
99 |
reset_log_entries()
|
|
|
112 |
|
113 |
asyncio.create_task(send_message_async(sent_message))
|
114 |
|
115 |
+
# # New Code Suggestion from Claude
|
116 |
+
# def handle_input(event):
|
117 |
+
# set_message(event['target']['value'])
|
118 |
+
|
119 |
+
# def handle_key_down(event):
|
120 |
+
# if event['key'] == 'Enter':
|
121 |
+
# send_message()
|
122 |
+
|
123 |
+
|
124 |
def handle_input(event):
|
125 |
+
new_value = event['target']['value']
|
126 |
+
set_input_value(new_value)
|
127 |
|
128 |
def handle_key_down(event):
|
129 |
if event['key'] == 'Enter':
|
130 |
send_message()
|
131 |
|
132 |
+
use_effect(lambda: set_message(input_value), [input_value])
|
|
|
|
|
|
|
133 |
|
134 |
@component
|
135 |
def Header(demo_name: str, short_description: str, extra_info: str):
|