markrodrigo commited on
Commit
0965db4
·
1 Parent(s): f25445a
Files changed (1) hide show
  1. app.py +3 -9
app.py CHANGED
@@ -2,8 +2,6 @@ from transformers import pipeline
2
  import gradio as gr
3
  import spaces
4
 
5
- # Hidden state for the counter
6
- counter_state = gr.State(0)
7
 
8
  pipe = pipeline("text-generation", model="markrodrigo/Llama-3.2-3B-Instruct-Spatial-SQL-1.1", device_map="auto")
9
 
@@ -68,10 +66,7 @@ custom_css = """
68
 
69
 
70
  @spaces.GPU
71
- def respond(user_message, chat_history, counter):
72
-
73
- # 1. Increment counter
74
- counter += 1
75
 
76
  chat_history = chat_history or []
77
 
@@ -96,7 +91,7 @@ def respond(user_message, chat_history, counter):
96
  bot_response = sequences[0]["generated_text"].strip()
97
  chat_history[-1]["content"] = bot_response
98
 
99
- return chat_history, "", counter
100
 
101
 
102
 
@@ -125,8 +120,7 @@ with gr.Blocks(title="Text to PostGIS Postgresql via Llama 3.2", css=custom_css)
125
  inputs=msg,
126
  label="Click an example → then click Submit"
127
  )
128
- counter_display = gr.Textbox(label="Request Counter", value=0, interactive=False)
129
- submit_btn.click(fn=respond, inputs=[msg, chatbot, counter_state], outputs=[chatbot, msg, counter_state, counter_display])
130
  msg.submit(fn=respond, inputs=[msg, chatbot], outputs=[chatbot, msg])
131
 
132
  clear_btn = gr.Button("Clear Chat", elem_id="clear-chat-btn")
 
2
  import gradio as gr
3
  import spaces
4
 
 
 
5
 
6
  pipe = pipeline("text-generation", model="markrodrigo/Llama-3.2-3B-Instruct-Spatial-SQL-1.1", device_map="auto")
7
 
 
66
 
67
 
68
  @spaces.GPU
69
+ def respond(user_message, chat_history):
 
 
 
70
 
71
  chat_history = chat_history or []
72
 
 
91
  bot_response = sequences[0]["generated_text"].strip()
92
  chat_history[-1]["content"] = bot_response
93
 
94
+ return chat_history, ""
95
 
96
 
97
 
 
120
  inputs=msg,
121
  label="Click an example → then click Submit"
122
  )
123
+ submit_btn.click(fn=respond, inputs=[msg, chatbot], outputs=[chatbot, msg])
 
124
  msg.submit(fn=respond, inputs=[msg, chatbot], outputs=[chatbot, msg])
125
 
126
  clear_btn = gr.Button("Clear Chat", elem_id="clear-chat-btn")