Update app/services/chat_service.py
Browse files- 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 |
-
|
| 40 |
-
|
|
|
|
|
|
|
| 41 |
## Main Answer
|
| 42 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
## Additional Notes
|
| 61 |
-
[
|
| 62 |
-
|
|
|
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|