-
Notifications
You must be signed in to change notification settings - Fork 0
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
Developer #11
base: main
Are you sure you want to change the base?
Conversation
…n response and improve tool call handling
volumes: | ||
- .:/usr/src/app | ||
ports: | ||
- "${EXPRESS_PORT}:${EXPRESS_PORT}" |
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.
Ensure that the ${EXPRESS_PORT}
environment variable is defined in your .env
file to avoid runtime errors.
- .:/usr/src/app | ||
ports: | ||
- "${EXPRESS_PORT}:${EXPRESS_PORT}" | ||
command: npm run dev |
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.
The command npm run dev
should be verified to ensure it is correctly set up in your package.json
.
env_file: | ||
- .env | ||
|
||
# mongo: |
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.
Consider removing the commented-out section for the mongo
service if it is not going to be used, to keep the file clean.
# volumes: | ||
# - mongo_data:/data/db | ||
|
||
# volumes: |
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.
Similar to the previous comment, if the mongo_data
volume is not needed, it should be removed to avoid confusion.
@@ -14,7 +14,7 @@ const aiRepositoryTool = { | |||
query: { | |||
type: 'object', | |||
description: | |||
'The query parameters used for the operation. Structure depends on the transaction type, Required for update operations. Include subpropeties query.filter and query.update', | |||
'The query parameters used for the operation. Structure depends on the transaction type.', |
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.
The description for the query parameters is incomplete. It should mention that it is required for update operations and include details about the subproperties query.filter
and query.update
.
app.use(asyncHandler(validateRequest)); | ||
app.use(asyncHandler(gptMiddleware)); | ||
app.use(errorHandler); | ||
|
||
setupSwagger(app); | ||
|
||
app.listen(process.env.EXPRESS_PORT || 3000, () => { |
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.
The line setupSwagger(app);
is duplicated. Please remove the redundant line to avoid unnecessary function calls.
@@ -25,42 +25,41 @@ const aiService = async ({ | |||
let response = await gpt({ completion: context }); | |||
|
|||
async function callTool(gpt) { | |||
const { name, arguments: args } = gpt.tool_calls[0].function; | |||
let functionResponse; | |||
for (const toolCall of gpt.tool_calls) { |
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.
The variable functionResponse
is declared but not initialized. Consider initializing it to null
or an appropriate default value to avoid potential reference errors.
return null; // Retorna null se não houver erro | ||
context.push({ | ||
role: 'tool', | ||
content: JSON.stringify(functionResponse) || 'Return error', |
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.
The fallback value for content
in context.push
should be more explicit. Instead of using || 'Return error'
, consider handling the error case more clearly to avoid confusion.
content: JSON.stringify(functionResponse) || 'Return error', | ||
tool_call_id: toolCall.id, | ||
}); | ||
} | ||
} | ||
|
||
context.push(response); | ||
let retries = 0; | ||
|
||
while (!response.content && retries < 20) { |
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.
The comment on line 54 is in Portuguese. It's better to keep comments in English for consistency, especially if the codebase is intended for a broader audience.
|
||
response = await gpt({ completion: context }); | ||
context.push(response); | ||
retries++; | ||
} | ||
|
||
console.log(context); | ||
return response; |
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.
The console.log(context);
statement on line 62 may lead to excessive logging. Consider removing it or using a logging level to control when it gets executed.
No description provided.