Skip to content
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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Developer #11

wants to merge 9 commits into from

Conversation

thadeucbr
Copy link
Owner

No description provided.

volumes:
- .:/usr/src/app
ports:
- "${EXPRESS_PORT}:${EXPRESS_PORT}"
Copy link
Owner Author

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
Copy link
Owner Author

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:
Copy link
Owner Author

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:
Copy link
Owner Author

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.',
Copy link
Owner Author

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, () => {
Copy link
Owner Author

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) {
Copy link
Owner Author

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',
Copy link
Owner Author

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) {
Copy link
Owner Author

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;
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant