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

Tools + agent #1473

Merged
merged 19 commits into from
Dec 20, 2024
Merged

Tools + agent #1473

merged 19 commits into from
Dec 20, 2024

Conversation

dartpain
Copy link
Contributor

@dartpain dartpain commented Dec 5, 2024

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    Tools
  • Why was this change needed? (You can also link to an open issue here)
    They are cool
  • Other information:
    n/a

Copy link

vercel bot commented Dec 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-gpt ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2024 6:14pm
nextra-docsgpt 🔄 Building (Inspect) Visit Preview 💬 Add feedback Dec 20, 2024 6:14pm

{"$set": {"tool_config": data["tool_config"]}},
)
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that detailed error information, including stack traces, is not exposed to the user. Instead, we should log the error on the server and return a generic error message to the user. This can be achieved by modifying the exception handling block to log the error and return a generic message.

  1. Import the logging module to enable logging of errors.
  2. Replace the current return statement in the exception block with a logging statement and a generic error message.
Suggested changeset 1
application/api/user/routes.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/application/api/user/routes.py b/application/api/user/routes.py
--- a/application/api/user/routes.py
+++ b/application/api/user/routes.py
@@ -5,3 +5,3 @@
 import uuid
-
+import logging
 from bson.binary import Binary, UuidRepresentation
@@ -1922,3 +1922,4 @@
         except Exception as err:
-            return make_response(jsonify({"success": False, "error": str(err)}), 400)
+            logging.error("An error occurred while creating a new tool: %s", err)
+            return make_response(jsonify({"success": False, "error": "An internal error has occurred."}), 400)
 
EOF
@@ -5,3 +5,3 @@
import uuid

import logging
from bson.binary import Binary, UuidRepresentation
@@ -1922,3 +1922,4 @@
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
logging.error("An error occurred while creating a new tool: %s", err)
return make_response(jsonify({"success": False, "error": "An internal error has occurred."}), 400)

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
{"$set": {"tool_actions": data["tool_actions"]}},
)
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that detailed error information is not exposed to the user. Instead, we should log the error on the server and return a generic error message to the user. This can be achieved by modifying the exception handling code to log the error and return a generic message.

  1. Import the logging module to enable logging of errors.
  2. Replace the return statement in the exception handling block to log the error and return a generic error message.
Suggested changeset 1
application/api/user/routes.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/application/api/user/routes.py b/application/api/user/routes.py
--- a/application/api/user/routes.py
+++ b/application/api/user/routes.py
@@ -1,2 +1,3 @@
 import datetime
+import logging
 import math
@@ -1973,3 +1974,4 @@
         except Exception as err:
-            return make_response(jsonify({"success": False, "error": str(err)}), 400)
+            logging.error("An error occurred while updating the tool: %s", str(err))
+            return make_response(jsonify({"success": False, "error": "An internal error has occurred."}), 400)
 
@@ -2005,3 +2007,4 @@
         except Exception as err:
-            return make_response(jsonify({"success": False, "error": str(err)}), 400)
+            logging.error("An error occurred while updating the tool configuration: %s", str(err))
+            return make_response(jsonify({"success": False, "error": "An internal error has occurred."}), 400)
 
EOF
@@ -1,2 +1,3 @@
import datetime
import logging
import math
@@ -1973,3 +1974,4 @@
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
logging.error("An error occurred while updating the tool: %s", str(err))
return make_response(jsonify({"success": False, "error": "An internal error has occurred."}), 400)

@@ -2005,3 +2007,4 @@
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
logging.error("An error occurred while updating the tool configuration: %s", str(err))
return make_response(jsonify({"success": False, "error": "An internal error has occurred."}), 400)

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
{"$set": {"status": data["status"]}},
)
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that detailed error messages and stack traces are not exposed to the end user. Instead, we should log the detailed error information on the server and return a generic error message to the user. This can be achieved by modifying the exception handling code to log the error and return a generic message.

  1. Import the logging module to enable logging of errors.
  2. Replace the current exception handling code to log the error and return a generic error message.
Suggested changeset 1
application/api/user/routes.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/application/api/user/routes.py b/application/api/user/routes.py
--- a/application/api/user/routes.py
+++ b/application/api/user/routes.py
@@ -1,2 +1,3 @@
 import datetime
+import logging
 import math
@@ -2005,3 +2006,4 @@
         except Exception as err:
-            return make_response(jsonify({"success": False, "error": str(err)}), 400)
+            logging.error("An error occurred: %s", str(err))
+            return make_response(jsonify({"success": False, "error": "An internal error has occurred!"}), 400)
 
EOF
@@ -1,2 +1,3 @@
import datetime
import logging
import math
@@ -2005,3 +2006,4 @@
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
logging.error("An error occurred: %s", str(err))
return make_response(jsonify({"success": False, "error": "An internal error has occurred!"}), 400)

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
{"$set": {"config": data["config"]}},
)
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that detailed error messages and stack traces are not exposed to the end user. Instead, we should log the error details on the server and return a generic error message to the user. This can be achieved by modifying the exception handling code to log the error and return a generic message.

  1. Import the logging module to enable logging of error messages.
  2. Replace the current return statements in the exception handling blocks with logging statements and a generic error message.
Suggested changeset 1
application/api/user/routes.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/application/api/user/routes.py b/application/api/user/routes.py
--- a/application/api/user/routes.py
+++ b/application/api/user/routes.py
@@ -5,2 +5,3 @@
 import uuid
+import logging
 
@@ -2039,3 +2040,4 @@
         except Exception as err:
-            return make_response(jsonify({"success": False, "error": str(err)}), 400)
+            logging.error("Error updating tool actions: %s", err)
+            return make_response(jsonify({"success": False, "error": "An internal error has occurred."}), 400)
 
@@ -2097,3 +2099,4 @@
         except Exception as err:
-            return {"success": False, "error": str(err)}, 400
+            logging.error("Error deleting tool: %s", err)
+            return {"success": False, "error": "An internal error has occurred."}, 400
 
EOF
@@ -5,2 +5,3 @@
import uuid
import logging

@@ -2039,3 +2040,4 @@
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
logging.error("Error updating tool actions: %s", err)
return make_response(jsonify({"success": False, "error": "An internal error has occurred."}), 400)

@@ -2097,3 +2099,4 @@
except Exception as err:
return {"success": False, "error": str(err)}, 400
logging.error("Error deleting tool: %s", err)
return {"success": False, "error": "An internal error has occurred."}, 400

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
{"$set": {"actions": data["actions"]}},
)
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that detailed error messages and stack traces are not exposed to the end user. Instead, we should log the error details on the server and return a generic error message to the user. This can be achieved by modifying the exception handling code to log the error and return a generic response.

  • Modify the exception handling blocks to log the error details and return a generic error message.
  • Ensure that the logging mechanism is properly set up to capture and store the error details for debugging purposes.
Suggested changeset 1
application/api/user/routes.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/application/api/user/routes.py b/application/api/user/routes.py
--- a/application/api/user/routes.py
+++ b/application/api/user/routes.py
@@ -2039,3 +2039,4 @@
         except Exception as err:
-            return make_response(jsonify({"success": False, "error": str(err)}), 400)
+            app.logger.error(f"Error updating tool actions: {err}")
+            return make_response(jsonify({"success": False, "message": "An internal error has occurred."}), 400)
 
@@ -2071,3 +2072,4 @@
         except Exception as err:
-            return make_response(jsonify({"success": False, "error": str(err)}), 400)
+            app.logger.error(f"Error updating tool status: {err}")
+            return make_response(jsonify({"success": False, "message": "An internal error has occurred."}), 400)
 
@@ -2097,3 +2099,4 @@
         except Exception as err:
-            return {"success": False, "error": str(err)}, 400
+            app.logger.error(f"Error deleting tool: {err}")
+            return {"success": False, "message": "An internal error has occurred."}, 400
 
EOF
@@ -2039,3 +2039,4 @@
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
app.logger.error(f"Error updating tool actions: {err}")
return make_response(jsonify({"success": False, "message": "An internal error has occurred."}), 400)

@@ -2071,3 +2072,4 @@
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
app.logger.error(f"Error updating tool status: {err}")
return make_response(jsonify({"success": False, "message": "An internal error has occurred."}), 400)

@@ -2097,3 +2099,4 @@
except Exception as err:
return {"success": False, "error": str(err)}, 400
app.logger.error(f"Error deleting tool: {err}")
return {"success": False, "message": "An internal error has occurred."}, 400

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
application/api/user/routes.py Fixed Show fixed Hide fixed
@@ -1801,4 +1806,296 @@
200,
)
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
return make_response(jsonify({"success": False, "error": str(err)}), 400)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix AI 2 days ago

To fix the problem, we need to ensure that detailed error messages and stack traces are not exposed to the end user. Instead, we should log the detailed error information on the server and return a generic error message to the user. This can be achieved by modifying the exception handling code to log the error and return a generic message.

  • Modify the exception handling blocks to log the error details and return a generic error message.
  • Ensure that the logging mechanism is in place to capture the detailed error information for debugging purposes.
Suggested changeset 1
application/api/user/routes.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/application/api/user/routes.py b/application/api/user/routes.py
--- a/application/api/user/routes.py
+++ b/application/api/user/routes.py
@@ -1773,3 +1773,4 @@
         except Exception as err:
-            return make_response(jsonify({"success": False, "error": str(err)}), 400)
+            app.logger.error(f"Error updating sync frequency: {err}")
+            return make_response(jsonify({"success": False, "message": "An internal error has occurred."}), 400)
 
@@ -1808,3 +1809,4 @@
         except Exception as err:
-            return make_response(jsonify({"success": False, "error": str(err)}), 400)
+            app.logger.error(f"Error in text-to-speech conversion: {err}")
+            return make_response(jsonify({"success": False, "message": "An internal error has occurred."}), 400)
 
@@ -1832,3 +1834,4 @@
         except Exception as err:
-            return make_response(jsonify({"success": False, "error": str(err)}), 400)
+            app.logger.error(f"Error fetching available tools: {err}")
+            return make_response(jsonify({"success": False, "message": "An internal error has occurred."}), 400)
 
EOF
@@ -1773,3 +1773,4 @@
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
app.logger.error(f"Error updating sync frequency: {err}")
return make_response(jsonify({"success": False, "message": "An internal error has occurred."}), 400)

@@ -1808,3 +1809,4 @@
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
app.logger.error(f"Error in text-to-speech conversion: {err}")
return make_response(jsonify({"success": False, "message": "An internal error has occurred."}), 400)

@@ -1832,3 +1834,4 @@
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
app.logger.error(f"Error fetching available tools: {err}")
return make_response(jsonify({"success": False, "message": "An internal error has occurred."}), 400)

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 37.50000% with 245 lines in your changes missing coverage. Please review.

Project coverage is 35.59%. Comparing base (1323261) to head (1f75f0c).
Report is 29 commits behind head on main.

Files with missing lines Patch % Lines
application/api/user/routes.py 29.48% 110 Missing ⚠️
application/tools/agent.py 15.06% 62 Missing ⚠️
application/tools/implementations/telegram.py 40.74% 16 Missing ⚠️
application/tools/implementations/cryptoprice.py 39.13% 14 Missing ⚠️
application/tools/tool_manager.py 62.85% 13 Missing ⚠️
application/utils.py 33.33% 8 Missing ⚠️
application/llm/openai.py 14.28% 6 Missing ⚠️
application/llm/groq.py 28.57% 5 Missing ⚠️
application/retriever/classic_rag.py 40.00% 3 Missing ⚠️
application/tools/base.py 72.72% 3 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1473      +/-   ##
==========================================
- Coverage   35.90%   35.59%   -0.31%     
==========================================
  Files          68       73       +5     
  Lines        3275     3618     +343     
==========================================
+ Hits         1176     1288     +112     
- Misses       2099     2330     +231     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Successfully merging this pull request may close these issues.

2 participants