garvitcpp commited on
Commit
3cc91c2
·
verified ·
1 Parent(s): 5575d19

Update app/services/chat_service.py

Browse files
Files changed (1) hide show
  1. app/services/chat_service.py +50 -22
app/services/chat_service.py CHANGED
@@ -33,41 +33,69 @@ class ChatService:
33
  context = self.prepare_context(code_chunks)
34
 
35
  prompt = f"""You are an expert code assistant analyzing the {repository_name} repository.
 
36
  User Question: {query}
 
37
  Code Context:
38
  {context}
39
- RESPONSE FORMAT:
40
- Use clean, professional markdown formatting similar to GitHub README files:
 
 
41
  ## Main Answer
42
- [Direct answer to the user's question]
 
 
 
 
43
  ## Implementation Overview
44
- [High-level explanation of how the feature/system works]
45
  ### Key Components
46
- - **Component Name**: Brief description (`filename.py`, lines X-Y)
47
- - **Component Name**: Brief description (`filename.py`, lines X-Y)
48
  ### Technical Details
49
- [Detailed explanation with code references]
50
- When referencing code:
51
- - Use **bold** for important file names and concepts
52
- - Use `backticks` for functions, variables, classes, and code snippets
53
- - Reference specific files and line numbers: `filename.py` (lines X-Y)
54
- - Use > blockquotes for important insights or warnings
55
  ### How It Works
56
- 1. **Step 1**: Description of first step
57
- 2. **Step 2**: Description of second step
58
- 3. **Step 3**: Description of third step
59
- > **Key Insight**: Important observations about the implementation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  ## Additional Notes
61
- [Any limitations, missing information, or recommendations]
62
- REQUIREMENTS:
 
63
  - NO emojis - use clean text only
 
 
 
 
 
64
  - Be comprehensive and detailed
65
- - Reference specific files and line numbers
66
  - Explain both WHAT the code does and HOW it works
67
- - Use proper markdown hierarchy (##, ###, -, >, etc.)
68
- - Focus on explanation rather than just code listing
69
  - Professional documentation style
70
- Your detailed markdown analysis:"""
 
 
 
 
 
71
 
72
  response = self.model.generate_content(prompt)
73
 
 
33
  context = self.prepare_context(code_chunks)
34
 
35
  prompt = f"""You are an expert code assistant analyzing the {repository_name} repository.
36
+
37
  User Question: {query}
38
+
39
  Code Context:
40
  {context}
41
+
42
+ RESPONSE STRUCTURE:
43
+
44
+ 1. ALWAYS start with:
45
  ## Main Answer
46
+ [Provide a direct, concise answer to the user's question first]
47
+
48
+ 2. Then adapt the rest based on query type:
49
+
50
+ FOR CODE EXPLANATION/ARCHITECTURE QUERIES:
51
  ## Implementation Overview
 
52
  ### Key Components
 
 
53
  ### Technical Details
 
 
 
 
 
 
54
  ### How It Works
55
+
56
+ FOR DEBUGGING/ERROR QUERIES:
57
+ ## Root Cause Analysis
58
+ ## Affected Code
59
+ ## Suggested Solution
60
+ ## Prevention Tips
61
+
62
+ FOR DOCUMENTATION/README REQUESTS:
63
+ ## Overview
64
+ ## Installation
65
+ ## Usage
66
+ ## Configuration
67
+ [Standard README sections as appropriate]
68
+
69
+ FOR "HOW TO" QUERIES:
70
+ ## Step-by-Step Guide
71
+ ## Code Examples
72
+ ## Best Practices
73
+
74
+ FOR FEATURE REQUESTS/SUGGESTIONS:
75
+ ## Current Implementation
76
+ ## Proposed Approach
77
+ ## Implementation Steps
78
+
79
+ Always end with:
80
  ## Additional Notes
81
+ [Limitations, missing information, or recommendations if relevant]
82
+
83
+ UNIVERSAL FORMATTING RULES (MANDATORY):
84
  - NO emojis - use clean text only
85
+ - Use **bold** for important file names and concepts
86
+ - Use `backticks` for functions, variables, classes, and code snippets
87
+ - ALWAYS reference specific files and line numbers: `filename.py` (lines X-Y)
88
+ - Use > blockquotes for important insights or warnings
89
+ - Use proper markdown hierarchy (##, ###, -, >, etc.)
90
  - Be comprehensive and detailed
 
91
  - Explain both WHAT the code does and HOW it works
 
 
92
  - Professional documentation style
93
+ - Focus on explanation rather than just code listing
94
+ - Clean, professional markdown formatting (GitHub README style)
95
+
96
+ CRITICAL: Every code reference MUST include the file path and line numbers from the context provided above.
97
+
98
+ Your detailed markdown response:"""
99
 
100
  response = self.model.generate_content(prompt)
101