Zul001 commited on
Commit
2027b4c
·
verified ·
1 Parent(s): c2caed7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -13
app.py CHANGED
@@ -10,7 +10,7 @@ model_path = "Zul001/HydroSense_Gemma_Finetuned_Model"
10
  gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset(f"hf://{model_path}")
11
 
12
 
13
-
14
 
15
  custom_css = """
16
  @import url('https://fonts.googleapis.com/css2?family=Edu+AU+VIC+WA+NT+Dots:[email protected]&family=Give+You+Glory&family=Sofia&family=Sunshiney&family=Vujahday+Script&display=swap');
@@ -65,18 +65,23 @@ def post_process_output(prompt, result):
65
 
66
 
67
  def inference(prompt):
68
- prompt_text = prompt
69
- generated_text = gemma_lm.generate(prompt_text)
70
-
71
- #Apply post-processing
72
- formatted_output = post_process_output(prompt_text, generated_text)
73
- print(formatted_output)
74
-
75
- #adding a bit of delay
76
- time.sleep(1)
77
- result = formatted_output
78
- # sessions = add_session(prompt_text)
79
- return result
 
 
 
 
 
80
 
81
 
82
  # def inference(prompt):
@@ -106,6 +111,8 @@ def remember(prompt, result):
106
  # return "\n".join(previous_sessions)
107
 
108
  def clear_fields():
 
 
109
  return "", "" # Return empty strings to clear the prompt and output fields
110
 
111
 
 
10
  gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset(f"hf://{model_path}")
11
 
12
 
13
+ reset_triggered = False
14
 
15
  custom_css = """
16
  @import url('https://fonts.googleapis.com/css2?family=Edu+AU+VIC+WA+NT+Dots:[email protected]&family=Give+You+Glory&family=Sofia&family=Sunshiney&family=Vujahday+Script&display=swap');
 
65
 
66
 
67
  def inference(prompt):
68
+ global reset_triggered
69
+ if reset_triggered:
70
+ #do nothing
71
+ return "", ""
72
+
73
+ prompt_text = prompt
74
+ generated_text = gemma_lm.generate(prompt_text)
75
+
76
+ #Apply post-processing
77
+ formatted_output = post_process_output(prompt_text, generated_text)
78
+ print(formatted_output)
79
+
80
+ #adding a bit of delay
81
+ time.sleep(1)
82
+ result = formatted_output
83
+ # sessions = add_session(prompt_text)
84
+ return result
85
 
86
 
87
  # def inference(prompt):
 
111
  # return "\n".join(previous_sessions)
112
 
113
  def clear_fields():
114
+ global reset_triggered
115
+ reset_triggered = True
116
  return "", "" # Return empty strings to clear the prompt and output fields
117
 
118