DrishtiSharma commited on
Commit
c5009ae
·
verified ·
1 Parent(s): 27d41c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -61
app.py CHANGED
@@ -54,69 +54,33 @@ def initialize_session_state_variables() -> None:
54
  """
55
  Initialize all the session state variables.
56
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
- # Variables for chatbot
59
- if "ready" not in st.session_state:
60
- st.session_state.ready = False
61
-
62
- if "openai" not in st.session_state:
63
- st.session_state.openai = None
64
-
65
- if "history" not in st.session_state:
66
- st.session_state.history = []
67
-
68
- if "model_type" not in st.session_state:
69
- st.session_state.model_type = "GPT Models from OpenAI"
70
-
71
- if "agent_type" not in st.session_state:
72
- st.session_state.agent_type = 2 * ["Tool Calling"]
73
-
74
- if "ai_role" not in st.session_state:
75
- st.session_state.ai_role = 2 * ["You are a helpful AI assistant."]
76
-
77
- if "prompt_exists" not in st.session_state:
78
- st.session_state.prompt_exists = False
79
-
80
- if "temperature" not in st.session_state:
81
- st.session_state.temperature = [0.7, 0.7]
82
-
83
- # Variables for audio and image
84
- if "audio_bytes" not in st.session_state:
85
- st.session_state.audio_bytes = None
86
-
87
- if "mic_used" not in st.session_state:
88
- st.session_state.mic_used = False
89
-
90
- if "audio_response" not in st.session_state:
91
- st.session_state.audio_response = None
92
-
93
- if "image_url" not in st.session_state:
94
- st.session_state.image_url = None
95
-
96
- if "image_description" not in st.session_state:
97
- st.session_state.image_description = None
98
-
99
- if "uploader_key" not in st.session_state:
100
- st.session_state.uploader_key = 0
101
-
102
- # Variables for tools
103
- if "tool_names" not in st.session_state:
104
- st.session_state.tool_names = [[], []]
105
-
106
- if "bing_subscription_validity" not in st.session_state:
107
- st.session_state.bing_subscription_validity = False
108
-
109
- if "google_cse_id_validity" not in st.session_state:
110
- st.session_state.google_cse_id_validity = False
111
-
112
- if "vector_store_message" not in st.session_state:
113
- st.session_state.vector_store_message = None
114
-
115
- if "retriever_tool" not in st.session_state:
116
- st.session_state.retriever_tool = None
117
 
118
- if "show_uploader" not in st.session_state:
119
- st.session_state.show_uploader = False
120
 
121
 
122
  class StreamHandler(BaseCallbackHandler):
 
54
  """
55
  Initialize all the session state variables.
56
  """
57
+ default_values = {
58
+ "ready": False,
59
+ "openai": None,
60
+ "history": [],
61
+ "model_type": "GPT Models from OpenAI",
62
+ "agent_type": 2 * ["Tool Calling"],
63
+ "ai_role": 2 * ["You are a helpful AI assistant."],
64
+ "prompt_exists": False,
65
+ "temperature": [0.7, 0.7],
66
+ "audio_bytes": None,
67
+ "mic_used": False,
68
+ "audio_response": None,
69
+ "image_url": None,
70
+ "image_description": None,
71
+ "uploader_key": 0,
72
+ "tool_names": [[], []],
73
+ "bing_subscription_validity": False,
74
+ "google_cse_id_validity": False,
75
+ "vector_store_message": None,
76
+ "retriever_tool": None,
77
+ "show_uploader": False
78
+ }
79
 
80
+ for key, value in default_values.items():
81
+ if key not in st.session_state:
82
+ st.session_state[key] = value
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
 
 
84
 
85
 
86
  class StreamHandler(BaseCallbackHandler):