jedick commited on
Commit
9477d3a
·
1 Parent(s): f53e324

Attempt fix for ChromaDB ValueError

Browse files
Files changed (4) hide show
  1. app.py +5 -7
  2. graph.py +0 -3
  3. mods/tool_calling_llm.py +4 -0
  4. retriever.py +3 -3
app.py CHANGED
@@ -218,7 +218,7 @@ def to_workflow(request: gr.Request, *args):
218
  yield value
219
 
220
 
221
- @spaces.GPU(duration=60)
222
  def run_workflow_local(*args):
223
  for value in run_workflow(*args):
224
  yield value
@@ -264,13 +264,11 @@ with gr.Blocks(
264
  "local",
265
  "remote",
266
  ],
267
- value=("local" if torch.cuda.is_available() else "remote"),
 
 
268
  label="Compute Mode",
269
- info=(
270
- "NOTE: remote mode **does not** use ZeroGPU"
271
- if torch.cuda.is_available()
272
- else "NOTE: local mode requires GPU"
273
- ),
274
  render=False,
275
  )
276
 
 
218
  yield value
219
 
220
 
221
+ @spaces.GPU(duration=90)
222
  def run_workflow_local(*args):
223
  for value in run_workflow(*args):
224
  yield value
 
264
  "local",
265
  "remote",
266
  ],
267
+ # Default to remote because it provides a better first impression for most people
268
+ # value=("local" if torch.cuda.is_available() else "remote"),
269
+ value="remote",
270
  label="Compute Mode",
271
+ info="NOTE: remote mode **does not** use ZeroGPU",
 
 
 
 
272
  render=False,
273
  )
274
 
graph.py CHANGED
@@ -12,9 +12,6 @@ from retriever import BuildRetriever
12
  from prompts import query_prompt, generate_prompt, generic_tools_template
13
  from mods.tool_calling_llm import ToolCallingLLM
14
 
15
- # Local modules
16
- from retriever import BuildRetriever
17
-
18
  # For tracing (disabled)
19
  # os.environ["LANGSMITH_TRACING"] = "true"
20
  # os.environ["LANGSMITH_PROJECT"] = "R-help-chat"
 
12
  from prompts import query_prompt, generate_prompt, generic_tools_template
13
  from mods.tool_calling_llm import ToolCallingLLM
14
 
 
 
 
15
  # For tracing (disabled)
16
  # os.environ["LANGSMITH_TRACING"] = "true"
17
  # os.environ["LANGSMITH_PROJECT"] = "R-help-chat"
mods/tool_calling_llm.py CHANGED
@@ -177,6 +177,10 @@ class ToolCallingLLM(BaseChatModel, ABC):
177
  # Extract <think>...</think> content and text after </think> for further processing 20250726 jmd
178
  think_text, post_think = extract_think(response_message.content)
179
 
 
 
 
 
180
  # Parse output for JSON (support multiple objects separated by commas)
181
  try:
182
  parsed_json_results = json.loads(f"[{post_think}]")
 
177
  # Extract <think>...</think> content and text after </think> for further processing 20250726 jmd
178
  think_text, post_think = extract_think(response_message.content)
179
 
180
+ ## For debugging
181
+ # print("post_think")
182
+ # print(post_think)
183
+
184
  # Parse output for JSON (support multiple objects separated by commas)
185
  try:
186
  parsed_json_results = json.loads(f"[{post_think}]")
retriever.py CHANGED
@@ -174,9 +174,9 @@ def BuildRetrieverDense(compute_mode: str, top_k=6):
174
  # Get top k documents
175
  search_kwargs={"k": top_k},
176
  )
177
- ## Release GPU memory
178
- ## https://github.com/langchain-ai/langchain/discussions/10668
179
- # torch.cuda.empty_cache()
180
  return retriever
181
 
182
 
 
174
  # Get top k documents
175
  search_kwargs={"k": top_k},
176
  )
177
+ # Fix for ValueError('Could not connect to tenant default_tenant. Are you sure it exists?')
178
+ # https://github.com/langchain-ai/langchain/issues/26884
179
+ chromadb.api.client.SharedSystemClient.clear_system_cache()
180
  return retriever
181
 
182