From 649b02b93b75bd0e857cc8996fe961572c9bbf2d Mon Sep 17 00:00:00 2001 From: JeffreyChen Date: Thu, 3 Aug 2023 18:08:14 +0800 Subject: [PATCH 1/3] Add test and doc Add test and doc --- .github/dependabot.yml | 11 ++ .../workflows/re_edge_gpt_dev_python3_10.yml | 31 ++++ .../workflows/re_edge_gpt_dev_python3_11.yml | 31 ++++ .../workflows/re_edge_gpt_dev_python3_8.yml | 31 ++++ .../workflows/re_edge_gpt_dev_python3_9.yml | 31 ++++ .../re_edge_gpt_stable_python3_10.yml | 31 ++++ .../re_edge_gpt_stable_python3_11.yml | 31 ++++ .../re_edge_gpt_stable_python3_8.yml | 31 ++++ .../re_edge_gpt_stable_python3_9.yml | 31 ++++ CODE_OF_CONDUCT.md | 132 ++++++++++++++++++ CONTRIBUTING.md | 46 ++++++ dev_requirements.txt | 6 + test/unit_test/test_bot.py | 22 +++ 13 files changed, 465 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/re_edge_gpt_dev_python3_10.yml create mode 100644 .github/workflows/re_edge_gpt_dev_python3_11.yml create mode 100644 .github/workflows/re_edge_gpt_dev_python3_8.yml create mode 100644 .github/workflows/re_edge_gpt_dev_python3_9.yml create mode 100644 .github/workflows/re_edge_gpt_stable_python3_10.yml create mode 100644 .github/workflows/re_edge_gpt_stable_python3_11.yml create mode 100644 .github/workflows/re_edge_gpt_stable_python3_8.yml create mode 100644 .github/workflows/re_edge_gpt_stable_python3_9.yml create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 dev_requirements.txt create mode 100644 test/unit_test/test_bot.py diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..ba1c6b8 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "pip" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" diff --git a/.github/workflows/re_edge_gpt_dev_python3_10.yml b/.github/workflows/re_edge_gpt_dev_python3_10.yml new file mode 100644 index 0000000..c110881 --- /dev/null +++ b/.github/workflows/re_edge_gpt_dev_python3_10.yml @@ -0,0 +1,31 @@ +name: ReEdgeGPT Dev Python3.10 + +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + schedule: + - cron: "0 8 * * *" + +permissions: + contents: read + +jobs: + build_dev_version: + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + pip install -r dev_requirements.txt + - name: Test Bot + env: + EDGE_COOKIES: ${{ secrets.EDGE_COOKIES }} + run: python ./test/unit_test/test_bot.py \ No newline at end of file diff --git a/.github/workflows/re_edge_gpt_dev_python3_11.yml b/.github/workflows/re_edge_gpt_dev_python3_11.yml new file mode 100644 index 0000000..234ef62 --- /dev/null +++ b/.github/workflows/re_edge_gpt_dev_python3_11.yml @@ -0,0 +1,31 @@ +name: ReEdgeGPT Dev Python3.11 + +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + schedule: + - cron: "0 8 * * *" + +permissions: + contents: read + +jobs: + build_dev_version: + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: "3.11" + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + pip install -r dev_requirements.txt + - name: Test Bot + env: + EDGE_COOKIES: ${{ secrets.EDGE_COOKIES }} + run: python ./test/unit_test/test_bot.py \ No newline at end of file diff --git a/.github/workflows/re_edge_gpt_dev_python3_8.yml b/.github/workflows/re_edge_gpt_dev_python3_8.yml new file mode 100644 index 0000000..6ecb130 --- /dev/null +++ b/.github/workflows/re_edge_gpt_dev_python3_8.yml @@ -0,0 +1,31 @@ +name: ReEdgeGPT Dev Python3.8 + +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + schedule: + - cron: "0 8 * * *" + +permissions: + contents: read + +jobs: + build_dev_version: + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v3 + with: + python-version: "3.8" + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + pip install -r dev_requirements.txt + - name: Test Bot + env: + EDGE_COOKIES: ${{ secrets.EDGE_COOKIES }} + run: python ./test/unit_test/test_bot.py diff --git a/.github/workflows/re_edge_gpt_dev_python3_9.yml b/.github/workflows/re_edge_gpt_dev_python3_9.yml new file mode 100644 index 0000000..4dafcbe --- /dev/null +++ b/.github/workflows/re_edge_gpt_dev_python3_9.yml @@ -0,0 +1,31 @@ +name: ReEdgeGPT Dev Python3.9 + +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + schedule: + - cron: "0 8 * * *" + +permissions: + contents: read + +jobs: + build_dev_version: + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: "3.9" + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + pip install -r dev_requirements.txt + - name: Test Bot + env: + EDGE_COOKIES: ${{ secrets.EDGE_COOKIES }} + run: python ./test/unit_test/test_bot.py \ No newline at end of file diff --git a/.github/workflows/re_edge_gpt_stable_python3_10.yml b/.github/workflows/re_edge_gpt_stable_python3_10.yml new file mode 100644 index 0000000..7d674fb --- /dev/null +++ b/.github/workflows/re_edge_gpt_stable_python3_10.yml @@ -0,0 +1,31 @@ +name: ReEdgeGPT Stable Python3.10 + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: "0 8 * * *" + +permissions: + contents: read + +jobs: + build_dev_version: + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + pip install -r requirements.txt + - name: Test Bot + env: + EDGE_COOKIES: ${{ secrets.EDGE_COOKIES }} + run: python ./test/unit_test/test_bot.py \ No newline at end of file diff --git a/.github/workflows/re_edge_gpt_stable_python3_11.yml b/.github/workflows/re_edge_gpt_stable_python3_11.yml new file mode 100644 index 0000000..fb859ee --- /dev/null +++ b/.github/workflows/re_edge_gpt_stable_python3_11.yml @@ -0,0 +1,31 @@ +name: ReEdgeGPT Stable Python3.11 + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: "0 8 * * *" + +permissions: + contents: read + +jobs: + build_dev_version: + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.11 + uses: actions/setup-python@v3 + with: + python-version: "3.11" + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + pip install -r requirements.txt + - name: Test Bot + env: + EDGE_COOKIES: ${{ secrets.EDGE_COOKIES }} + run: python ./test/unit_test/test_bot.py \ No newline at end of file diff --git a/.github/workflows/re_edge_gpt_stable_python3_8.yml b/.github/workflows/re_edge_gpt_stable_python3_8.yml new file mode 100644 index 0000000..ce59ef7 --- /dev/null +++ b/.github/workflows/re_edge_gpt_stable_python3_8.yml @@ -0,0 +1,31 @@ +name: ReEdgeGPT Stable Python3.8 + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: "0 8 * * *" + +permissions: + contents: read + +jobs: + build_dev_version: + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v3 + with: + python-version: "3.8" + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + pip install -r requirements.txt + - name: Test Bot + env: + EDGE_COOKIES: ${{ secrets.EDGE_COOKIES }} + run: python ./test/unit_test/test_bot.py \ No newline at end of file diff --git a/.github/workflows/re_edge_gpt_stable_python3_9.yml b/.github/workflows/re_edge_gpt_stable_python3_9.yml new file mode 100644 index 0000000..e468c68 --- /dev/null +++ b/.github/workflows/re_edge_gpt_stable_python3_9.yml @@ -0,0 +1,31 @@ +name: ReEdgeGPT Stable Python3.9 + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: "0 8 * * *" + +permissions: + contents: read + +jobs: + build_dev_version: + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: "3.9" + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel + pip install -r requirements.txt + - name: Test Bot + env: + EDGE_COOKIES: ${{ secrets.EDGE_COOKIES }} + run: python ./test/unit_test/test_bot.py \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..609e99d --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,132 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[INSERT CONTACT METHOD]. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..97f2f37 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,46 @@ +# Why should we follow this guidelines +> * Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. +> * In return, they should reciprocate that respect in addressing your issue, assessing changes, and helping you finalize your pull requests. + +## Ground Rules +> * Ensure cross-platform compatibility for every change that's accepted. Windows, Mac, Ubuntu Linux. +> * Keep feature versions as small as possible, preferably one new feature per version. +> * Make sure all tests pass and CI/CD pipelines pass. + +## What you can do in this repo +> * Doc translate, renew, improving,etc. +> * Feature requests or writing new feature etc. +> * Submitting the bug reports, bug fix etc. +> * Sharing this repo like blog or stackoverflow even Facebook and Twitter . + +## Getting started +> * Create you own fork repo. +> * Edit code on you own repo. +> * Make sure all tests pass and CI/CD pipelines pass. +> * Open pull request. + +> * As a rule of thumb, changes are obvious fixes if they do not introduce any new functionality or creative thinking. As long as the change does not affect functionality, some likely examples include the following: +>> * Spelling / grammar fixes +>> * Typo correction, white space and formatting changes +>> * Comment clean up +>> * Bug fixes that change default return values or error codes stored in constants +>> * Adding logging messages or debugging output +>> * Changes to ‘metadata’ files like Gemfile, .gitignore, build scripts, etc. +>> * Moving source files from one directory or package to another + +## How to report a bug +> * If you find a security vulnerability, do NOT open an issue. Email instead. + +> * When filing an issue, make sure to answer these five questions: +>> * What version of python are you using (python version)? +>> * What operating system and processor architecture are you using? +>> * What did you do? +>> * What did you expect to see? +>> * What did you see instead? +>> * General questions should go to discord instead. + +## How to suggest a feature +> * Pen an issue on our issues list on GitHub which describes the feature you would like to see, why you need it, and how it should work. + +## Code review process +> * If all tests pass we will check code on every week Sa and Su day \ No newline at end of file diff --git a/dev_requirements.txt b/dev_requirements.txt new file mode 100644 index 0000000..0ca6a09 --- /dev/null +++ b/dev_requirements.txt @@ -0,0 +1,6 @@ +aiohttp +certifi +httpx +prompt_toolkit +requests +rich diff --git a/test/unit_test/test_bot.py b/test/unit_test/test_bot.py new file mode 100644 index 0000000..06c8d85 --- /dev/null +++ b/test/unit_test/test_bot.py @@ -0,0 +1,22 @@ +import asyncio +import json +from os import getenv + +from re_edge_gpt import Chatbot +from re_edge_gpt import ConversationStyle + + +async def test_ask() -> None: + bot = await Chatbot.create(cookies=getenv("EDGE_COOKIES")) + response = await bot.ask( + prompt="find me some information about the new ai released by meta.", + conversation_style=ConversationStyle.balanced, + simplify_response=True, + ) + await bot.close() + print(json.dumps(response, indent=2)) + assert response + + +if __name__ == "__main__": + asyncio.run(test_ask()) From bfa644452d50aba46d922b131eb1824cb3729cd6 Mon Sep 17 00:00:00 2001 From: JeffreyChen Date: Thu, 3 Aug 2023 19:03:28 +0800 Subject: [PATCH 2/3] Update and fix --- dev_requirements.txt | 1 + pyproject.toml | 4 ++-- requirements.txt | 1 + dev.toml => stable.toml | 4 ++-- 4 files changed, 6 insertions(+), 4 deletions(-) rename dev.toml => stable.toml (95%) diff --git a/dev_requirements.txt b/dev_requirements.txt index 0ca6a09..3ea7c3d 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -4,3 +4,4 @@ httpx prompt_toolkit requests rich +re_edge_gpt diff --git a/pyproject.toml b/pyproject.toml index 0626315..e296c4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,8 +5,8 @@ requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] -name = "re_edge_gpt" -version = "0.0.01" +name = "re_edge_gpt_dev" +version = "0.0.02" authors = [ { name = "JE-Chen", email = "jechenmailman@gmail.com" }, ] diff --git a/requirements.txt b/requirements.txt index 0ca6a09..3ea7c3d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ httpx prompt_toolkit requests rich +re_edge_gpt diff --git a/dev.toml b/stable.toml similarity index 95% rename from dev.toml rename to stable.toml index 744b985..1ec394e 100644 --- a/dev.toml +++ b/stable.toml @@ -5,8 +5,8 @@ requires = ["setuptools>=61.0"] build-backend = "setuptools.build_meta" [project] -name = "re_edge_gpt_dev" -version = "0.0.01" +name = "re_edge_gpt" +version = "0.0.02" authors = [ { name = "JE-Chen", email = "jechenmailman@gmail.com" }, ] From 8a046180b6db1fa3fbdd926a4df9d72fd8099901 Mon Sep 17 00:00:00 2001 From: JeffreyChen Date: Thu, 3 Aug 2023 19:21:06 +0800 Subject: [PATCH 3/3] test --- test/unit_test/test_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit_test/test_bot.py b/test/unit_test/test_bot.py index 06c8d85..20cdae0 100644 --- a/test/unit_test/test_bot.py +++ b/test/unit_test/test_bot.py @@ -7,7 +7,7 @@ async def test_ask() -> None: - bot = await Chatbot.create(cookies=getenv("EDGE_COOKIES")) + bot = await Chatbot.create(cookies=json.loads(getenv("EDGE_COOKIES"))) response = await bot.ask( prompt="find me some information about the new ai released by meta.", conversation_style=ConversationStyle.balanced,