Private
Public Access
0
0

starting human review of ai_client

This commit is contained in:
2026-06-12 20:51:55 -04:00
parent b0f31a84bd
commit 6aafac5d2f
+20 -32
View File
@@ -65,11 +65,11 @@ from src.module_loader import _require_warmed # noqa: E402,F401
from src.result_types import ErrorInfo, ErrorKind, Result # noqa: E402,F401 from src.result_types import ErrorInfo, ErrorKind, Result # noqa: E402,F401
_provider: str = "gemini" _provider: str = "gemini"
_model: str = "gemini-2.5-flash-lite" _model: str = "gemini-2.5-flash-lite"
_temperature: float = 0.0 _temperature: float = 0.0
_top_p: float = 1.0 _top_p: float = 1.0
_max_tokens: int = 8192 _max_tokens: int = 8192
_history_trunc_limit: int = 8000 _history_trunc_limit: int = 8000
@@ -84,10 +84,10 @@ def set_model_params(temp: float, max_tok: int, trunc_limit: int = 8000, top_p:
[C: src/app_controller.py:AppController._handle_request_event, src/app_controller.py:_api_generate] [C: src/app_controller.py:AppController._handle_request_event, src/app_controller.py:_api_generate]
""" """
global _temperature, _max_tokens, _history_trunc_limit, _top_p global _temperature, _max_tokens, _history_trunc_limit, _top_p
_temperature = temp _temperature = temp
_max_tokens = max_tok _max_tokens = max_tok
_history_trunc_limit = trunc_limit _history_trunc_limit = trunc_limit
_top_p = top_p _top_p = top_p
_gemini_client: Optional[genai.Client] = None _gemini_client: Optional[genai.Client] = None
_gemini_chat: Any = None _gemini_chat: Any = None
@@ -100,25 +100,25 @@ _gemini_cached_file_paths: list[str] = []
# proactively rebuilt at 90% of this value to avoid stale-reference errors. # proactively rebuilt at 90% of this value to avoid stale-reference errors.
_GEMINI_CACHE_TTL: int = 3600 _GEMINI_CACHE_TTL: int = 3600
_anthropic_client: Optional[anthropic.Anthropic] = None _anthropic_client: Optional[anthropic.Anthropic] = None
_anthropic_history: list[dict[str, Any]] = [] _anthropic_history: list[dict[str, Any]] = []
_anthropic_history_lock: threading.Lock = threading.Lock() _anthropic_history_lock: threading.Lock = threading.Lock()
_deepseek_client: Any = None _deepseek_client: Any = None
_deepseek_history: list[dict[str, Any]] = [] _deepseek_history: list[dict[str, Any]] = []
_deepseek_history_lock: threading.Lock = threading.Lock() _deepseek_history_lock: threading.Lock = threading.Lock()
_minimax_client: Any = None _minimax_client: Any = None
_minimax_history: list[dict[str, Any]] = [] _minimax_history: list[dict[str, Any]] = []
_minimax_history_lock: threading.Lock = threading.Lock() _minimax_history_lock: threading.Lock = threading.Lock()
_qwen_client: Any = None _qwen_client: Any = None
_qwen_history: list[dict[str, Any]] = [] _qwen_history: list[dict[str, Any]] = []
_qwen_history_lock: threading.Lock = threading.Lock() _qwen_history_lock: threading.Lock = threading.Lock()
_qwen_region: str = "china" _qwen_region: str = "china"
_grok_client: Any = None _grok_client: Any = None
_grok_history: list[dict[str, Any]] = [] _grok_history: list[dict[str, Any]] = []
_grok_history_lock: threading.Lock = threading.Lock() _grok_history_lock: threading.Lock = threading.Lock()
_llama_client: Any = None _llama_client: Any = None
@@ -206,23 +206,14 @@ def set_custom_system_prompt(prompt: str) -> None:
_custom_system_prompt = prompt _custom_system_prompt = prompt
def set_base_system_prompt(prompt: str) -> None: def set_base_system_prompt(prompt: str) -> None:
"""
[C: src/app_controller.py:AppController._do_generate, src/app_controller.py:AppController._handle_request_event, src/app_controller.py:_api_generate, tests/test_system_prompt_exposure.py:TestSystemPromptExposure.setUp, tests/test_system_prompt_exposure.py:TestSystemPromptExposure.test_ai_client_get_combined_respects_use_default, tests/test_system_prompt_exposure.py:TestSystemPromptExposure.test_ai_client_set_base_overrides_when_default_false]
"""
global _base_system_prompt_override global _base_system_prompt_override
_base_system_prompt_override = prompt _base_system_prompt_override = prompt
def set_use_default_base_prompt(use_default: bool) -> None: def set_use_default_base_prompt(use_default: bool) -> None:
"""
[C: src/app_controller.py:AppController._do_generate, src/app_controller.py:AppController._handle_request_event, src/app_controller.py:_api_generate, tests/test_system_prompt_exposure.py:TestSystemPromptExposure.setUp, tests/test_system_prompt_exposure.py:TestSystemPromptExposure.test_ai_client_get_combined_respects_use_default, tests/test_system_prompt_exposure.py:TestSystemPromptExposure.test_ai_client_set_base_overrides_when_default_false]
"""
global _use_default_base_system_prompt global _use_default_base_system_prompt
_use_default_base_system_prompt = use_default _use_default_base_system_prompt = use_default
def set_project_context_marker(marker: str) -> None: def set_project_context_marker(marker: str) -> None:
"""
[C: src/app_controller.py:AppController._do_generate, src/app_controller.py:AppController._handle_request_event, src/app_controller.py:_api_generate]
"""
global _project_context_marker global _project_context_marker
_project_context_marker = marker _project_context_marker = marker
@@ -230,9 +221,6 @@ def _get_context_marker() -> str:
return _project_context_marker if _project_context_marker.strip() else "[SYSTEM: FILES UPDATED]" return _project_context_marker if _project_context_marker.strip() else "[SYSTEM: FILES UPDATED]"
def _get_combined_system_prompt(preset: Optional[ToolPreset] = None, bias: Optional[BiasProfile] = None) -> str: def _get_combined_system_prompt(preset: Optional[ToolPreset] = None, bias: Optional[BiasProfile] = None) -> str:
"""
[C: tests/test_bias_efficacy.py:test_bias_efficacy_prompt_generation, tests/test_bias_integration.py:test_system_prompt_biasing, tests/test_system_prompt_exposure.py:TestSystemPromptExposure.test_ai_client_get_combined_respects_use_default, tests/test_system_prompt_exposure.py:TestSystemPromptExposure.test_ai_client_set_base_overrides_when_default_false]
"""
if preset is None: preset = _active_tool_preset if preset is None: preset = _active_tool_preset
if bias is None: bias = _active_bias_profile if bias is None: bias = _active_bias_profile
if _use_default_base_system_prompt: if _use_default_base_system_prompt:
@@ -2773,12 +2761,12 @@ def send_result(
stream, pre_tool_callback, qa_callback, stream_callback, patch_callback stream, pre_tool_callback, qa_callback, stream_callback, patch_callback
) )
elif p == "llama": elif p == "llama":
res = _send_llama_result( res = _send_llama(
md_content, user_message, base_dir, file_items, discussion_history, md_content, user_message, base_dir, file_items, discussion_history,
stream, pre_tool_callback, qa_callback, stream_callback, patch_callback stream, pre_tool_callback, qa_callback, stream_callback, patch_callback
) )
elif p == "grok": elif p == "grok":
res = _send_grok_result( res = _send_grok(
md_content, user_message, base_dir, file_items, discussion_history, md_content, user_message, base_dir, file_items, discussion_history,
stream, pre_tool_callback, qa_callback, stream_callback, patch_callback stream, pre_tool_callback, qa_callback, stream_callback, patch_callback
) )