-
Notifications
You must be signed in to change notification settings - Fork 930
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
feat(agents-api): Add humanize_text function to supported PyExp functions #1187
base: dev
Are you sure you want to change the base?
Conversation
|
GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
---|---|---|---|---|---|
15754213 | Triggered | Bearer Token | 057afd5 | agents-api/agents_api/activities/humanization_utils.py | View secret |
15754214 | Triggered | Bearer Token | 057afd5 | agents-api/agents_api/activities/humanization_utils.py | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
CI Feedback 🧐(Feedback updated until commit 125adcb)A test triggered by this PR failed. Here is an AI-generated analysis of the failure:
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
WalkthroughThis PR introduces a new utility for text humanization within the agents API. A new file, Changes
Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts belowEmoji Descriptions:
Interact with the Bot:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
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.
❌ Changes requested. Reviewed everything up to 3504da7 in 3 minutes and 55 seconds
More details
- Looked at
588
lines of code in8
files - Skipped
0
files when reviewing. - Skipped posting
12
drafted comments based on config settings.
1. agents-api/agents_api/activities/humanization_utils.py:92
-
Draft comment:
This is a duplicate of the existinghumanize_openai
function. Consider using or extending the existing function instead of creating a new one. -
function
humanize_openai
(humanization_utils.py) -
Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
The comment is technically correct - these functions are nearly identical. However, looking at the broader context, both functions are actually used distinctly in process_paragraph() where there's a conditional: "paragraph = humanize_openai(paragraph) if is_chatgpt else humanize(paragraph)". This suggests the duplication is intentional to handle different cases, even if the implementation is currently similar.
The comment fails to notice that both functions are used in a conditional statement for different purposes. Just because functions look similar doesn't mean they should be combined if they serve different logical purposes.
While the functions are similar now, keeping them separate allows for future divergence in implementation based on the is_chatgpt flag. The current similarity may be temporary.
The comment should be deleted because the apparent duplication appears to be intentional design to handle different cases (chatgpt vs non-chatgpt), even though the current implementations are similar.
2. agents-api/agents_api/env.py:137
- Draft comment:
The zerogpt_api_key is parsed but not used in is_human_zerogpt. Integrate the API key or remove the unused variable to avoid confusion. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. agents-api/docker-compose.yml:42
- Draft comment:
Consider adding ZEROGPT_API_KEY to the environment variables if it's required by is_human_zerogpt. - Reason this comment was not posted:
Comment was on unchanged code.
4. agents-api/agents_api/activities/humanization_utils.py:70
- Draft comment:
Consider renaming function 'grammer' to 'grammar' for clarity and correctness. - Reason this comment was not posted:
Marked as duplicate.
5. agents-api/agents_api/activities/humanization_utils.py:230
- Draft comment:
Potential infinite recursion in 'is_human_zerogpt'. Consider adding a maximum retry limit or break condition to avoid endless loops. - Reason this comment was not posted:
Marked as duplicate.
6. agents-api/agents_api/activities/humanization_utils.py:290
- Draft comment:
The double reversal in 'replace_with_homoglyphs' is non-obvious and may impact performance; consider refactoring for clarity. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50%
The double reversal is actually a clever technique to randomize which instances of characters get replaced, since replace() is deterministic left-to-right. While non-obvious at first glance, it serves a specific purpose. The performance impact would be negligible for typical text lengths. A comment suggesting to refactor this would likely lead to a more complex solution.
Maybe the code could benefit from an explanatory comment about why the reversal is done, rather than changing the implementation.
The current implementation is actually simpler and more efficient than alternatives would be. The non-obviousness could be solved with a comment rather than refactoring.
The comment should be deleted as it suggests refactoring a valid implementation that is actually quite elegant once understood.
7. agents-api/agents_api/env.py:140
- Draft comment:
The 'zerogpt_api_key' variable is defined but not used. Remove it or integrate it into 'is_human_zerogpt' if needed. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50%
The comment header clearly states these API keys are needed for the humanize_text method. Without seeing the actual humanize_text method implementation, we can't verify if zerogpt_api_key is truly unused. The grouping with other similar API keys and the explicit comment suggests this is intentional. We don't have strong evidence that the variable is actually unused.
I might be wrong because the variable isn't included in the final environment dictionary. Maybe it really is unused.
The environment dictionary doesn't include any of the API keys, so that's not strong evidence. The explicit comment about these being needed for humanize_text is more compelling.
Delete this comment because we don't have strong evidence that zerogpt_api_key is actually unused, and there's explicit documentation saying it's needed.
8. agents-api/docker-compose.yml:44
- Draft comment:
Consider exposing 'ZEROGPT_API_KEY' in docker-compose if 'is_human_zerogpt' eventually requires authentication. - Reason this comment was not posted:
Comment was on unchanged code.
9. agents-api/agents_api/activities/utils.py:217
- Draft comment:
Consider using 'str.join()' to combine processed paragraphs in 'humanize_text' for better readability and performance. - Reason this comment was not posted:
Confidence changes required:50%
<= threshold50%
None
10. agents-api/agents_api/activities/humanization_utils.py:17
- Draft comment:
Typographical error: In the humanize_prompt string, 'princeton' should be capitalized to 'Princeton'. - Reason this comment was not posted:
Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50%
This is a very minor typographical suggestion. The prompt is used internally for AI text generation and the capitalization of "princeton" has no functional impact on the code's behavior. The prompt is not user-facing content where proper capitalization would be important for professionalism.
Perhaps proper capitalization should be maintained throughout the codebase as a matter of consistency and professionalism, even for internal strings?
While code quality is important, this level of nitpicking about capitalization in an internal prompt string doesn't meet the bar for requiring a code change. The comment adds noise without meaningful value.
Delete this comment as it suggests a trivial change that has no functional impact and doesn't meaningfully improve code quality.
11. agents-api/agents_api/activities/humanization_utils.py:21
- Draft comment:
Typographical error: In the grammar_prompt, 'chaning' should be corrected to 'changing'. - Reason this comment was not posted:
Marked as duplicate.
12. agents-api/agents_api/activities/humanization_utils.py:109
- Draft comment:
Typographical error: The function name 'grammer' is misspelled and should likely be 'grammar' to match conventional spelling. - Reason this comment was not posted:
Marked as duplicate.
Workflow ID: wflow_c4OMD51kXYGh3zS1
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
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.
👍 Looks good to me! Incremental review on 125adcb in 57 seconds
More details
- Looked at
57
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
6
drafted comments based on config settings.
1. agents-api/agents_api/activities/humanization_utils.py:282
- Draft comment:
Minor: Instead of reassigning and then returning, the direct return of the joined string is cleaner. Ensure this aligns with our string handling standards. - Reason this comment was not posted:
Comment looked like it was already resolved.
2. agents-api/agents_api/activities/utils.py:219
- Draft comment:
New humanize_text function: Consider using a list to accumulate paragraphs and then join at the end for performance and cleaner concatenation. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. agents-api/agents_api/activities/humanization_utils.py:10
- Draft comment:
The order of imported environment variables changed. While not a functional issue, consider keeping a consistent order for clarity. - Reason this comment was not posted:
Confidence changes required:20%
<= threshold50%
None
4. agents-api/agents_api/activities/humanization_utils.py:270
- Draft comment:
Minor style improvement: using a direct return with ''.join(text_chars) is cleaner. - Reason this comment was not posted:
Confidence changes required:0%
<= threshold50%
None
5. agents-api/agents_api/activities/utils.py:219
- Draft comment:
In the new humanize_text function, consider accumulating processed paragraphs in a list and then joining them instead of repeatedly concatenating strings, which can be inefficient for large texts. - Reason this comment was not posted:
Confidence changes required:50%
<= threshold50%
None
6. agents-api/agents_api/activities/humanization_utils.py:20
- Draft comment:
In the humanize_prompt (line 20), consider changing "22 year old at princeton" to "22-year-old at Princeton" for proper grammar and capitalization. - Reason this comment was not posted:
Comment was not on a location in the diff, so it can't be submitted as a review comment.
Workflow ID: wflow_Fw4dcDYaKdjHM8Ut
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
PR Type
Enhancement, Documentation
Description
Introduced
humanize_text
function for advanced text transformations.Added new utility functions for text processing and splitting.
Updated environment variables and dependencies to support
humanize_text
.Documented
humanize_text
usage in the advanced Python expression guide.Changes walkthrough 📝
humanization_utils.py
Introduced utilities for text humanization and evaluation
agents-api/agents_api/activities/humanization_utils.py
humanize_text
related utility functions for text transformation.em-dash insertion.
utils.py
Added `humanize_text` function and utility integration
agents-api/agents_api/activities/utils.py
humanize_text
function for text transformation.process_paragraph
andsplit_with_langchain
utilities.humanize_text
in the allowed functions list.env.py
Added API key environment variables
agents-api/agents_api/env.py
keys.
docker-compose.yml
Updated Docker Compose with API key environment variables
agents-api/docker-compose.yml
.env.example
Added API key placeholders to `.env.example`
.env.example
python-expression.mdx
Added documentation for `humanize_text` function
documentation/docs/advanced/python-expression.mdx
humanize_text
function in the advanced Python expressionguide.
pyproject.toml
Updated dependencies for text processing
agents-api/pyproject.toml
langchain-text-splitters
anddeep-translator
to dependencies.EntelligenceAI PR Summary
Purpose:
Changes:
humanization_utils.py
for text translation, grammatical correction, and stylistic modification.humanize_text
function into utilities; updated environment configurations with API keys.humanize_text
function usage.Impact:
Important
Introduces
humanize_text
function for text transformation, updates configurations, and documents usage in the agents API.humanize_text
function inutils.py
for text transformation.humanization_utils.py
for text translation, grammatical correction, and stylistic modification.humanize_text
into allowed functions inutils.py
.env.py
anddocker-compose.yml
with API key configurations for Sapling, Copyleaks, and ZeroGPT.humanize_text
usage inpython-expression.mdx
..env.example
.langchain-text-splitters
anddeep-translator
topyproject.toml
.This description was created by
for 125adcb. It will automatically update as commits are pushed.