sunholo 0.140.7__tar.gz → 0.140.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sunholo-0.140.7/src/sunholo.egg-info → sunholo-0.140.8}/PKG-INFO +1 -1
- {sunholo-0.140.7 → sunholo-0.140.8}/pyproject.toml +1 -1
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/flask/vac_routes.py +60 -58
- {sunholo-0.140.7 → sunholo-0.140.8/src/sunholo.egg-info}/PKG-INFO +1 -1
- {sunholo-0.140.7 → sunholo-0.140.8}/LICENSE.txt +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/MANIFEST.in +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/README.md +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/setup.cfg +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/dispatch_to_qa.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/langserve.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/route.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/agents/swagger.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/archive/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/archive/archive.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/auth/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/auth/gcloud.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/auth/refresh.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/auth/run.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/azure/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/azure/auth.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/azure/blobs.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/azure/event_grid.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/bots/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/bots/discord.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/bots/webapp.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/chunker/azure.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/chunker/encode_metadata.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/chunker/images.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/chunker/process_chunker_data.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/chunker/publish.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/chunker/pubsub.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/cli/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/cli/chat_vac.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/cli/cli.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/cli/configs.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/cli/deploy.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/cli/embedder.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/cli/swagger.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/cli/vertex.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/components/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/components/llm.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/components/retriever.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/custom_logging.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/alloydb.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/alloydb_client.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/database.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/lancedb.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/database/uuid.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/discovery_engine/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/discovery_engine/chunker_handler.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/discovery_engine/cli.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/discovery_engine/create_new.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/discovery_engine/discovery_engine_client.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/discovery_engine/get_ai_search_chunks.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/embedder/embed_metadata.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/excel/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/excel/plugin.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/gcs/download_folder.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/gcs/download_gcs_text.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/gcs/download_url.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/gcs/extract_and_sign.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/genai/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/genai/file_handling.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/genai/genaiv2.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/genai/images.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/genai/init.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/genai/process_funcs_cls.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/genai/safety.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/invoke/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/invoke/async_class.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/invoke/direct_vac_func.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/invoke/invoke_vac_utils.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/langchain_types.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/langfuse/evals.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/llamaindex/get_files.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/llamaindex/import_files.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/llamaindex/llamaindex_class.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/llamaindex/user_history.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/mcp/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/mcp/cli.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/ollama/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/ollama/ollama_images.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/qna/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/qna/parsers.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/qna/retry.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/senses/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/senses/stream_voice.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/streaming/stream_lookup.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/streaming/streaming.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/agent/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/agent/agent_service.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/agent/app.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/agent/my_log.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/agent/tools/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/agent/tools/your_agent.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/agent/vac_service.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/project/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/project/app.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/project/my_log.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/project/vac_service.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/system_services/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/system_services/app.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/templates/system_services/my_log.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/terraform/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/terraform/tfvars_editor.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/tools/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/tools/web_browser.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/api_key.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/big_context.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/config.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/config_class.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/gcp.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/gcp_project.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/mime.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/parsers.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/timedelta.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/user_ids.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/utils/version.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/vertex/__init__.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/vertex/extensions_call.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/vertex/extensions_class.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/vertex/genai_functions.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/vertex/init.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/vertex/memory_tools.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/vertex/safety.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo/vertex/type_dict_to_json.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo.egg-info/SOURCES.txt +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/src/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/tests/test_async.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/tests/test_async_genai2.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/tests/test_chat_history.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/tests/test_config.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/tests/test_genai2.py +0 -0
- {sunholo-0.140.7 → sunholo-0.140.8}/tests/test_unstructured.py +0 -0
@@ -36,7 +36,7 @@ except ImportError:
|
|
36
36
|
# Cache dictionary to store validated API keys
|
37
37
|
api_key_cache = {}
|
38
38
|
cache_duration = timedelta(minutes=5) # Cache duration
|
39
|
-
# Global caches and thread pool
|
39
|
+
# Global caches and thread pool
|
40
40
|
_config_cache = {}
|
41
41
|
_config_lock = threading.Lock()
|
42
42
|
_thread_pool = ThreadPoolExecutor(max_workers=4)
|
@@ -94,17 +94,24 @@ if __name__ == "__main__":
|
|
94
94
|
except Exception as e:
|
95
95
|
log.warning(f"Failed to pre-load config for {vector_name}: {e}")
|
96
96
|
|
97
|
-
|
98
|
-
@lru_cache(maxsize=100)
|
99
97
|
def _get_cached_config(self, vector_name: str):
|
100
|
-
"""Cached config loader with thread safety"""
|
98
|
+
"""Cached config loader with thread safety - CORRECTED VERSION"""
|
99
|
+
# Check cache first (without lock for read)
|
100
|
+
if vector_name in _config_cache:
|
101
|
+
log.debug(f"Using cached config for {vector_name}")
|
102
|
+
return _config_cache[vector_name]
|
103
|
+
|
104
|
+
# Need to load config
|
101
105
|
with _config_lock:
|
106
|
+
# Double-check inside lock (another thread might have loaded it)
|
102
107
|
if vector_name in _config_cache:
|
103
108
|
return _config_cache[vector_name]
|
104
109
|
|
105
110
|
try:
|
111
|
+
log.info(f"Loading fresh config for {vector_name}")
|
106
112
|
config = ConfigManager(vector_name)
|
107
113
|
_config_cache[vector_name] = config
|
114
|
+
log.info(f"Cached config for {vector_name}")
|
108
115
|
return config
|
109
116
|
except Exception as e:
|
110
117
|
log.error(f"Error loading config for {vector_name}: {e}")
|
@@ -286,13 +293,13 @@ if __name__ == "__main__":
|
|
286
293
|
if is_async:
|
287
294
|
log.info(f"Stream interpreter is async: {observed_stream_interpreter}")
|
288
295
|
|
289
|
-
#
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
error_response
|
295
|
-
return jsonify(error_response),
|
296
|
+
# Call prep_vac and handle errors properly
|
297
|
+
try:
|
298
|
+
prep = self.prep_vac(request, vector_name)
|
299
|
+
except Exception as e:
|
300
|
+
log.error(f"prep_vac failed: {e}")
|
301
|
+
error_response = {'error': f'Prep error: {str(e)}'}
|
302
|
+
return jsonify(error_response), 500
|
296
303
|
|
297
304
|
log.info(f"Processing prep completed in {time.time() - request_start:.3f}s")
|
298
305
|
|
@@ -343,7 +350,9 @@ if __name__ == "__main__":
|
|
343
350
|
else:
|
344
351
|
result_queue.put(chunk)
|
345
352
|
except Exception as e:
|
346
|
-
|
353
|
+
error_msg = f"Streaming Error: {str(e)} {traceback.format_exc()}"
|
354
|
+
log.error(error_msg)
|
355
|
+
result_queue.put(error_msg)
|
347
356
|
finally:
|
348
357
|
result_queue.put(None) # Sentinel
|
349
358
|
|
@@ -385,16 +394,18 @@ if __name__ == "__main__":
|
|
385
394
|
yield chunk
|
386
395
|
|
387
396
|
except Exception as e:
|
388
|
-
|
397
|
+
error_msg = f"Streaming Error: {str(e)} {traceback.format_exc()}"
|
398
|
+
log.error(error_msg)
|
399
|
+
yield error_msg
|
389
400
|
|
390
401
|
# Create streaming response
|
391
402
|
response = Response(generate_response_content(), content_type='text/plain; charset=utf-8')
|
392
403
|
response.headers['Transfer-Encoding'] = 'chunked'
|
393
404
|
|
394
|
-
log.
|
405
|
+
log.info(f"Streaming response created in {time.time() - request_start:.3f}s")
|
395
406
|
|
407
|
+
# Do final trace operations in background (don't block the response)
|
396
408
|
if trace:
|
397
|
-
# Do final trace operations in background
|
398
409
|
_thread_pool.submit(self._finalize_trace_background, trace, span, response, all_input)
|
399
410
|
|
400
411
|
return response
|
@@ -744,59 +755,50 @@ if __name__ == "__main__":
|
|
744
755
|
def prep_vac(self, request, vector_name):
|
745
756
|
start_time = time.time()
|
746
757
|
|
747
|
-
# Fast request parsing
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
except Exception as e:
|
764
|
-
return {"error": f"Request parsing error: {str(e)}"}, 400
|
758
|
+
# Fast request parsing - KEEP ORIGINAL ERROR HANDLING STYLE
|
759
|
+
if request.content_type.startswith('application/json'):
|
760
|
+
data = request.get_json()
|
761
|
+
elif request.content_type.startswith('multipart/form-data'):
|
762
|
+
data = request.form.to_dict()
|
763
|
+
# Handle file upload in background if present
|
764
|
+
if 'file' in request.files:
|
765
|
+
file = request.files['file']
|
766
|
+
if file.filename != '':
|
767
|
+
log.info(f"Found file: {file.filename} - uploading in background")
|
768
|
+
# Start file upload in background, don't block
|
769
|
+
upload_future = _thread_pool.submit(self._handle_file_upload_background, file, vector_name)
|
770
|
+
data["_upload_future"] = upload_future
|
771
|
+
else:
|
772
|
+
# KEEP ORIGINAL STYLE - return the error response directly
|
773
|
+
raise ValueError("Unsupported content type")
|
765
774
|
|
766
775
|
log.info(f"vac/{vector_name} got data keys: {list(data.keys())}")
|
767
776
|
|
768
|
-
#
|
769
|
-
try:
|
770
|
-
user_input = data.pop('user_input').strip()
|
771
|
-
stream_wait_time = data.pop('stream_wait_time', 7)
|
772
|
-
stream_timeout = data.pop('stream_timeout', 120)
|
773
|
-
chat_history = data.pop('chat_history', None)
|
774
|
-
eval_percent = data.pop('eval_percent', 0.01)
|
775
|
-
vector_name_param = data.pop('vector_name', vector_name)
|
776
|
-
trace_id = data.pop('trace_id', None)
|
777
|
-
|
778
|
-
if not user_input:
|
779
|
-
return {"error": "No user input provided"}, 400
|
780
|
-
|
781
|
-
except Exception as e:
|
782
|
-
return {"error": f"Required field missing: {str(e)}"}, 400
|
783
|
-
|
784
|
-
# Get config from cache (should be very fast)
|
777
|
+
# Get config from cache first (before processing other data)
|
785
778
|
try:
|
786
779
|
vac_config = self._get_cached_config(vector_name)
|
787
780
|
except Exception as e:
|
788
|
-
|
789
|
-
return {"error": f"Unable to find vac_config for {vector_name} - {str(e)}"}, 500
|
790
|
-
|
791
|
-
# Process chat history with caching (should be fast)
|
792
|
-
paired_messages = extract_chat_history_with_cache(chat_history)
|
781
|
+
raise ValueError(f"Unable to find vac_config for {vector_name} - {str(e)}")
|
793
782
|
|
794
|
-
#
|
783
|
+
# Initialize trace variables
|
795
784
|
trace = None
|
796
785
|
span = None
|
797
786
|
if self.add_langfuse_eval:
|
787
|
+
trace_id = data.get('trace_id')
|
788
|
+
# Create trace in background - don't block
|
798
789
|
trace_future = _thread_pool.submit(self._create_langfuse_trace_background, request, vector_name, trace_id)
|
799
|
-
|
790
|
+
|
791
|
+
# Extract data (keep original logic)
|
792
|
+
user_input = data.pop('user_input').strip()
|
793
|
+
stream_wait_time = data.pop('stream_wait_time', 7)
|
794
|
+
stream_timeout = data.pop('stream_timeout', 120)
|
795
|
+
chat_history = data.pop('chat_history', None)
|
796
|
+
eval_percent = data.pop('eval_percent', 0.01)
|
797
|
+
vector_name_param = data.pop('vector_name', vector_name)
|
798
|
+
data.pop('trace_id', None) # to ensure not in kwargs
|
799
|
+
|
800
|
+
# Process chat history with caching
|
801
|
+
paired_messages = extract_chat_history_with_cache(chat_history)
|
800
802
|
|
801
803
|
# Wait for file upload if it was started (with timeout)
|
802
804
|
if "_upload_future" in data:
|
@@ -823,7 +825,7 @@ if __name__ == "__main__":
|
|
823
825
|
# Try to get trace result if available (don't block long)
|
824
826
|
if self.add_langfuse_eval:
|
825
827
|
try:
|
826
|
-
trace = trace_future.result(timeout=0.
|
828
|
+
trace = trace_future.result(timeout=0.1) # Very short timeout
|
827
829
|
if trace:
|
828
830
|
this_vac_config = vac_config.configs_by_kind.get("vacConfig")
|
829
831
|
metadata_config = None
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|