Spaces:
Sleeping
Sleeping
EL GHAFRAOUI AYOUB
commited on
Commit
·
ca1ecaa
1
Parent(s):
6f14d8b
- .gitignore +8 -0
- 0.26.0 +0 -0
- 0.26.0' +0 -0
- alembic.ini +0 -64
- app.log +0 -22
- app/__pycache__/main.cpython-312.pyc +0 -0
- app/controllers/__pycache__/f5_model.cpython-312.pyc +0 -0
- app/controllers/f5_model.py +18 -12
- app/main.py +25 -71
- app/templates/index.html +164 -38
- requirements.txt +7 -1
.gitignore
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.env
|
2 |
+
.DS_Store
|
3 |
+
|
4 |
+
model_cache
|
5 |
+
cache
|
6 |
+
__pycache__
|
7 |
+
|
8 |
+
|
0.26.0
DELETED
File without changes
|
0.26.0'
DELETED
File without changes
|
alembic.ini
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
# A generic, single database configuration.
|
2 |
-
|
3 |
-
[alembic]
|
4 |
-
# Path to migration scripts
|
5 |
-
script_location = alembic
|
6 |
-
|
7 |
-
# Template used to generate migration files
|
8 |
-
# file_template = %%(rev)s_%%(slug)s
|
9 |
-
|
10 |
-
# Sys.path path, will be prepended to sys.path if present.
|
11 |
-
# Defaults to the current working directory.
|
12 |
-
prepend_sys_path = .
|
13 |
-
|
14 |
-
# Version path separator
|
15 |
-
version_path_separator = os # Use os.pathsep. Default configuration used for new projects.
|
16 |
-
|
17 |
-
# Database connection string (SQLite persistent database)
|
18 |
-
sqlalchemy.url = sqlite+aiosqlite:///./sql_app.db
|
19 |
-
|
20 |
-
# Explicitly set pooling to avoid unnecessary resets
|
21 |
-
[sqlalchemy]
|
22 |
-
poolclass = QueuePool
|
23 |
-
|
24 |
-
# Post-migration hooks (optional, can be customized)
|
25 |
-
[post_write_hooks]
|
26 |
-
# hooks = black
|
27 |
-
# black.type = console_scripts
|
28 |
-
# black.entrypoint = black
|
29 |
-
# black.options = -l 79 REVISION_SCRIPT_FILENAME
|
30 |
-
|
31 |
-
# Logging configuration
|
32 |
-
[loggers]
|
33 |
-
keys = root,sqlalchemy,alembic
|
34 |
-
|
35 |
-
[handlers]
|
36 |
-
keys = console
|
37 |
-
|
38 |
-
[formatters]
|
39 |
-
keys = generic
|
40 |
-
|
41 |
-
[logger_root]
|
42 |
-
level = WARN
|
43 |
-
handlers = console
|
44 |
-
qualname =
|
45 |
-
|
46 |
-
[logger_sqlalchemy]
|
47 |
-
level = WARN
|
48 |
-
handlers =
|
49 |
-
qualname = sqlalchemy.engine
|
50 |
-
|
51 |
-
[logger_alembic]
|
52 |
-
level = INFO
|
53 |
-
handlers =
|
54 |
-
qualname = alembic
|
55 |
-
|
56 |
-
[handler_console]
|
57 |
-
class = StreamHandler
|
58 |
-
args = (sys.stderr,)
|
59 |
-
level = NOTSET
|
60 |
-
formatter = generic
|
61 |
-
|
62 |
-
[formatter_generic]
|
63 |
-
format = %(levelname)-5.5s [%(name)s] %(message)s
|
64 |
-
datefmt = %H:%M:%S
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.log
CHANGED
@@ -1,22 +0,0 @@
|
|
1 |
-
2025-02-28 18:27:16,754 - INFO - Chat request received with 1 messages
|
2 |
-
2025-02-28 18:27:16,755 - INFO - Formatted prompt: give me saas app
|
3 |
-
|
4 |
-
2025-02-28 18:27:29,908 - INFO - Generated response: i want to download saas app
|
5 |
-
2025-02-28 18:28:08,376 - INFO - Feature generation request received with requirements: gerneate me 10 feature to use in saas
|
6 |
-
2025-02-28 18:28:08,377 - INFO - Generated prompt: Generate 5 features based on the following requirements. Format each feature as a JSON object with 'feature' and 'short_description' fields.
|
7 |
-
|
8 |
-
Requirements: gerneate me 10 feature to use in saas
|
9 |
-
2025-02-28 18:29:29,392 - INFO - Model response: i would like 10 feature to use in saas
|
10 |
-
2025-02-28 18:29:29,392 - INFO - Returning features: [Feature(feature='Feature 1', short_description='Description 1'), Feature(feature='Feature 2', short_description='Description 2')]
|
11 |
-
2025-02-28 18:31:00,786 - INFO - Feature generation request received with requirements: gerneate me 10 feature to use in saas
|
12 |
-
2025-02-28 18:31:00,787 - INFO - Generated prompt: Generate 5 detailed SaaS features based on the following requirements. Each feature should be practical and implementation-ready. Format your response as a list of JSON objects, each with 'feature' and 'short_description' fields.
|
13 |
-
|
14 |
-
Example format:
|
15 |
-
{
|
16 |
-
'feature': 'User Authentication',
|
17 |
-
'short_description': 'Secure login system with OAuth2 and MFA support'
|
18 |
-
}
|
19 |
-
|
20 |
-
Requirements: gerneate me 10 feature to use in saas
|
21 |
-
|
22 |
-
Provide 5 features in the exact JSON format shown above.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/__pycache__/main.cpython-312.pyc
CHANGED
Binary files a/app/__pycache__/main.cpython-312.pyc and b/app/__pycache__/main.cpython-312.pyc differ
|
|
app/controllers/__pycache__/f5_model.cpython-312.pyc
CHANGED
Binary files a/app/controllers/__pycache__/f5_model.cpython-312.pyc and b/app/controllers/__pycache__/f5_model.cpython-312.pyc differ
|
|
app/controllers/f5_model.py
CHANGED
@@ -8,43 +8,48 @@ class F5ModelHandler:
|
|
8 |
def __init__(self):
|
9 |
logging.info("Initializing F5ModelHandler...")
|
10 |
try:
|
11 |
-
|
12 |
-
|
13 |
-
#
|
|
|
|
|
14 |
self.generator = pipeline(
|
15 |
"text2text-generation",
|
16 |
model=self.model_name,
|
17 |
device="cuda" if torch.cuda.is_available() else "cpu",
|
18 |
-
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32
|
|
|
19 |
)
|
20 |
logging.info(f"Model loaded successfully on {self.generator.device}")
|
21 |
except Exception as e:
|
22 |
logging.error(f"Error loading model: {str(e)}")
|
23 |
raise
|
24 |
|
25 |
-
async def generate_response(self, prompt: str, max_length: int =
|
26 |
try:
|
27 |
logging.info(f"Generating response for prompt: {prompt[:100]}...")
|
28 |
|
29 |
-
#
|
30 |
response = self.generator(
|
31 |
prompt,
|
32 |
max_length=max_length,
|
|
|
33 |
num_beams=5,
|
34 |
-
temperature=0.
|
35 |
top_p=0.95,
|
36 |
top_k=50,
|
37 |
repetition_penalty=1.2,
|
38 |
length_penalty=1.0,
|
39 |
do_sample=True,
|
40 |
-
num_return_sequences=1
|
|
|
41 |
)[0]['generated_text']
|
42 |
|
43 |
# Clean up the response
|
44 |
response = response.strip()
|
45 |
|
46 |
# Ensure minimum content length
|
47 |
-
if len(response) <
|
48 |
logging.warning("Response too short, regenerating...")
|
49 |
return await self.generate_response(prompt, max_length)
|
50 |
|
@@ -55,14 +60,15 @@ class F5ModelHandler:
|
|
55 |
logging.error(f"Error generating response: {str(e)}")
|
56 |
raise
|
57 |
|
58 |
-
async def stream_response(self, prompt: str, max_length: int =
|
59 |
try:
|
60 |
response = self.generator(
|
61 |
prompt,
|
62 |
max_length=max_length,
|
|
|
63 |
num_beams=4,
|
64 |
-
temperature=0.
|
65 |
-
top_p=0.
|
66 |
do_sample=True,
|
67 |
return_full_text=False
|
68 |
)[0]['generated_text']
|
|
|
8 |
def __init__(self):
|
9 |
logging.info("Initializing F5ModelHandler...")
|
10 |
try:
|
11 |
+
# Using a larger T5 model for better generation
|
12 |
+
logging.info("Loading model 'google/flan-t5-large'...")
|
13 |
+
self.model_name = "google/flan-t5-large" # Upgraded from small to large
|
14 |
+
|
15 |
+
# Use pipeline for simpler model loading with better parameters
|
16 |
self.generator = pipeline(
|
17 |
"text2text-generation",
|
18 |
model=self.model_name,
|
19 |
device="cuda" if torch.cuda.is_available() else "cpu",
|
20 |
+
torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
|
21 |
+
model_kwargs={"cache_dir": "./model_cache"} # Cache the model locally
|
22 |
)
|
23 |
logging.info(f"Model loaded successfully on {self.generator.device}")
|
24 |
except Exception as e:
|
25 |
logging.error(f"Error loading model: {str(e)}")
|
26 |
raise
|
27 |
|
28 |
+
async def generate_response(self, prompt: str, max_length: int = 3072) -> str:
|
29 |
try:
|
30 |
logging.info(f"Generating response for prompt: {prompt[:100]}...")
|
31 |
|
32 |
+
# Enhanced generation parameters for better quality
|
33 |
response = self.generator(
|
34 |
prompt,
|
35 |
max_length=max_length,
|
36 |
+
min_length=1000, # Ensure minimum length
|
37 |
num_beams=5,
|
38 |
+
temperature=0.8,
|
39 |
top_p=0.95,
|
40 |
top_k=50,
|
41 |
repetition_penalty=1.2,
|
42 |
length_penalty=1.0,
|
43 |
do_sample=True,
|
44 |
+
num_return_sequences=1,
|
45 |
+
early_stopping=True
|
46 |
)[0]['generated_text']
|
47 |
|
48 |
# Clean up the response
|
49 |
response = response.strip()
|
50 |
|
51 |
# Ensure minimum content length
|
52 |
+
if len(response) < 500: # Increased minimum length requirement
|
53 |
logging.warning("Response too short, regenerating...")
|
54 |
return await self.generate_response(prompt, max_length)
|
55 |
|
|
|
60 |
logging.error(f"Error generating response: {str(e)}")
|
61 |
raise
|
62 |
|
63 |
+
async def stream_response(self, prompt: str, max_length: int = 3072):
|
64 |
try:
|
65 |
response = self.generator(
|
66 |
prompt,
|
67 |
max_length=max_length,
|
68 |
+
min_length=1000,
|
69 |
num_beams=4,
|
70 |
+
temperature=0.8,
|
71 |
+
top_p=0.95,
|
72 |
do_sample=True,
|
73 |
return_full_text=False
|
74 |
)[0]['generated_text']
|
app/main.py
CHANGED
@@ -190,89 +190,43 @@ async def generate_plan(request: ProjectPlanRequest):
|
|
190 |
try:
|
191 |
logger.info(f"Plan generation request received for project: {request.project_title}")
|
192 |
|
193 |
-
#
|
194 |
-
prompt = f"""
|
195 |
-
Include specific {request.platform} services and implementation details in each section.
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
- Highlight main {request.platform} services to be used
|
201 |
-
- Explain expected business impact
|
202 |
|
203 |
-
|
204 |
-
- Define detailed scope including:
|
205 |
-
* Core functionalities
|
206 |
-
* System boundaries
|
207 |
-
* Integration points
|
208 |
-
- List at least 5 specific objectives
|
209 |
-
- Include measurable success criteria
|
210 |
|
211 |
-
|
212 |
-
|
213 |
-
* Frontend architecture
|
214 |
-
* Backend services
|
215 |
-
* Database design
|
216 |
-
* Integration patterns
|
217 |
-
* Network topology
|
218 |
-
- Explain how components interact
|
219 |
-
- Include scalability considerations
|
220 |
|
221 |
-
|
222 |
-
|
223 |
-
* Purpose and functionality
|
224 |
-
* Technical specifications
|
225 |
-
* Data flow
|
226 |
-
* Integration points
|
227 |
-
* Performance requirements
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
- Detail authentication and authorization
|
232 |
-
- Describe data protection measures
|
233 |
-
- Include compliance requirements
|
234 |
-
- Specify security monitoring
|
235 |
|
236 |
-
|
237 |
-
|
238 |
-
- Test strategy including:
|
239 |
-
* Unit testing
|
240 |
-
* Integration testing
|
241 |
-
* Performance testing
|
242 |
-
- Monitoring setup with {request.platform} tools
|
243 |
-
- Alerting and logging strategy
|
244 |
|
245 |
-
|
246 |
-
|
247 |
-
- Detail specific skills needed
|
248 |
-
- Include {request.platform} certifications
|
249 |
-
- Define team structure
|
250 |
-
- Specify responsibilities
|
251 |
|
252 |
-
|
253 |
-
|
254 |
-
- Resource optimization strategies
|
255 |
-
- Scaling considerations
|
256 |
-
- Cost monitoring approach
|
257 |
-
- Budget optimization tips
|
258 |
|
259 |
-
|
260 |
-
|
261 |
-
- Specific tasks for each phase
|
262 |
-
- Timeline estimates
|
263 |
-
- Dependencies
|
264 |
-
- Critical path items
|
265 |
|
266 |
-
|
267 |
-
|
268 |
|
269 |
-
|
270 |
-
|
271 |
|
272 |
-
|
273 |
-
{request.additional_requirements}
|
274 |
-
|
275 |
-
Generate a detailed plan following this structure with specific {request.platform} implementation details."""
|
276 |
|
277 |
logger.info("Generating plan with model...")
|
278 |
response = await model_handler.generate_response(prompt)
|
|
|
190 |
try:
|
191 |
logger.info(f"Plan generation request received for project: {request.project_title}")
|
192 |
|
193 |
+
# Simplified prompt for better generation
|
194 |
+
prompt = f"""Create a detailed technical project plan for a {request.platform} project named '{request.project_title}'.
|
|
|
195 |
|
196 |
+
Requirements: {request.requirements}
|
197 |
+
Features: {', '.join(request.features)}
|
198 |
+
Additional Requirements: {request.additional_requirements}
|
|
|
|
|
199 |
|
200 |
+
Generate a complete plan with the following sections:
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
|
202 |
+
1. Executive Summary
|
203 |
+
Brief overview of the project, its goals, and business impact.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
|
205 |
+
2. Project Scope and Objectives
|
206 |
+
Core functionalities and specific objectives.
|
|
|
|
|
|
|
|
|
|
|
207 |
|
208 |
+
3. Architecture Overview
|
209 |
+
{request.platform} architecture components and their interactions.
|
|
|
|
|
|
|
|
|
210 |
|
211 |
+
4. Component Design
|
212 |
+
Core components and their technical specifications.
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
|
214 |
+
5. Security and Compliance
|
215 |
+
Security measures and compliance requirements.
|
|
|
|
|
|
|
|
|
216 |
|
217 |
+
6. Deployment, Testing, and Monitoring
|
218 |
+
Implementation approach and quality assurance.
|
|
|
|
|
|
|
|
|
219 |
|
220 |
+
7. Team Roles and Skills
|
221 |
+
Required team members and their expertise.
|
|
|
|
|
|
|
|
|
222 |
|
223 |
+
8. Cost Estimates and Optimization
|
224 |
+
Resource planning and cost optimization.
|
225 |
|
226 |
+
9. Project Tasks and Milestones
|
227 |
+
Project phases and timeline.
|
228 |
|
229 |
+
Provide detailed content for each section."""
|
|
|
|
|
|
|
230 |
|
231 |
logger.info("Generating plan with model...")
|
232 |
response = await model_handler.generate_response(prompt)
|
app/templates/index.html
CHANGED
@@ -5,6 +5,7 @@
|
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>F5 Model Test Interface</title>
|
7 |
<script src="https://cdn.tailwindcss.com"></script>
|
|
|
8 |
<style>
|
9 |
.loading {
|
10 |
display: none;
|
@@ -40,6 +41,70 @@
|
|
40 |
0%, 100% { opacity: 1; }
|
41 |
50% { opacity: 0.5; }
|
42 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
</style>
|
44 |
</head>
|
45 |
<body class="bg-gray-100">
|
@@ -87,30 +152,26 @@
|
|
87 |
<h3 class="text-lg font-semibold mb-2" id="planTitle"></h3>
|
88 |
<div id="planSections" class="space-y-4"></div>
|
89 |
</div>
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
<div class="mb-4">
|
96 |
-
<div id="chatHistory" class="bg-gray-50 rounded p-4 h-64 overflow-y-auto mb-4"></div>
|
97 |
-
<div id="chatLoading" class="loading mb-4">
|
98 |
-
<div></div>
|
99 |
-
<div></div>
|
100 |
-
<div></div>
|
101 |
-
</div>
|
102 |
-
<div class="flex gap-2">
|
103 |
-
<input type="text" id="chatInput"
|
104 |
-
class="flex-1 border rounded px-3 py-2"
|
105 |
-
placeholder="Type your message...">
|
106 |
-
<button onclick="sendMessage()"
|
107 |
-
class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600">
|
108 |
-
Send
|
109 |
</button>
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
</div>
|
115 |
</div>
|
116 |
</div>
|
@@ -136,22 +197,73 @@
|
|
136 |
</div>
|
137 |
</div>
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
<script>
|
140 |
let chatHistory = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
async function sendMessage() {
|
143 |
const input = document.getElementById('chatInput');
|
144 |
const message = input.value.trim();
|
|
|
|
|
145 |
if (!message) return;
|
146 |
-
|
147 |
-
// Show loading indicator
|
148 |
-
document.getElementById('chatLoading').style.display = 'block';
|
149 |
|
150 |
-
// Add user message to chat
|
151 |
-
appendMessage('user', message);
|
152 |
input.value = '';
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
155 |
try {
|
156 |
if (streamMode) {
|
157 |
const response = await fetch('/chat', {
|
@@ -195,10 +307,9 @@
|
|
195 |
}
|
196 |
} catch (error) {
|
197 |
console.error('Error:', error);
|
198 |
-
appendMessage('
|
199 |
} finally {
|
200 |
-
|
201 |
-
document.getElementById('chatLoading').style.display = 'none';
|
202 |
}
|
203 |
}
|
204 |
|
@@ -245,11 +356,12 @@
|
|
245 |
function updateChatDisplay() {
|
246 |
const chatDiv = document.getElementById('chatHistory');
|
247 |
chatDiv.innerHTML = chatHistory.map(msg => `
|
248 |
-
<div class="mb-
|
249 |
-
<
|
250 |
-
${msg.role}
|
251 |
-
|
252 |
-
|
|
|
253 |
</div>
|
254 |
`).join('');
|
255 |
chatDiv.scrollTop = chatDiv.scrollHeight;
|
@@ -325,6 +437,11 @@
|
|
325 |
}
|
326 |
}
|
327 |
|
|
|
|
|
|
|
|
|
|
|
328 |
function displayPlan(data) {
|
329 |
console.log('Displaying plan data:', data);
|
330 |
const output = document.getElementById('planOutput');
|
@@ -368,6 +485,15 @@
|
|
368 |
|
369 |
console.log('Final HTML output:', sections.innerHTML);
|
370 |
output.classList.remove('hidden');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
371 |
}
|
372 |
</script>
|
373 |
</body>
|
|
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<title>F5 Model Test Interface</title>
|
7 |
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
9 |
<style>
|
10 |
.loading {
|
11 |
display: none;
|
|
|
41 |
0%, 100% { opacity: 1; }
|
42 |
50% { opacity: 0.5; }
|
43 |
}
|
44 |
+
|
45 |
+
/* Chat Widget Styles */
|
46 |
+
.chat-widget {
|
47 |
+
position: fixed;
|
48 |
+
bottom: 20px;
|
49 |
+
right: 20px;
|
50 |
+
z-index: 1000;
|
51 |
+
}
|
52 |
+
|
53 |
+
.chat-button {
|
54 |
+
width: 60px;
|
55 |
+
height: 60px;
|
56 |
+
border-radius: 50%;
|
57 |
+
background-color: #3B82F6;
|
58 |
+
display: flex;
|
59 |
+
align-items: center;
|
60 |
+
justify-content: center;
|
61 |
+
cursor: pointer;
|
62 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
63 |
+
transition: all 0.3s ease;
|
64 |
+
}
|
65 |
+
|
66 |
+
.chat-button:hover {
|
67 |
+
transform: scale(1.1);
|
68 |
+
}
|
69 |
+
|
70 |
+
.chat-window {
|
71 |
+
position: fixed;
|
72 |
+
bottom: 90px;
|
73 |
+
right: 20px;
|
74 |
+
width: 350px;
|
75 |
+
height: 500px;
|
76 |
+
background: white;
|
77 |
+
border-radius: 12px;
|
78 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
79 |
+
display: none;
|
80 |
+
flex-direction: column;
|
81 |
+
overflow: hidden;
|
82 |
+
}
|
83 |
+
|
84 |
+
.chat-window.active {
|
85 |
+
display: flex;
|
86 |
+
}
|
87 |
+
|
88 |
+
.chat-header {
|
89 |
+
padding: 1rem;
|
90 |
+
background: #3B82F6;
|
91 |
+
color: white;
|
92 |
+
display: flex;
|
93 |
+
justify-content: space-between;
|
94 |
+
align-items: center;
|
95 |
+
}
|
96 |
+
|
97 |
+
.chat-messages {
|
98 |
+
flex-grow: 1;
|
99 |
+
overflow-y: auto;
|
100 |
+
padding: 1rem;
|
101 |
+
}
|
102 |
+
|
103 |
+
.chat-input-container {
|
104 |
+
padding: 1rem;
|
105 |
+
border-top: 1px solid #e5e7eb;
|
106 |
+
background: white;
|
107 |
+
}
|
108 |
</style>
|
109 |
</head>
|
110 |
<body class="bg-gray-100">
|
|
|
152 |
<h3 class="text-lg font-semibold mb-2" id="planTitle"></h3>
|
153 |
<div id="planSections" class="space-y-4"></div>
|
154 |
</div>
|
155 |
+
<div id="debugPanel" class="mt-6 bg-gray-800 rounded p-4 text-white hidden">
|
156 |
+
<div class="flex justify-between items-center mb-4">
|
157 |
+
<h3 class="text-lg font-semibold">Debug Panel</h3>
|
158 |
+
<button onclick="toggleDebugPanel()" class="text-gray-400 hover:text-white">
|
159 |
+
<i class="fas fa-times"></i>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
</button>
|
161 |
+
</div>
|
162 |
+
<div class="space-y-4">
|
163 |
+
<div>
|
164 |
+
<h4 class="text-sm font-semibold text-gray-400">Request Data</h4>
|
165 |
+
<pre id="requestData" class="text-xs bg-gray-900 p-2 rounded overflow-auto max-h-40"></pre>
|
166 |
+
</div>
|
167 |
+
<div>
|
168 |
+
<h4 class="text-sm font-semibold text-gray-400">Raw API Response</h4>
|
169 |
+
<pre id="rawResponse" class="text-xs bg-gray-900 p-2 rounded overflow-auto max-h-40"></pre>
|
170 |
+
</div>
|
171 |
+
<div>
|
172 |
+
<h4 class="text-sm font-semibold text-gray-400">Parsed Sections</h4>
|
173 |
+
<pre id="parsedSections" class="text-xs bg-gray-900 p-2 rounded overflow-auto max-h-40"></pre>
|
174 |
+
</div>
|
175 |
</div>
|
176 |
</div>
|
177 |
</div>
|
|
|
197 |
</div>
|
198 |
</div>
|
199 |
|
200 |
+
<!-- Chat Widget -->
|
201 |
+
<div class="chat-widget">
|
202 |
+
<div class="chat-button" onclick="toggleChat()">
|
203 |
+
<i class="fas fa-comments text-white text-2xl"></i>
|
204 |
+
</div>
|
205 |
+
|
206 |
+
<div class="chat-window" id="chatWindow">
|
207 |
+
<div class="chat-header">
|
208 |
+
<span class="font-semibold">Chat Assistant</span>
|
209 |
+
<button onclick="toggleChat()" class="text-white hover:text-gray-200">
|
210 |
+
<i class="fas fa-times"></i>
|
211 |
+
</button>
|
212 |
+
</div>
|
213 |
+
|
214 |
+
<div class="chat-messages" id="chatHistory">
|
215 |
+
<!-- Messages will be inserted here -->
|
216 |
+
</div>
|
217 |
+
|
218 |
+
<div id="chatLoading" class="loading mx-auto my-2" style="transform: scale(0.5);">
|
219 |
+
<div></div>
|
220 |
+
<div></div>
|
221 |
+
<div></div>
|
222 |
+
</div>
|
223 |
+
|
224 |
+
<div class="chat-input-container">
|
225 |
+
<div class="flex gap-2">
|
226 |
+
<input type="text" id="chatInput"
|
227 |
+
class="flex-1 border rounded px-3 py-2"
|
228 |
+
placeholder="Type your message...">
|
229 |
+
<button onclick="sendMessage()"
|
230 |
+
class="bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600">
|
231 |
+
<i class="fas fa-paper-plane"></i>
|
232 |
+
</button>
|
233 |
+
</div>
|
234 |
+
<div class="flex items-center gap-2 mt-2">
|
235 |
+
<label class="flex items-center gap-2 text-sm text-gray-600">
|
236 |
+
<input type="checkbox" id="streamToggle">
|
237 |
+
Stream responses
|
238 |
+
</label>
|
239 |
+
</div>
|
240 |
+
</div>
|
241 |
+
</div>
|
242 |
+
</div>
|
243 |
+
|
244 |
<script>
|
245 |
let chatHistory = [];
|
246 |
+
let chatWindowOpen = false;
|
247 |
+
|
248 |
+
function toggleChat() {
|
249 |
+
const chatWindow = document.getElementById('chatWindow');
|
250 |
+
chatWindowOpen = !chatWindowOpen;
|
251 |
+
chatWindow.classList.toggle('active');
|
252 |
+
}
|
253 |
|
254 |
async function sendMessage() {
|
255 |
const input = document.getElementById('chatInput');
|
256 |
const message = input.value.trim();
|
257 |
+
const streamMode = document.getElementById('streamToggle').checked;
|
258 |
+
|
259 |
if (!message) return;
|
|
|
|
|
|
|
260 |
|
|
|
|
|
261 |
input.value = '';
|
262 |
+
appendMessage('user', message);
|
263 |
+
|
264 |
+
const loading = document.getElementById('chatLoading');
|
265 |
+
loading.style.display = 'block';
|
266 |
+
|
267 |
try {
|
268 |
if (streamMode) {
|
269 |
const response = await fetch('/chat', {
|
|
|
307 |
}
|
308 |
} catch (error) {
|
309 |
console.error('Error:', error);
|
310 |
+
appendMessage('assistant', 'Sorry, there was an error processing your request.');
|
311 |
} finally {
|
312 |
+
loading.style.display = 'none';
|
|
|
313 |
}
|
314 |
}
|
315 |
|
|
|
356 |
function updateChatDisplay() {
|
357 |
const chatDiv = document.getElementById('chatHistory');
|
358 |
chatDiv.innerHTML = chatHistory.map(msg => `
|
359 |
+
<div class="mb-3">
|
360 |
+
<div class="flex items-start ${msg.role === 'user' ? 'justify-end' : 'justify-start'}">
|
361 |
+
<div class="max-w-[80%] ${msg.role === 'user' ? 'bg-blue-500 text-white' : 'bg-gray-200'} rounded-lg px-4 py-2">
|
362 |
+
<div class="text-sm">${msg.content}</div>
|
363 |
+
</div>
|
364 |
+
</div>
|
365 |
</div>
|
366 |
`).join('');
|
367 |
chatDiv.scrollTop = chatDiv.scrollHeight;
|
|
|
437 |
}
|
438 |
}
|
439 |
|
440 |
+
function toggleDebugPanel() {
|
441 |
+
const debugPanel = document.getElementById('debugPanel');
|
442 |
+
debugPanel.classList.toggle('hidden');
|
443 |
+
}
|
444 |
+
|
445 |
function displayPlan(data) {
|
446 |
console.log('Displaying plan data:', data);
|
447 |
const output = document.getElementById('planOutput');
|
|
|
485 |
|
486 |
console.log('Final HTML output:', sections.innerHTML);
|
487 |
output.classList.remove('hidden');
|
488 |
+
|
489 |
+
// Update debug panel
|
490 |
+
document.getElementById('debugPanel').classList.remove('hidden');
|
491 |
+
document.getElementById('requestData').textContent = JSON.stringify({
|
492 |
+
project_title: data.project_title,
|
493 |
+
sections: data.sections
|
494 |
+
}, null, 2);
|
495 |
+
document.getElementById('rawResponse').textContent = data.raw_content;
|
496 |
+
document.getElementById('parsedSections').textContent = JSON.stringify(data.sections, null, 2);
|
497 |
}
|
498 |
</script>
|
499 |
</body>
|
requirements.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
fastapi==0.109.0
|
|
|
2 |
uvicorn==0.27.0
|
3 |
sqlalchemy==2.0.25
|
4 |
aiosqlite==0.19.0
|
@@ -12,4 +13,9 @@ passlib==1.7.4
|
|
12 |
alembic==1.13.1
|
13 |
openpyxl
|
14 |
xlsxwriter
|
15 |
-
pypdf
|
|
|
|
|
|
|
|
|
|
|
|
1 |
fastapi==0.109.0
|
2 |
+
torch
|
3 |
uvicorn==0.27.0
|
4 |
sqlalchemy==2.0.25
|
5 |
aiosqlite==0.19.0
|
|
|
13 |
alembic==1.13.1
|
14 |
openpyxl
|
15 |
xlsxwriter
|
16 |
+
pypdf
|
17 |
+
transformers>=4.36.2
|
18 |
+
torch
|
19 |
+
accelerate>=0.25.0
|
20 |
+
sentencepiece>=0.1.99
|
21 |
+
|