debisoft commited on
Commit
c5acf4e
·
1 Parent(s): 3c4f927
Files changed (1) hide show
  1. main.py +18 -8
main.py CHANGED
@@ -28,6 +28,18 @@ function load()
28
  //alert('loading...');
29
  }
30
  setTimeout(load, 1000);
 
 
 
 
 
 
 
 
 
 
 
 
31
  """
32
 
33
  # @rt('/')
@@ -88,18 +100,15 @@ def ChatInput():
88
  # The main screen
89
  @app.get
90
  def index():
91
- page = Form(hx_post=send, hx_target="#chatlist", hx_swap="beforeend")(
92
- Div(id="chatlist", cls="chat-box h-[73vh] overflow-y-auto"),
93
- Div(cls="flex space-x-2 mt-2")(
94
- Group(ChatInput(), Button("Send", cls="btn btn-primary"))
95
- )
96
- )
97
  return Titled("MinorityMap",
 
 
 
98
  Link(rel="stylesheet", href="https://unpkg.com/[email protected]/dist/leaflet.css"),
99
  Style(style),
100
  Script(src="https://unpkg.com/[email protected]/dist/leaflet.js"),
101
  #Body(onload='load()'),
102
- Form(hx_post=send, hx_target="#chatlist", hx_swap="beforeend")(
103
  Div(id='mapid'),
104
  Div(cls="flex space-x-2 mt-2")(
105
  Group(ChatInput(), Button("Send", cls="btn btn-primary"))
@@ -115,7 +124,8 @@ def send(msg:str, messages:list[str]=None):
115
  if not messages: messages = []
116
  messages.append(msg.rstrip())
117
  print(messages[0])
118
- r = get_completion(messages[0]) # get response from chat model
 
119
  return (ChatMessage(msg, True), # The user's message
120
  ChatMessage(r.rstrip(), False), # The chatbot's response
121
  ChatInput()) # And clear the input field via an OOB swap
 
28
  //alert('loading...');
29
  }
30
  setTimeout(load, 1000);
31
+
32
+ $('#chat_form')
33
+ .ajaxForm({
34
+ url : 'myscript.php', // or whatever
35
+ dataType : 'json',
36
+ success : function (response) {
37
+ alert("The server says: " + response);
38
+ }
39
+ })
40
+ ;
41
+
42
+
43
  """
44
 
45
  # @rt('/')
 
100
  # The main screen
101
  @app.get
102
  def index():
 
 
 
 
 
 
103
  return Titled("MinorityMap",
104
+ Link(rel="stylesheet", href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/ui-darkness/jquery-ui.css"),
105
+ Script(src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"),
106
+ Script(src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js"),
107
  Link(rel="stylesheet", href="https://unpkg.com/[email protected]/dist/leaflet.css"),
108
  Style(style),
109
  Script(src="https://unpkg.com/[email protected]/dist/leaflet.js"),
110
  #Body(onload='load()'),
111
+ Form(id="chat_form", hx_post=send, hx_target="#chatlist", hx_swap="beforeend")(
112
  Div(id='mapid'),
113
  Div(cls="flex space-x-2 mt-2")(
114
  Group(ChatInput(), Button("Send", cls="btn btn-primary"))
 
124
  if not messages: messages = []
125
  messages.append(msg.rstrip())
126
  print(messages[0])
127
+ post_append_str = ' Return as JSON with GeoLocation'
128
+ r = get_completion(messages[0] + post_append_str) # get response from chat model
129
  return (ChatMessage(msg, True), # The user's message
130
  ChatMessage(r.rstrip(), False), # The chatbot's response
131
  ChatInput()) # And clear the input field via an OOB swap