Private
Public Access
0
0

rm tmp files

This commit is contained in:
2026-05-16 01:23:30 -04:00
parent 20054b0476
commit 3c51af9bcf
2 changed files with 0 additions and 107 deletions
-102
View File
@@ -1,102 +0,0 @@
def _api_generate(controller: 'AppController', req: GenerateRequest) -> dict[str, Any]:
"""
Triggers an AI generation request using the current project context.
[SDM: src/app_controller.py:_api_generate]
"""
if not req.prompt.strip():
raise HTTPException(status_code=400, detail="Prompt cannot be empty")
with controller._send_thread_lock:
start_time = time.time()
try:
# 1. Build context
from src import aggregate
full_md, path, file_items, stable_md, disc_text = controller._do_generate()
controller._last_stable_md = stable_md
controller.last_md = md
controller.last_md_path = path
controller.last_file_items = file_items
user_msg = req.prompt
# 2. RAG Retrieval
if controller.rag_engine and controller.rag_config and controller.rag_config.enabled:
try:
chunks = controller.rag_engine.search(user_msg)
if chunks:
context_block = "## Retrieved Context\n\n"
for i, chunk in enumerate(chunks):
path = chunk.get("metadata", {}).get("path", "unknown")
context_block += f"### Chunk {i+1} (Source: {path})\n{chunk.get('document', '')}\n\n"
user_msg = context_block + user_msg
except Exception as e:
sys.stderr.write(f"RAG search error: {e}\n")
sys.stderr.flush()
# 3. Symbol Resolution
try:
from src.markdown_helper import parse_symbols, get_symbol_definition
symbols = parse_symbols(user_msg)
file_paths = [f.path if hasattr(f, "path") else f.get("path") if isinstance(f, dict) else str(f) for f in controller.last_file_items]
for symbol in symbols:
res = get_symbol_definition(symbol, file_paths)
if res:
file_path, definition, line = res
user_msg += f'\n\n[Definition: {symbol} from {file_path} (line {line})]\n```python\n{definition}\n```'
except Exception as e:
sys.stderr.write(f"Symbol resolution error: {e}\n")
sys.stderr.flush()
base_dir = controller.active_project_root
csp = filter(bool, [controller.ui_global_system_prompt.strip(), controller.ui_project_system_prompt.strip()])
ai_client.set_custom_system_prompt("\n\n".join(csp))
ai_client.set_base_system_prompt(controller.ui_base_system_prompt)
ai_client.set_use_default_base_prompt(controller.ui_use_default_base_prompt)
ai_client.set_project_context_marker(controller.ui_project_context_marker)
temp = req.temperature if req.temperature is not None else controller.temperature
top_p = req.top_p if req.top_p is not None else controller.top_p
tokens = req.max_tokens if req.max_tokens is not None else controller.max_tokens
ai_client.set_model_params(temp, tokens, controller.history_trunc_limit, top_p)
ai_client.set_agent_tools(controller.ui_agent_tools)
if req.auto_add_history:
with controller._pending_history_adds_lock:
controller._pending_history_adds.append({
"role": "User",
"content": user_msg,
"collapsed": True,
"ts": project_manager.now_ts()
})
try:
resp = ai_client.send(stable_md, user_msg, base_dir, controller.last_file_items, disc_text, rag_engine=None)
if req.auto_add_history:
with controller._pending_history_adds_lock:
controller._pending_history_adds.append({
"role": "AI",
"content": resp,
"collapsed": True,
"ts": project_manager.now_ts()
})
controller._recalculate_session_usage()
duration = time.time() - start_time
return {
"text": resp,
"metadata": {
"provider": controller.current_provider,
"model": controller.current_model,
"duration_sec": round(duration, 3),
"timestamp": project_manager.now_ts()
},
"usage": controller.session_usage
}
except ai_client.ProviderError as e:
raise HTTPException(status_code=500, detail=e.ui_message())
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
except Exception as e:
import traceback
traceback.print_exc()
raise HTTPException(status_code=500, detail=str(e))
-5
View File
@@ -1,5 +0,0 @@
def __setattr__(self, name: str, value: Any) -> None:
if name != 'controller' and hasattr(self, 'controller') and hasattr(self.controller, name):
setattr(self.controller, name, value)
else:
object.__setattr__(self, name, value)