-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix port numebr in back end and add end point configeration to example #96
Changes from all commits
c887b7c
b9745e1
5ede8d4
097c4e5
7ed3f2b
dd074c4
0877baa
8c17e65
1a248d3
247c987
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
PORT=8090 | ||
PORT=8080 | ||
JWT_SECRET="JACKSONCHENNAHEULALLEN" | ||
SALT_ROUNDS=123 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,11 @@ import { BuilderContext } from 'src/build-system/context'; | |
import { generateBackendOverviewPrompt } from './prompt'; | ||
import { Logger } from '@nestjs/common'; | ||
import { removeCodeBlockFences } from 'src/build-system/utils/strings'; | ||
import { chatSyncWithClocker } from 'src/build-system/utils/handler-helper'; | ||
import { MessageInterface } from 'src/common/model-provider/types'; | ||
import { | ||
MissingConfigurationError, | ||
ModelUnavailableError, | ||
ResponseParsingError, | ||
} from 'src/build-system/errors'; | ||
import { chatSyncWithClocker } from 'src/build-system/utils/handler-helper'; | ||
|
||
type BackendRequirementResult = { | ||
overview: string; | ||
|
@@ -68,27 +66,17 @@ export class BackendRequirementHandler | |
let backendOverview: string; | ||
|
||
try { | ||
const messages: MessageInterface[] = [ | ||
{ content: overviewPrompt, role: 'system' }, | ||
]; | ||
backendOverview = await chatSyncWithClocker( | ||
context, | ||
messages, | ||
'gpt-4o-mini', | ||
{ | ||
model: 'gpt-4o-mini', | ||
messages: [{ content: overviewPrompt, role: 'system' }], | ||
}, | ||
'generateBackendOverviewPrompt', | ||
this.id, | ||
); | ||
|
||
if (!backendOverview) { | ||
throw new ModelUnavailableError( | ||
'The model did not respond within the expected time.', | ||
); | ||
} | ||
if (backendOverview.trim() === '') { | ||
throw new ResponseParsingError('Generated backend overview is empty.'); | ||
} | ||
} catch (error) { | ||
throw error; | ||
throw new ModelUnavailableError('Model is unavailable:' + error); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add response validation before usage. Similar to other handlers, we should validate the model's response before using it. } catch (error) {
throw new ModelUnavailableError('Model is unavailable:' + error);
}
+
+ if (!backendOverview?.trim()) {
+ throw new ModelUnavailableError('Model returned empty response');
+ }
|
||
} | ||
|
||
// Return generated data | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,7 @@ import { Logger } from '@nestjs/common'; | |
import { removeCodeBlockFences } from 'src/build-system/utils/strings'; | ||
import { | ||
MissingConfigurationError, | ||
ResponseParsingError, | ||
ModelUnavailableError, | ||
TemporaryServiceUnavailableError, | ||
RateLimitExceededError, | ||
} from 'src/build-system/errors'; | ||
import { chatSyncWithClocker } from 'src/build-system/utils/handler-helper'; | ||
import { MessageInterface } from 'src/common/model-provider/types'; | ||
|
@@ -41,34 +38,17 @@ export class DatabaseRequirementHandler implements BuildHandler<string> { | |
let dbRequirementsContent: string; | ||
|
||
try { | ||
const messages: MessageInterface[] = [ | ||
{ content: prompt, role: 'system' }, | ||
]; | ||
dbRequirementsContent = await chatSyncWithClocker( | ||
context, | ||
messages, | ||
'gpt-4o-mini', | ||
{ | ||
model: 'gpt-4o-mini', | ||
messages: [{ content: prompt, role: 'system' }], | ||
}, | ||
'generateDatabaseRequirementPrompt', | ||
this.id, | ||
); | ||
|
||
if (!dbRequirementsContent) { | ||
throw new ModelUnavailableError( | ||
'The model did not respond within the expected time.', | ||
); | ||
} | ||
|
||
if (dbRequirementsContent.trim() === '') { | ||
throw new ResponseParsingError( | ||
'Generated database requirements content is empty.', | ||
); | ||
} | ||
} catch (error) { | ||
this.logger.error( | ||
'Error during database requirements generation:', | ||
error, | ||
); | ||
throw error; // Propagate error to upper-level handler | ||
throw new ModelUnavailableError('Model Unavailable:' + error); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add response validation before usage. While the error handling has been simplified, we should validate the model's response before using it. An empty or malformed response could cause issues downstream. } catch (error) {
throw new ModelUnavailableError('Model Unavailable:' + error);
}
+
+ if (!dbRequirementsContent?.trim()) {
+ throw new ModelUnavailableError('Model returned empty response');
+ }
|
||
} | ||
|
||
return { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling for file write operation.
The file write operation should be wrapped in a try-catch block to handle potential write errors.