sunholo 0.140.10__tar.gz → 0.140.11__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.10/src/sunholo.egg-info → sunholo-0.140.11}/PKG-INFO +1 -1
- {sunholo-0.140.10 → sunholo-0.140.11}/pyproject.toml +1 -1
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/flask/vac_routes.py +105 -149
- {sunholo-0.140.10 → sunholo-0.140.11/src/sunholo.egg-info}/PKG-INFO +1 -1
- {sunholo-0.140.10 → sunholo-0.140.11}/LICENSE.txt +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/MANIFEST.in +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/README.md +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/setup.cfg +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/chat_history.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/dispatch_to_qa.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/fastapi/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/fastapi/base.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/fastapi/qna_routes.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/flask/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/flask/base.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/langserve.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/pubsub.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/route.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/special_commands.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/agents/swagger.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/archive/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/archive/archive.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/auth/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/auth/gcloud.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/auth/refresh.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/auth/run.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/azure/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/azure/auth.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/azure/blobs.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/azure/event_grid.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/bots/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/bots/discord.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/bots/github_webhook.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/bots/webapp.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/chunker/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/chunker/azure.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/chunker/doc_handling.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/chunker/encode_metadata.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/chunker/images.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/chunker/loaders.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/chunker/message_data.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/chunker/pdfs.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/chunker/process_chunker_data.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/chunker/publish.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/chunker/pubsub.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/chunker/splitter.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/cli/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/cli/chat_vac.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/cli/cli.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/cli/cli_init.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/cli/configs.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/cli/deploy.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/cli/embedder.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/cli/merge_texts.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/cli/run_proxy.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/cli/sun_rich.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/cli/swagger.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/cli/vertex.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/components/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/components/llm.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/components/retriever.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/components/vectorstore.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/custom_logging.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/alloydb.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/alloydb_client.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/database.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/lancedb.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/sql/sb/create_function.sql +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/sql/sb/create_function_time.sql +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/sql/sb/create_table.sql +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/sql/sb/delete_source_row.sql +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/sql/sb/return_sources.sql +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/sql/sb/setup.sql +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/static_dbs.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/database/uuid.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/discovery_engine/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/discovery_engine/chunker_handler.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/discovery_engine/cli.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/discovery_engine/create_new.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/discovery_engine/discovery_engine_client.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/discovery_engine/get_ai_search_chunks.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/embedder/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/embedder/embed_chunk.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/embedder/embed_metadata.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/excel/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/excel/plugin.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/gcs/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/gcs/add_file.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/gcs/download_folder.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/gcs/download_gcs_text.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/gcs/download_url.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/gcs/extract_and_sign.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/gcs/metadata.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/genai/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/genai/file_handling.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/genai/genaiv2.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/genai/images.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/genai/init.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/genai/process_funcs_cls.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/genai/safety.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/invoke/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/invoke/async_class.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/invoke/direct_vac_func.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/invoke/invoke_vac_utils.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/langchain_types.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/langfuse/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/langfuse/callback.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/langfuse/evals.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/langfuse/prompts.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/llamaindex/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/llamaindex/get_files.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/llamaindex/import_files.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/llamaindex/llamaindex_class.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/llamaindex/user_history.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/lookup/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/lookup/model_lookup.yaml +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/mcp/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/mcp/cli.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/ollama/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/ollama/ollama_images.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/pubsub/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/pubsub/process_pubsub.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/pubsub/pubsub_manager.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/qna/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/qna/parsers.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/qna/retry.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/senses/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/senses/stream_voice.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/streaming/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/streaming/content_buffer.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/streaming/langserve.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/streaming/stream_lookup.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/streaming/streaming.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/summarise/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/summarise/summarise.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/agent/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/agent/agent_service.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/agent/app.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/agent/my_log.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/agent/tools/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/agent/tools/your_agent.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/agent/vac_service.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/project/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/project/app.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/project/my_log.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/project/vac_service.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/system_services/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/system_services/app.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/templates/system_services/my_log.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/terraform/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/terraform/tfvars_editor.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/tools/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/tools/web_browser.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/api_key.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/big_context.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/config.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/config_class.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/config_schema.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/gcp.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/gcp_project.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/mime.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/parsers.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/timedelta.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/user_ids.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/utils/version.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/vertex/__init__.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/vertex/extensions_call.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/vertex/extensions_class.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/vertex/genai_functions.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/vertex/init.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/vertex/memory_tools.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/vertex/safety.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/vertex/type_dict_to_json.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo.egg-info/SOURCES.txt +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo.egg-info/dependency_links.txt +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo.egg-info/entry_points.txt +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo.egg-info/requires.txt +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo.egg-info/top_level.txt +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/tests/test_async.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/tests/test_async_genai2.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/tests/test_chat_history.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/tests/test_config.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/tests/test_genai2.py +0 -0
- {sunholo-0.140.10 → sunholo-0.140.11}/tests/test_unstructured.py +0 -0
@@ -6,10 +6,6 @@ import random
|
|
6
6
|
from functools import partial
|
7
7
|
import inspect
|
8
8
|
import asyncio
|
9
|
-
import time
|
10
|
-
import threading
|
11
|
-
from functools import lru_cache
|
12
|
-
from concurrent.futures import ThreadPoolExecutor
|
13
9
|
|
14
10
|
from ..chat_history import extract_chat_history_with_cache, extract_chat_history_async_cached
|
15
11
|
from ...qna.parsers import parse_output
|
@@ -36,11 +32,6 @@ except ImportError:
|
|
36
32
|
# Cache dictionary to store validated API keys
|
37
33
|
api_key_cache = {}
|
38
34
|
cache_duration = timedelta(minutes=5) # Cache duration
|
39
|
-
# Global caches and thread pool
|
40
|
-
_config_cache = {}
|
41
|
-
_config_lock = threading.Lock()
|
42
|
-
_thread_pool = ThreadPoolExecutor(max_workers=4)
|
43
|
-
|
44
35
|
|
45
36
|
class VACRoutes:
|
46
37
|
"""
|
@@ -78,44 +69,8 @@ if __name__ == "__main__":
|
|
78
69
|
self.additional_routes = additional_routes if additional_routes is not None else []
|
79
70
|
self.async_stream = async_stream
|
80
71
|
self.add_langfuse_eval = add_langfuse_eval
|
81
|
-
|
82
|
-
# Pre-warm common configs
|
83
|
-
self._preload_common_configs()
|
84
|
-
|
85
72
|
self.register_routes()
|
86
|
-
|
87
|
-
def _preload_common_configs(self):
|
88
|
-
"""Pre-load commonly used configurations to cache"""
|
89
|
-
common_vector_names = ["aitana3"] # Add your common vector names
|
90
|
-
for vector_name in common_vector_names:
|
91
|
-
try:
|
92
|
-
self._get_cached_config(vector_name)
|
93
|
-
log.info(f"Pre-loaded config for {vector_name}")
|
94
|
-
except Exception as e:
|
95
|
-
log.warning(f"Failed to pre-load config for {vector_name}: {e}")
|
96
|
-
|
97
|
-
def _get_cached_config(self, vector_name: str):
|
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
73
|
|
104
|
-
# Need to load config
|
105
|
-
with _config_lock:
|
106
|
-
# Double-check inside lock (another thread might have loaded it)
|
107
|
-
if vector_name in _config_cache:
|
108
|
-
return _config_cache[vector_name]
|
109
|
-
|
110
|
-
try:
|
111
|
-
log.info(f"Loading fresh config for {vector_name}")
|
112
|
-
config = ConfigManager(vector_name)
|
113
|
-
_config_cache[vector_name] = config
|
114
|
-
log.info(f"Cached config for {vector_name}")
|
115
|
-
return config
|
116
|
-
except Exception as e:
|
117
|
-
log.error(f"Error loading config for {vector_name}: {e}")
|
118
|
-
raise
|
119
74
|
|
120
75
|
def vac_interpreter_default(self, question: str, vector_name: str, chat_history=[], **kwargs):
|
121
76
|
# Create a callback that does nothing for streaming if you don't want intermediate outputs
|
@@ -273,18 +228,7 @@ if __name__ == "__main__":
|
|
273
228
|
|
274
229
|
log.info(f"OpenAI response: {openai_response}")
|
275
230
|
return jsonify(openai_response)
|
276
|
-
|
277
|
-
def _finalize_trace_background(self, trace, span, response, all_input):
|
278
|
-
"""Finalize trace operations in background"""
|
279
|
-
try:
|
280
|
-
if span:
|
281
|
-
span.end(output=str(response))
|
282
|
-
if trace:
|
283
|
-
trace.update(output=str(response))
|
284
|
-
self.langfuse_eval_response(trace_id=trace.id, eval_percent=all_input.get('eval_percent'))
|
285
|
-
except Exception as e:
|
286
|
-
log.warning(f"Background trace finalization failed: {e}")
|
287
|
-
|
231
|
+
|
288
232
|
def handle_stream_vac(self, vector_name):
|
289
233
|
observed_stream_interpreter = self.stream_interpreter
|
290
234
|
is_async = inspect.iscoroutinefunction(self.stream_interpreter)
|
@@ -710,131 +654,144 @@ if __name__ == "__main__":
|
|
710
654
|
tags = tags,
|
711
655
|
release = package_version
|
712
656
|
)
|
713
|
-
|
714
|
-
def _create_langfuse_trace_background(self, request, vector_name, trace_id):
|
715
|
-
"""Create Langfuse trace in background"""
|
716
|
-
try:
|
717
|
-
return self.create_langfuse_trace(request, vector_name, trace_id)
|
718
|
-
except Exception as e:
|
719
|
-
log.warning(f"Background trace creation failed: {e}")
|
720
|
-
return None
|
721
657
|
|
722
|
-
def _handle_file_upload_background(self, file, vector_name):
|
723
|
-
"""Handle file upload in background thread"""
|
724
|
-
try:
|
725
|
-
# Save with timestamp to avoid conflicts
|
726
|
-
temp_filename = f"temp_{int(time.time() * 1000)}_{file.filename}"
|
727
|
-
file.save(temp_filename)
|
728
|
-
|
729
|
-
# Upload to GCS
|
730
|
-
image_uri = add_file_to_gcs(temp_filename, vector_name)
|
731
|
-
|
732
|
-
# Clean up
|
733
|
-
os.remove(temp_filename)
|
734
|
-
|
735
|
-
return {"image_uri": image_uri, "mime": file.mimetype}
|
736
|
-
except Exception as e:
|
737
|
-
log.error(f"Background file upload failed: {e}")
|
738
|
-
return {}
|
739
|
-
|
740
658
|
def prep_vac(self, request, vector_name):
|
741
|
-
|
742
|
-
|
743
|
-
# Fast request parsing - KEEP ORIGINAL ERROR HANDLING STYLE
|
659
|
+
|
744
660
|
if request.content_type.startswith('application/json'):
|
745
661
|
data = request.get_json()
|
746
662
|
elif request.content_type.startswith('multipart/form-data'):
|
747
663
|
data = request.form.to_dict()
|
748
|
-
# Handle file upload in background if present
|
749
664
|
if 'file' in request.files:
|
750
665
|
file = request.files['file']
|
751
666
|
if file.filename != '':
|
752
|
-
log.info(f"Found file: {file.filename}
|
753
|
-
|
754
|
-
|
755
|
-
|
667
|
+
log.info(f"Found file: {file.filename} to upload to GCS")
|
668
|
+
try:
|
669
|
+
image_uri, mime_type = self.handle_file_upload(file, vector_name)
|
670
|
+
data["image_uri"] = image_uri
|
671
|
+
data["mime"] = mime_type
|
672
|
+
except Exception as e:
|
673
|
+
log.error(traceback.format_exc())
|
674
|
+
return jsonify({'error': str(e), 'traceback': traceback.format_exc()}), 500
|
675
|
+
else:
|
676
|
+
log.error("No file selected")
|
677
|
+
return jsonify({"error": "No file selected"}), 400
|
756
678
|
else:
|
757
|
-
|
758
|
-
raise ValueError("Unsupported content type")
|
679
|
+
return jsonify({"error": "Unsupported content type"}), 400
|
759
680
|
|
760
|
-
log.info(f"vac/{vector_name} got data
|
681
|
+
log.info(f"vac/{vector_name} got data: {data}")
|
761
682
|
|
762
|
-
|
683
|
+
trace = None
|
684
|
+
span = None
|
685
|
+
if self.add_langfuse_eval:
|
686
|
+
trace_id = data.get('trace_id')
|
687
|
+
trace = self.create_langfuse_trace(request, vector_name, trace_id)
|
688
|
+
log.info(f"Using existing langfuse trace: {trace_id}")
|
689
|
+
|
690
|
+
#config, _ = load_config("config/llm_config.yaml")
|
763
691
|
try:
|
764
|
-
vac_config =
|
692
|
+
vac_config = ConfigManager(vector_name)
|
765
693
|
except Exception as e:
|
766
694
|
raise ValueError(f"Unable to find vac_config for {vector_name} - {str(e)}")
|
767
695
|
|
768
|
-
|
696
|
+
if trace:
|
697
|
+
this_vac_config = vac_config.configs_by_kind.get("vacConfig")
|
698
|
+
metadata_config=None
|
699
|
+
if this_vac_config:
|
700
|
+
metadata_config = this_vac_config.get(vector_name)
|
701
|
+
|
702
|
+
trace.update(input=data, metadata=metadata_config)
|
703
|
+
|
769
704
|
user_input = data.pop('user_input').strip()
|
770
705
|
stream_wait_time = data.pop('stream_wait_time', 7)
|
771
706
|
stream_timeout = data.pop('stream_timeout', 120)
|
772
707
|
chat_history = data.pop('chat_history', None)
|
773
708
|
eval_percent = data.pop('eval_percent', 0.01)
|
774
|
-
|
775
|
-
data.pop('trace_id', None)
|
709
|
+
vector_name = data.pop('vector_name', vector_name)
|
710
|
+
data.pop('trace_id', None) # to ensure not in kwargs
|
776
711
|
|
777
|
-
# Process chat history with caching
|
778
712
|
paired_messages = extract_chat_history_with_cache(chat_history)
|
779
713
|
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
714
|
+
all_input = {'user_input': user_input,
|
715
|
+
'vector_name': vector_name,
|
716
|
+
'chat_history': paired_messages,
|
717
|
+
'stream_wait_time': stream_wait_time,
|
718
|
+
'stream_timeout': stream_timeout,
|
719
|
+
'eval_percent': eval_percent,
|
720
|
+
'kwargs': data}
|
721
|
+
|
722
|
+
if trace:
|
723
|
+
span = trace.span(
|
724
|
+
name="VAC",
|
725
|
+
metadata=vac_config.configs_by_kind,
|
726
|
+
input = all_input
|
727
|
+
)
|
728
|
+
|
729
|
+
return {
|
730
|
+
"trace": trace,
|
731
|
+
"span": span,
|
732
|
+
"all_input": all_input,
|
733
|
+
"vac_config": vac_config
|
734
|
+
}
|
790
735
|
|
791
|
-
|
736
|
+
async def prep_vac_async(self, request, vector_name):
|
737
|
+
"""Async version of prep_vac."""
|
738
|
+
# Parse request data
|
739
|
+
if request.content_type.startswith('application/json'):
|
740
|
+
data = request.get_json()
|
741
|
+
elif request.content_type.startswith('multipart/form-data'):
|
742
|
+
data = request.form.to_dict()
|
743
|
+
if 'file' in request.files:
|
744
|
+
file = request.files['file']
|
745
|
+
if file.filename != '':
|
746
|
+
log.info(f"Found file: {file.filename} to upload to GCS")
|
747
|
+
try:
|
748
|
+
# Make file upload async if possible
|
749
|
+
image_uri, mime_type = await self.handle_file_upload_async(file, vector_name)
|
750
|
+
data["image_uri"] = image_uri
|
751
|
+
data["mime"] = mime_type
|
752
|
+
except Exception as e:
|
753
|
+
log.error(traceback.format_exc())
|
754
|
+
return jsonify({'error': str(e), 'traceback': traceback.format_exc()}), 500
|
755
|
+
else:
|
756
|
+
log.error("No file selected")
|
757
|
+
return jsonify({"error": "No file selected"}), 400
|
758
|
+
else:
|
759
|
+
return jsonify({"error": "Unsupported content type"}), 400
|
760
|
+
|
761
|
+
log.info(f"vac/{vector_name} got data: {data}")
|
762
|
+
|
763
|
+
# Run these operations concurrently
|
764
|
+
tasks = []
|
765
|
+
|
766
|
+
# Extract other data while configs load
|
767
|
+
user_input = data.pop('user_input').strip()
|
768
|
+
stream_wait_time = data.pop('stream_wait_time', 7)
|
769
|
+
stream_timeout = data.pop('stream_timeout', 120)
|
770
|
+
chat_history = data.pop('chat_history', None)
|
771
|
+
vector_name_param = data.pop('vector_name', vector_name)
|
772
|
+
data.pop('trace_id', None) # to ensure not in kwargs
|
773
|
+
|
774
|
+
# Task 3: Process chat history
|
775
|
+
chat_history_task = asyncio.create_task(extract_chat_history_async_cached(chat_history))
|
776
|
+
tasks.append(chat_history_task)
|
777
|
+
|
778
|
+
# Await all tasks concurrently
|
779
|
+
results = await asyncio.gather(*tasks, return_exceptions=True)
|
780
|
+
|
781
|
+
paired_messages = results[0] if not isinstance(results[0], Exception) else []
|
782
|
+
|
783
|
+
# Only create span after we have trace
|
792
784
|
all_input = {
|
793
785
|
'user_input': user_input,
|
794
786
|
'vector_name': vector_name_param,
|
795
787
|
'chat_history': paired_messages,
|
796
788
|
'stream_wait_time': stream_wait_time,
|
797
789
|
'stream_timeout': stream_timeout,
|
798
|
-
'eval_percent': eval_percent,
|
799
790
|
'kwargs': data
|
800
791
|
}
|
801
|
-
|
802
|
-
# Initialize trace variables
|
803
|
-
trace = None
|
804
|
-
span = None
|
805
|
-
if self.add_langfuse_eval:
|
806
|
-
trace_id = data.get('trace_id')
|
807
|
-
# Create trace in background - don't block
|
808
|
-
trace_future = _thread_pool.submit(self._create_langfuse_trace_background, request, vector_name, trace_id)
|
809
|
-
|
810
|
-
# Try to get trace result if available (don't block long)
|
811
|
-
try:
|
812
|
-
trace = trace_future.result(timeout=0.1) # Very short timeout
|
813
|
-
if trace:
|
814
|
-
this_vac_config = vac_config.configs_by_kind.get("vacConfig")
|
815
|
-
metadata_config = None
|
816
|
-
if this_vac_config:
|
817
|
-
metadata_config = this_vac_config.get(vector_name)
|
818
|
-
trace.update(input=data, metadata=metadata_config)
|
819
|
-
|
820
|
-
span = trace.span(
|
821
|
-
name="VAC",
|
822
|
-
metadata=vac_config.configs_by_kind,
|
823
|
-
input=all_input
|
824
|
-
)
|
825
|
-
except Exception as e:
|
826
|
-
log.warning(f"Langfuse trace creation timed out or failed: {e}")
|
827
|
-
trace = None
|
828
|
-
span = None
|
829
|
-
|
830
|
-
prep_time = time.time() - start_time
|
831
|
-
log.info(f"prep_vac completed in {prep_time:.3f}s")
|
832
|
-
|
792
|
+
|
833
793
|
return {
|
834
|
-
"
|
835
|
-
"span": span,
|
836
|
-
"all_input": all_input,
|
837
|
-
"vac_config": vac_config
|
794
|
+
"all_input": all_input
|
838
795
|
}
|
839
796
|
|
840
797
|
def handle_file_upload(self, file, vector_name):
|
@@ -846,4 +803,3 @@ if __name__ == "__main__":
|
|
846
803
|
except Exception as e:
|
847
804
|
raise Exception(f'File upload failed: {str(e)}')
|
848
805
|
|
849
|
-
|
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
|
{sunholo-0.140.10 → sunholo-0.140.11}/src/sunholo/discovery_engine/discovery_engine_client.py
RENAMED
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
|