AUXteam commited on
Commit
8c297cc
·
verified ·
1 Parent(s): fc10d08

Upload folder using huggingface_hub

Browse files
CriticalThinking/app/api/router.py CHANGED
@@ -15,7 +15,7 @@ router = APIRouter()
15
  tasks: Dict[str, Any] = {}
16
 
17
  class AnalyzeRequest(BaseModel):
18
- repo_url: str
19
  project_description: Optional[str] = "Generic software project"
20
 
21
  class AnalyzeResponse(BaseModel):
@@ -32,8 +32,9 @@ async def run_analysis_task(task_id: str, repo_url: str, project_description: st
32
  matcher = HFMatcher()
33
  web_researcher = WebResearcher()
34
 
35
- # 1. Index
36
- indexer.index_repository(repo_url)
 
37
 
38
  # 2. Analyze
39
  analysis_results = orchestrator.run_analysis(project_description)
 
15
  tasks: Dict[str, Any] = {}
16
 
17
  class AnalyzeRequest(BaseModel):
18
+ repo_url: Optional[str] = None
19
  project_description: Optional[str] = "Generic software project"
20
 
21
  class AnalyzeResponse(BaseModel):
 
32
  matcher = HFMatcher()
33
  web_researcher = WebResearcher()
34
 
35
+ # 1. Index (if repo_url is provided)
36
+ if repo_url:
37
+ indexer.index_repository(repo_url)
38
 
39
  # 2. Analyze
40
  analysis_results = orchestrator.run_analysis(project_description)
CriticalThinking/app/services/agent_orchestrator.py CHANGED
@@ -87,7 +87,11 @@ class AgentOrchestrator:
87
  sub_q = step.get("sub_question")
88
  # Search codebase
89
  results = self.indexer.search(sub_q, limit=3)
90
- context = "\n---\n".join([r.get("text", "") for r in results])
 
 
 
 
91
 
92
  # Analyze
93
  analysis = self.analyzer.analyze(context)
 
87
  sub_q = step.get("sub_question")
88
  # Search codebase
89
  results = self.indexer.search(sub_q, limit=3)
90
+ if results:
91
+ context = "\n---\n".join([r.get("text", "") for r in results])
92
+ else:
93
+ # If no code results, use the sub-question itself as context for conceptual analysis
94
+ context = f"No code snippets found for: {sub_q}. Analyzing based on project overview: {project_overview}"
95
 
96
  # Analyze
97
  analysis = self.analyzer.analyze(context)
CriticalThinking/app/services/improvement_agent.py CHANGED
@@ -4,11 +4,12 @@ from app.services.agent_orchestrator import BaseAgent
4
  class ImprovementAgent(BaseAgent):
5
  def generate_improvements(self, weaknesses: List[str]) -> Dict[str, Any]:
6
  system_prompt = """You are an AI research scientist and senior architect.
7
- Your goal is to generate impactful and creative ideas for improving a codebase.
8
  Consider:
9
- - Refactoring for better scalability.
10
- - Replacing custom implementations with state-of-the-art Hugging Face models or open-source projects.
11
- - Improving performance and maintainability."""
 
12
  user_prompt = f"Given these weaknesses:\n{weaknesses}\n\nPropose a next-step improvement roadmap. Respond in JSON with format:\n{{\n 'improvements': [\n {{\n 'weakness': 'the identified weakness',\n 'proposal': 'detailed improvement plan',\n 'replacement_search_query': 'query for Hugging Face or GitHub',\n 'interestingness': 1-10,\n 'feasibility': 1-10\n }}\n ]\n}}"
13
  return self._get_response(system_prompt, user_prompt, response_format={"type": "json_object"})
14
 
 
4
  class ImprovementAgent(BaseAgent):
5
  def generate_improvements(self, weaknesses: List[str]) -> Dict[str, Any]:
6
  system_prompt = """You are an AI research scientist and senior architect.
7
+ Your goal is to generate impactful and creative ideas for improving a codebase or designing a new one.
8
  Consider:
9
+ - Decomposing the project into independent, modular components.
10
+ - Suggesting state-of-the-art Hugging Face models (Spaces/Models) or GitHub projects to serve as functional components.
11
+ - Ensuring components communicate via FastAPI endpoints.
12
+ - Replacing custom implementations with existing open-source projects to reduce maintenance."""
13
  user_prompt = f"Given these weaknesses:\n{weaknesses}\n\nPropose a next-step improvement roadmap. Respond in JSON with format:\n{{\n 'improvements': [\n {{\n 'weakness': 'the identified weakness',\n 'proposal': 'detailed improvement plan',\n 'replacement_search_query': 'query for Hugging Face or GitHub',\n 'interestingness': 1-10,\n 'feasibility': 1-10\n }}\n ]\n}}"
14
  return self._get_response(system_prompt, user_prompt, response_format={"type": "json_object"})
15
 
README.md CHANGED
@@ -7,7 +7,6 @@ sdk: docker
7
  pinned: false
8
  app_port: 7860
9
  ---
10
-
11
  <h1 align="center">
12
  <a href="https://github.com/SakanaAI/AI-Scientist/blob/main/docs/logo_2.png">
13
  <img src="docs/logo_2.png" width="215" /></a><br>
 
7
  pinned: false
8
  app_port: 7860
9
  ---
 
10
  <h1 align="center">
11
  <a href="https://github.com/SakanaAI/AI-Scientist/blob/main/docs/logo_2.png">
12
  <img src="docs/logo_2.png" width="215" /></a><br>
hf_app.py CHANGED
@@ -16,7 +16,7 @@ with gr.Blocks(title="Critical Code Agent") as demo:
16
  gr.Markdown("Autonomous agent system for deep architectural analysis and software weakness identification.")
17
 
18
  with gr.Row():
19
- repo_url = gr.Textbox(label="Repository URL", placeholder="https://github.com/username/repo")
20
  project_desc = gr.Textbox(label="Project Description", placeholder="Brief description of the project")
21
 
22
  analyze_btn = gr.Button("Analyze Repository", variant="primary")
 
16
  gr.Markdown("Autonomous agent system for deep architectural analysis and software weakness identification.")
17
 
18
  with gr.Row():
19
+ repo_url = gr.Textbox(label="Repository URL (Optional)", placeholder="https://github.com/username/repo")
20
  project_desc = gr.Textbox(label="Project Description", placeholder="Brief description of the project")
21
 
22
  analyze_btn = gr.Button("Analyze Repository", variant="primary")