AroojImtiaz commited on
Commit
3d473c5
·
verified ·
1 Parent(s): ee36a65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -31,7 +31,6 @@ if genai is not None:
31
  logging.info(f"Gemini model initialized: {MODEL_NAME}")
32
  except Exception as e:
33
  logging.error(f"Failed to initialize Gemini model '{MODEL_NAME}': {e}")
34
- model = None
35
  else:
36
  logging.error("google.generativeai is not available.")
37
 
@@ -47,6 +46,7 @@ async def _call_gemini_generate(prompt: str):
47
  async def on_chat_start():
48
  """Welcome message and session init."""
49
  cl.user_session.set("message_history", [{"role": "system", "content": SYSTEM_PROMPT}])
 
50
  if model is None:
51
  await cl.Message(
52
  content=(
@@ -97,4 +97,7 @@ async def handle_message(message: cl.Message):
97
 
98
  # Save assistant reply to history
99
  history.append({"role": "assistant", "content": reply})
100
- cl.user_session.set("message_history", history)
 
 
 
 
31
  logging.info(f"Gemini model initialized: {MODEL_NAME}")
32
  except Exception as e:
33
  logging.error(f"Failed to initialize Gemini model '{MODEL_NAME}': {e}")
 
34
  else:
35
  logging.error("google.generativeai is not available.")
36
 
 
46
  async def on_chat_start():
47
  """Welcome message and session init."""
48
  cl.user_session.set("message_history", [{"role": "system", "content": SYSTEM_PROMPT}])
49
+
50
  if model is None:
51
  await cl.Message(
52
  content=(
 
97
 
98
  # Save assistant reply to history
99
  history.append({"role": "assistant", "content": reply})
100
+ cl.user_session.set("message_history", history)
101
+
102
+ if __name__ == "__main__":
103
+ logging.info("Starting the application...")