Spaces:
Sleeping
Sleeping
Said Lfagrouche
commited on
Commit
·
727b222
1
Parent(s):
c13c6ef
Fix syntax error: global variable declaration in api_mental_health.py
Browse files- api_mental_health.py +5 -11
api_mental_health.py
CHANGED
@@ -150,16 +150,11 @@ async def startup_event():
|
|
150 |
disallowed_special=(),
|
151 |
chunk_size=1000
|
152 |
)
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
embedding_function=embeddings
|
159 |
-
)
|
160 |
-
except Exception as chroma_error:
|
161 |
-
logger.warning(f"Error initializing Chroma collection: {chroma_error}")
|
162 |
-
vector_store = None
|
163 |
else:
|
164 |
logger.warning("Skipping ChromaDB initialization as OPENAI_API_KEY is not set")
|
165 |
vector_store = None
|
@@ -169,7 +164,6 @@ async def startup_event():
|
|
169 |
|
170 |
# Initialize OpenAI client and LLM if API key is available
|
171 |
logger.info("Initializing OpenAI client and LLM")
|
172 |
-
global openai_client, llm
|
173 |
if os.environ.get("OPENAI_API_KEY"):
|
174 |
try:
|
175 |
openai_client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
|
|
|
150 |
disallowed_special=(),
|
151 |
chunk_size=1000
|
152 |
)
|
153 |
+
vector_store = Chroma(
|
154 |
+
client=chroma_client,
|
155 |
+
collection_name="mental_health_conversations",
|
156 |
+
embedding_function=embeddings
|
157 |
+
)
|
|
|
|
|
|
|
|
|
|
|
158 |
else:
|
159 |
logger.warning("Skipping ChromaDB initialization as OPENAI_API_KEY is not set")
|
160 |
vector_store = None
|
|
|
164 |
|
165 |
# Initialize OpenAI client and LLM if API key is available
|
166 |
logger.info("Initializing OpenAI client and LLM")
|
|
|
167 |
if os.environ.get("OPENAI_API_KEY"):
|
168 |
try:
|
169 |
openai_client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
|