diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 9f3c79d9acc557d23041f6d335b7ead8836813fc..0000000000000000000000000000000000000000 --- a/.gitignore +++ /dev/null @@ -1,130 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ -cookies.json diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 3b0b9d391fe0d2515043513f2f8326e09251c292..0000000000000000000000000000000000000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,31 +0,0 @@ -repos: - - repo: https://github.com/asottile/reorder_python_imports - rev: v3.9.0 - hooks: - - id: reorder-python-imports - args: [--py37-plus] - - repo: https://github.com/asottile/add-trailing-comma - rev: v2.3.0 - hooks: - - id: add-trailing-comma - args: [--py36-plus] - - repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 - hooks: - - id: pyupgrade - args: [--py37-plus] - - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: debug-statements - - id: double-quote-string-fixer - - id: name-tests-test - - id: requirements-txt-fixer - - repo: https://github.com/psf/black - rev: 22.10.0 - hooks: - - id: black diff --git a/App/Analytics/AnalyticsRoutes.py b/App/Analytics/AnalyticsRoutes.py new file mode 100644 index 0000000000000000000000000000000000000000..c903c95a7d69efeb8f832a5a04397502dd6b40a0 --- /dev/null +++ b/App/Analytics/AnalyticsRoutes.py @@ -0,0 +1,10 @@ +from fastapi import APIRouter, status +from .Schemas import BaseRequest, editRequest +from .Model import Comments +from App.Users.Model import User +from App.Post.Model import Post + +analytics_router = APIRouter(tags=["Analytics"]) + + + diff --git a/App/Analytics/Model.py b/App/Analytics/Model.py new file mode 100644 index 0000000000000000000000000000000000000000..c3fd5eddcf54e3cf597d165a126f482818e8a1ad --- /dev/null +++ b/App/Analytics/Model.py @@ -0,0 +1,21 @@ +import asyncio +import orm +import psycopg2 +import datetime +import pydantic +from App.modelInit import database, models +from App.Users.Model import User + + +class Analytics(orm.Model): + tablename = "Analytics" + registry = models + fields = { + "id": orm.Integer(primary_key=True), + "user": orm.ForeignKey(User, on_delete=orm.CASCADE,allow_null=True), # Optional for unknown users. + "post": orm.ForeignKey(User, on_delete=orm.CASCADE), + "ip": orm.String(max_length=100), + "device": orm.String(max_length=100), + "country": orm.String(max_length=100), + "createdAt": orm.DateTime(index=True, default=datetime.datetime.now), + } diff --git a/App/Analytics/Schemas.py b/App/Analytics/Schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..db428d1a28bf0d331dc81d2dccc843ed9b6aebef --- /dev/null +++ b/App/Analytics/Schemas.py @@ -0,0 +1,15 @@ +from typing import List, Optional +from pydantic import EmailStr, BaseModel +from datetime import date, datetime, time, timedelta + + +class BaseRequest(BaseModel): + user: Optional[int] + id: Optional[int] + content: Optional[str] + + +class editRequest(BaseRequest): + updatedAt: datetime = datetime.now() + + \ No newline at end of file diff --git a/App/Authentication.py b/App/Authentication.py new file mode 100644 index 0000000000000000000000000000000000000000..db68d9005b1e3aff8748a72db025106f2d4aa4e8 --- /dev/null +++ b/App/Authentication.py @@ -0,0 +1,7 @@ +from fastapi import APIRouter, status +from fastapi.security import OAuth2PasswordBearer,OAuth2PasswordRequestForm + + + + + diff --git a/App/CommentLikes/CommentLikesRoutes.py b/App/CommentLikes/CommentLikesRoutes.py new file mode 100644 index 0000000000000000000000000000000000000000..76edd4bee7888d36a96c49ec1eb5fd91d0b303ec --- /dev/null +++ b/App/CommentLikes/CommentLikesRoutes.py @@ -0,0 +1,11 @@ +from fastapi import APIRouter, status +from .Schemas import BaseRequest, editRequest +from .Model import Comments +from App.Users.Model import User +from App.Post.Model import Post + +commentLikes_router = APIRouter(tags=["CommentLikes"]) + +@commentLikes_router.get('/likes/comments/add') +async def add_commentLike(): + pass \ No newline at end of file diff --git a/App/CommentLikes/Model.py b/App/CommentLikes/Model.py new file mode 100644 index 0000000000000000000000000000000000000000..259ea3bdeba3cf9b6c6301e28ce75045ca95aa1d --- /dev/null +++ b/App/CommentLikes/Model.py @@ -0,0 +1,18 @@ +import asyncio +import orm +import psycopg2 +import datetime +import pydantic +from App.modelInit import database, models +from App.Users.Model import User +from App.Post.Model import Post + +class CommentLike(orm.Model): + tablename = "commentlikes" + registry = models + fields = { + "id": orm.Integer(primary_key=True), + "user": orm.ForeignKey(User, on_delete=orm.CASCADE), + "post": orm.ForeignKey(Post, on_delete=orm.CASCADE), + "createdAt": orm.DateTime(index=True, default=datetime.datetime.now), + } diff --git a/App/CommentLikes/Schemas.py b/App/CommentLikes/Schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..0301ea12197a81cccbbe2e3615244b1e71bccc0d --- /dev/null +++ b/App/CommentLikes/Schemas.py @@ -0,0 +1,15 @@ +from typing import List, Optional +from pydantic import EmailStr, BaseModel +from datetime import date, datetime, time, timedelta + + +class addLike (BaseModel): + postId:int + userId:int + +class deleteLike (BaseModel): + id:int + postId:int + userId:int + + \ No newline at end of file diff --git a/App/Comments/CommentRoutes.py b/App/Comments/CommentRoutes.py new file mode 100644 index 0000000000000000000000000000000000000000..aba7634517e55c09b8953510cf18cf03f5e586d5 --- /dev/null +++ b/App/Comments/CommentRoutes.py @@ -0,0 +1,53 @@ +from fastapi import APIRouter, status +from .Schemas import createComment,editComment,deleteComment,allComments +from .Model import Comment +from App.Users.Model import User +from App.Post.Model import Post +from App.utils import get_user_and_post +import asyncio +postLike_router = APIRouter(tags=["PostLikes"]) + + + + +comment_router = APIRouter(tags=["Comments"]) + + +@comment_router.post("/comment/create") +async def create_comment(comment: createComment): + user,_post = await get_user_and_post(comment) + db_data = await Comment.objects.create(user=user, content=comment.content,post=_post) + return {"code": 200, "message": "success", "payload": data.__dict__} + + +@comment_router.post("/comment/edit") +async def edit_comment(comment: editComment): + # user,_post = await get_user_and_post(comment) + db_comment = await Comment.objects.filter(id=comment.id).first() + if not db_comment: + return {"code": 400, "message": "Comment does not exist", "payload": None} + if db_comment.user.id != comment.userId: + return { + "code": 400, + "message": "This comment belongs to a different user", + "payload": None, + } + db_data = await db_comment.update(content=comment.content) + return {"code": 200, "message": "success", "payload": None} + + +@comment_router.post("/comment/all") +async def all_comments(comment: allComments): + + user = await User.objects.filter(id=comment.userId).first() + if not user: + return {"code": 400, "message": "User does not exist", "payload": None} + db_comment = await Comment.objects.filter(user=user).all() + + if not db_comment: + return {"code": 400, "message": "Comment does not exist", "payload": None} + return { + "code": 200, + "message": "success", + "payload": [i.__dict__ for i in db_comment], + } diff --git a/App/Comments/Model.py b/App/Comments/Model.py new file mode 100644 index 0000000000000000000000000000000000000000..0797ea69780259652ec6c414b61e8596cff8ef47 --- /dev/null +++ b/App/Comments/Model.py @@ -0,0 +1,21 @@ +import asyncio +import orm +import psycopg2 +import datetime +import pydantic +from App.modelInit import database, models +from App.Users.Model import User + + +class Comment(orm.Model): + tablename = "comments" + registry = models + fields = { + "id": orm.Integer(primary_key=True), + "user": orm.ForeignKey(User, on_delete=orm.CASCADE), + "post": orm.ForeignKey(User, on_delete=orm.CASCADE), + "content": orm.String(max_length=100), + "likes": orm.Integer(index=True, default=0), + "createdAt": orm.DateTime(index=True, default=datetime.datetime.now), + "updatedAt": orm.DateTime(index=True, default=datetime.datetime.now), + } diff --git a/App/Comments/Schemas.py b/App/Comments/Schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..2562dd04f2a56f53c4e86a67217f28763477e3c4 --- /dev/null +++ b/App/Comments/Schemas.py @@ -0,0 +1,24 @@ +from typing import List, Optional +from pydantic import EmailStr, BaseModel +from datetime import date, datetime, time, timedelta + + +class createComment(BaseModel): + userId: int + content: str + postId:int + + +class editComment(BaseModel): + id:int + userId: int + content: str + postId:int + +class deleteComment(BaseModel): + id:int + userId: int + postId:int + +class allComments(BaseModel): + userId: int diff --git a/App/Comments/__pycache__/CommentRoutes.cpython-38.pyc b/App/Comments/__pycache__/CommentRoutes.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8518080772529418f81f503f77b3e0817dbda979 Binary files /dev/null and b/App/Comments/__pycache__/CommentRoutes.cpython-38.pyc differ diff --git a/App/Comments/__pycache__/Model.cpython-38.pyc b/App/Comments/__pycache__/Model.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..77c9ce0cc34b18ed4d845871428f4df24d029554 Binary files /dev/null and b/App/Comments/__pycache__/Model.cpython-38.pyc differ diff --git a/App/Comments/__pycache__/Schemas.cpython-38.pyc b/App/Comments/__pycache__/Schemas.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f5dfdafce8a062120cfc0bc096381b20fa6a2c95 Binary files /dev/null and b/App/Comments/__pycache__/Schemas.cpython-38.pyc differ diff --git a/App/Post/Model.py b/App/Post/Model.py new file mode 100644 index 0000000000000000000000000000000000000000..caeb15247c40a4897c4a30045d50862d6ec3845b --- /dev/null +++ b/App/Post/Model.py @@ -0,0 +1,19 @@ +import asyncio +import orm +import psycopg2 +import datetime +import pydantic +from App.modelInit import database, models +from App.Users.Model import User + + +class Post(orm.Model): + tablename = "posts" + registry = models + fields = { + "id": orm.Integer(primary_key=True), + "pageId": orm.Integer(index=True,default=0), + "content": orm.JSON(), + "recommendations": orm.JSON(allow_null=True), + "createdAt": orm.DateTime(index=True, default=datetime.datetime.now), + } diff --git a/App/Post/PostRoutes.py b/App/Post/PostRoutes.py new file mode 100644 index 0000000000000000000000000000000000000000..7567fb45580e7ad6fd5f2a0c71efae0904e9fc22 --- /dev/null +++ b/App/Post/PostRoutes.py @@ -0,0 +1,24 @@ +from fastapi import APIRouter, status +from .Schemas import createPost,editPost,getPost +from .Model import Post + +post_router = APIRouter(tags=["Posts"]) + + +@post_router.post("/post/create") +async def create_post(post: createPost): + data=await Post.objects.create(**post.dict()) + return {"code": 200, "message": "success", "payload": data.__dict__} + +@post_router.post("/post/update") +async def create_post(post: editPost): + temp=await Post.objects.get(id= post.id) + data=await temp.update(recommendations=post.recommendations,content=post.content) + # data=await Post.objects.update(**post.dict()) + return {"code": 200, "message": "success", "payload": temp.__dict__} + + +@post_router.post("/post/get") +async def create_post(post: getPost): + data=await Post.objects.get(id=post.id) + return {"code": 200, "message": "success", "payload": data.__dict__} \ No newline at end of file diff --git a/App/Post/Schemas.py b/App/Post/Schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..93860a9f7d2c13695ee8f39c2cacba5a08d6ecc9 --- /dev/null +++ b/App/Post/Schemas.py @@ -0,0 +1,19 @@ +from typing import List, Optional +from pydantic import EmailStr, BaseModel +from datetime import date, datetime, time, timedelta + + +class editPost(BaseModel): + id: Optional[int] + content:Optional[dict] + recommendations:Optional[dict] + + +class createPost(BaseModel): + content:Optional[dict] + recommendations:Optional[dict] + +class getPost(BaseModel): + id: Optional[int] + + \ No newline at end of file diff --git a/App/Post/__pycache__/Model.cpython-38.pyc b/App/Post/__pycache__/Model.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4300c65ea4b852837da3494faa4e7042e02b511f Binary files /dev/null and b/App/Post/__pycache__/Model.cpython-38.pyc differ diff --git a/App/Post/__pycache__/PostRoutes.cpython-38.pyc b/App/Post/__pycache__/PostRoutes.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ffceea7599cb28012831cd4e38aa55d07dcf494e Binary files /dev/null and b/App/Post/__pycache__/PostRoutes.cpython-38.pyc differ diff --git a/App/Post/__pycache__/Schemas.cpython-38.pyc b/App/Post/__pycache__/Schemas.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c96d30e45c232af4a8faed0f28376bca27acba02 Binary files /dev/null and b/App/Post/__pycache__/Schemas.cpython-38.pyc differ diff --git a/App/PostLikes/Model.py b/App/PostLikes/Model.py new file mode 100644 index 0000000000000000000000000000000000000000..5fe2b1f26edd68ddc40886618c28b8a2ae62b93d --- /dev/null +++ b/App/PostLikes/Model.py @@ -0,0 +1,20 @@ +import asyncio +import orm +import psycopg2 +import datetime +import pydantic +from App.modelInit import database, models +from App.Users.Model import User +from App.Post.Model import Post + + +class PostLike(orm.Model): + tablename = "postlikes" + registry = models + fields = { + "id": orm.Integer(primary_key=True), + "user": orm.ForeignKey(User, on_delete=orm.CASCADE), + "post": orm.ForeignKey(Post, on_delete=orm.CASCADE), + "createdAt": orm.DateTime(index=True, default=datetime.datetime.now) + } + diff --git a/App/PostLikes/PostLikesRoutes.py b/App/PostLikes/PostLikesRoutes.py new file mode 100644 index 0000000000000000000000000000000000000000..79c6183525f282adbe4bcf8ba038d76a501ada5f --- /dev/null +++ b/App/PostLikes/PostLikesRoutes.py @@ -0,0 +1,41 @@ +from fastapi import APIRouter, Depends +from .Schemas import addLike,deleteLike +from .Model import PostLike +from App.Users.Model import User +from App.Post.Model import Post +from App.utils import get_user_and_post +import asyncio +postLike_router = APIRouter(tags=["PostLikes"]) + + + + +@postLike_router.post("/postLike/add") +async def add_postLike(post: addLike): + user,_post=await get_user_and_post(post) #validate if both the post and user exist + previos =await PostLike.objects.filter(user=user).filter(post=_post).first() + if previos: + return {"code": 400, "message": "you already liked it", "payload": None} + + data=await PostLike.objects.create(post=_post,user=user) + return {"code": 200, "message": "success", "payload": data.__dict__} + +@postLike_router.post("/postLike/delete") +async def create_post(post: deleteLike): + user,_post=await get_user_and_post(post) + data=await PostLike.objects.filter(id=post.id).first() + if not data: + return {"code": 400, "message": "Does not exist", "payload": None} + if user.id == data.user.id and _post.id == data.post.id: + await data.delete() + return {"code": 200, "message": "success", "payload": None} + + +@postLike_router.post("/postLike/get") +async def create_post(post: deleteLike): + user,_post=await get_user_and_post(post) + data=await PostLike.objects.filter(id=post.id).first() + if not data: + return {"code": 400, "message": "Does not exist", "payload": None} + if user.id == data.user.id and _post.id == data.post.user.id: + return {"code": 200, "message": "success", "payload": data.__dict__} diff --git a/App/PostLikes/Schemas.py b/App/PostLikes/Schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..4b4649df21e40395ca3e06b009d2d4cfb753cd81 --- /dev/null +++ b/App/PostLikes/Schemas.py @@ -0,0 +1,16 @@ +from typing import List, Optional +from pydantic import EmailStr, BaseModel +from datetime import date, datetime, time, timedelta + + +class addLike (BaseModel): + postId:int + userId:int + +class deleteLike (BaseModel): + id:int + postId:int + userId:int + + + \ No newline at end of file diff --git a/App/PostLikes/__pycache__/Model.cpython-38.pyc b/App/PostLikes/__pycache__/Model.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cec8e0918210d765833f00917bf1d241a52bacc8 Binary files /dev/null and b/App/PostLikes/__pycache__/Model.cpython-38.pyc differ diff --git a/App/PostLikes/__pycache__/PostLikesRoutes.cpython-38.pyc b/App/PostLikes/__pycache__/PostLikesRoutes.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..98175bc36212bf7fd635fb840e1363e085115cc3 Binary files /dev/null and b/App/PostLikes/__pycache__/PostLikesRoutes.cpython-38.pyc differ diff --git a/App/PostLikes/__pycache__/Schemas.cpython-38.pyc b/App/PostLikes/__pycache__/Schemas.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..393c9213f29b59d5017c86de151e85c82e7fc3fa Binary files /dev/null and b/App/PostLikes/__pycache__/Schemas.cpython-38.pyc differ diff --git a/App/Settings.py b/App/Settings.py new file mode 100644 index 0000000000000000000000000000000000000000..ae04d0a8436abdfc07a5d0e0f2baae27d0aa42f0 --- /dev/null +++ b/App/Settings.py @@ -0,0 +1,3 @@ +class Settings: + ALGORITHM = "HS256" + HASH="86c5ceb27e1bf441130299c0209e5f35b88089f62c06b2b09d65772274f12057" diff --git a/App/Users/Model.py b/App/Users/Model.py new file mode 100644 index 0000000000000000000000000000000000000000..dc6c82ebb23c9ee8b7d90dd74ba05d4007b94cb4 --- /dev/null +++ b/App/Users/Model.py @@ -0,0 +1,28 @@ +import asyncio +import orm +import psycopg2 +import datetime +import pydantic +from passlib.context import CryptContext +from App.modelInit import database, models + +pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") + + +class User(orm.Model): + tablename = "users" + registry = models + fields = { + "id": orm.Integer(primary_key=True), + "name": orm.String(max_length=100, index=True), + "email": orm.String(max_length=100, index=True, unique=True), + "password": orm.String(max_length=100, index=True), + "phoneNumber": orm.String(max_length=100, index=True, allow_null=True), + "account_type": orm.Integer(index=True, default=1), + "createdAt": orm.DateTime(index=True, default=datetime.datetime.now), + "updatedAt": orm.DateTime(index=True, default=datetime.datetime.now), + "lastLogin": orm.DateTime(index=True, default=datetime.datetime.now), + } + + def verify_password(self, plain_password): + return pwd_context.verify(plain_password, self.password) diff --git a/App/Users/Schemas.py b/App/Users/Schemas.py new file mode 100644 index 0000000000000000000000000000000000000000..8791f87648a91187625fa38d358105a96f61c2bb --- /dev/null +++ b/App/Users/Schemas.py @@ -0,0 +1,15 @@ +from typing import List, Optional +from pydantic import EmailStr, BaseModel +from passlib.context import CryptContext + +pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") + + +class BaseRequest(BaseModel): + email: EmailStr + name: str + password: str + phoneNumber: Optional[str] + + def hash_password(self): + self.password = pwd_context.hash(self.password) diff --git a/App/Users/UserRoutes.py b/App/Users/UserRoutes.py new file mode 100644 index 0000000000000000000000000000000000000000..6960d5b32f4c6a3bdb8f8e131bf3bc035d2b72c1 --- /dev/null +++ b/App/Users/UserRoutes.py @@ -0,0 +1,27 @@ +from fastapi import APIRouter, status +from .Schemas import BaseRequest +from .Model import User +from sqlalchemy import and_ +from fastapi.security import OAuth2PasswordBearer,OAuth2PasswordRequestForm + +oauth_scheme=OAuth2PasswordBearer(tokenUrl='/user/login') +user_router = APIRouter(tags=["User"]) + + +@user_router.post("/user/register") +async def register_user(user: BaseRequest): + data = await User.objects.filter(email=user.email).first() + if data != None: + return {"code": 400, "message": "user exists", "payload": None} + else: + user.hash_password() + sample = await User.objects.create(**user.dict()) + return {"code": 200, "message": "success", "payload": None} + + +@user_router.post("/user/login") +async def register_user(user: BaseRequest): + db_user = await User.objects.filter(email=user.email).first() + if db_user.verify_password(user.password): + return {"code": 200, "message": "success", "payload": db_user.__dict__} + return {"code": 401, "message": "Invalid Credentials", "payload": None} diff --git a/App/Users/__pycache__/Model.cpython-38.pyc b/App/Users/__pycache__/Model.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ed2898b2160544f8e42fb8ff2af7ebaeaf5e0233 Binary files /dev/null and b/App/Users/__pycache__/Model.cpython-38.pyc differ diff --git a/App/Users/__pycache__/Schemas.cpython-38.pyc b/App/Users/__pycache__/Schemas.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..396f471e23b3fd6ef66a678372c5d044cf696b8b Binary files /dev/null and b/App/Users/__pycache__/Schemas.cpython-38.pyc differ diff --git a/App/Users/__pycache__/UserRoutes.cpython-38.pyc b/App/Users/__pycache__/UserRoutes.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f6cd291cd8695ec2f613f79b043e28658e58f1f1 Binary files /dev/null and b/App/Users/__pycache__/UserRoutes.cpython-38.pyc differ diff --git a/App/__init__.py b/App/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/App/__pycache__/__init__.cpython-38.pyc b/App/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d10edbca5f6d5f22eb7fe1ca26a3727dfead37c8 Binary files /dev/null and b/App/__pycache__/__init__.cpython-38.pyc differ diff --git a/App/__pycache__/app.cpython-38.pyc b/App/__pycache__/app.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bcd17b0f10cf4dfdc007d61fcdc64fbf8427b534 Binary files /dev/null and b/App/__pycache__/app.cpython-38.pyc differ diff --git a/App/__pycache__/modelInit.cpython-38.pyc b/App/__pycache__/modelInit.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6016b62daab645b752e10f494b60131a992ee76b Binary files /dev/null and b/App/__pycache__/modelInit.cpython-38.pyc differ diff --git a/App/__pycache__/utils.cpython-38.pyc b/App/__pycache__/utils.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..30d54c93b11229bbdfbb6942deec1c4b53b66745 Binary files /dev/null and b/App/__pycache__/utils.cpython-38.pyc differ diff --git a/App/app.py b/App/app.py new file mode 100644 index 0000000000000000000000000000000000000000..e00d72daeecbb7038417eec75251d5896d09e101 --- /dev/null +++ b/App/app.py @@ -0,0 +1,36 @@ +from fastapi import FastAPI +from .Users.UserRoutes import user_router +from .Post.PostRoutes import post_router +from .PostLikes.PostLikesRoutes import postLike_router +from .Comments.CommentRoutes import comment_router +from .modelInit import models, database + +app = FastAPI() + + +@app.on_event("startup") +async def startup_event(): + await models.create_all() + if not database.is_connected: + await database.connect() + print("connected!") + + +@app.get("/") +async def landing_page(): + return {"code": 200, "message": "still running"} + + +app.include_router(user_router) +app.include_router(comment_router) +app.include_router(post_router) +app.include_router(postLike_router) + + +async def main(): + pass + + +# if __name__ == "__main__": +# main() +# uvicorn.run(app, host="0.0.0.0", port=8000) diff --git a/App/modelInit.py b/App/modelInit.py new file mode 100644 index 0000000000000000000000000000000000000000..6642e0c6822d072e0fa82a1677dec05fc14a6bf6 --- /dev/null +++ b/App/modelInit.py @@ -0,0 +1,9 @@ +import databases +import orm +import psycopg2 + +database = databases.Database( + "postgresql+asyncpg://postgres:CW38stnBqQnCEHe@db.vqbjlhcywjisidxeipdg.supabase.co:5432/postgres" +) +# databases = databases.Database(**args) +models = orm.ModelRegistry(database=database) diff --git a/App/utils.py b/App/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..ae97c7fff9a12243ba9aa2f66881eb43cfe60777 --- /dev/null +++ b/App/utils.py @@ -0,0 +1,14 @@ +from App.Users.Model import User +from App.Post.Model import Post +import asyncio +from fastapi import HTTPException + +async def get_user_and_post(content): + try: + # user = None + # post = await Post.objects.get(id=content.postId) + # print(post.id) + user,post = await asyncio.gather(*[User.objects.get(id=content.userId), Post.objects.get(id=content.postId)]) + except: + raise HTTPException(status_code=400, detail="Invalid data") + return user,post \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index fdddb29aa445bf3d6a5d843d6dd77e10a9f99657..0000000000000000000000000000000000000000 --- a/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -This is free and unencumbered software released into the public domain. - -Anyone is free to copy, modify, publish, use, compile, sell, or -distribute this software, either in source code form or as a compiled -binary, for any purpose, commercial or non-commercial, and by any -means. - -In jurisdictions that recognize copyright laws, the author or authors -of this software dedicate any and all copyright interest in the -software to the public domain. We make this dedication for the benefit -of the public at large and to the detriment of our heirs and -successors. We intend this dedication to be an overt act of -relinquishment in perpetuity of all present and future rights to this -software under copyright law. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -For more information, please refer to diff --git a/README.md b/README.md deleted file mode 100644 index e5b3d3d896f091b9e1a16fd1e9c4d425fe993c37..0000000000000000000000000000000000000000 --- a/README.md +++ /dev/null @@ -1,156 +0,0 @@ -
- EdgeGPT - - # Edge GPT - - *The reverse engineering the chat feature of the new version of Bing* - -
- -

- - PyPI version - - Python version -

- ---- - -## Table of Contents -- [Edge GPT](#edge-gpt) - - [Table of Contents](#table-of-contents) - - [Setup](#setup) - - [Install package](#install-package) - - [Requirements](#requirements) - - [Checking access (Required)](#checking-access-required) - - [Getting authentication (Required)](#getting-authentication-required) - - [Usage](#usage) - - [Quick start](#quick-start) - - [Developer demo](#developer-demo) - - [Work in progress](#work-in-progress) - - [Star History](#star-history) - - [Contributors](#contributors) - -## Setup - -### Install package -```bash -python3 -m pip install EdgeGPT --upgrade -``` - -### Requirements -- python 3.8+ -- A Microsoft Account with early access to http://bing.com/chat (Required) - - -
- - - ### Checking access (Required) - - - -- Install the latest version of Microsoft Edge -- Open http://bing.com/chat -- If you see a chat feature, you are good to go - -
- - -
- - - ### Getting authentication (Required) - - - -- Install the cookie editor extension for [Chrome](https://chrome.google.com/webstore/detail/cookie-editor/hlkenndednhfkekhgcdicdfddnkalmdm) or [Firefox](https://addons.mozilla.org/en-US/firefox/addon/cookie-editor/) -- Go to `bing.com` -- Open the extension -- Click "Export" on the bottom right (This saves your cookies to clipboard) -- Paste your cookies into a file `cookies.json` - -
- - - -## Usage - -### Quick start - -``` - $ python3 -m EdgeGPT -h - - EdgeGPT - A demo of reverse engineering the Bing GPT chatbot - Repo: github.com/acheong08/EdgeGPT - By: Antonio Cheong - - !help for help - - Type !exit to exit - Enter twice to send message or set --enter-once to send one line message - -usage: EdgeGPT.py [-h] [--enter-once] [--no-stream] [--style {creative,balanced,precise}] --cookie-file COOKIE_FILE - -options: - -h, --help show this help message and exit - --enter-once - --no-stream - --style {creative,balanced,precise} - --cookie-file COOKIE_FILE -``` - ------ - -### Developer demo - -Three ways to pass in cookies: - -- Environment variable: `export COOKIE_FILE=/path/to/cookies.json`. -- Specify the path to `cookies.json` in the argument `cookiePath` like this: - - ```python - bot = Chatbot(cookiePath='./cookie.json') - ``` - -- Pass in the cookies directly by the argument `cookies`, like this: - - ```python - with open('./cookie.json', 'r') as f: - cookies = json.load(f) - bot = Chatbot(cookies=cookies) - ``` - - -Use Async for the best experience - -Reference code for more advanced example of usage: - -```python -import asyncio -from EdgeGPT import Chatbot, ConversationStyle - -async def main(): - bot = Chatbot() - print(await bot.ask(prompt="Hello world", conversation_style=ConversationStyle.creative)) - await bot.close() - - -if __name__ == "__main__": - asyncio.run(main()) - -``` - -## Work in progress -- Error handling - -## Star History -[![Star History Chart](https://api.star-history.com/svg?repos=acheong08/EdgeGPT&type=Date)](https://star-history.com/#acheong08/EdgeGPT&Date) - - -## Contributors -This project exists thanks to all the people who contribute. - - - - diff --git a/__pycache__/app.cpython-38.pyc b/__pycache__/app.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9fda837779bce249db46fb6aa3b7dd8240e4619a Binary files /dev/null and b/__pycache__/app.cpython-38.pyc differ diff --git a/data.txt b/data.txt new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/data.txt @@ -0,0 +1 @@ + diff --git a/example.env b/example.env deleted file mode 100644 index 7c0ddc0dc35536ee607be64e35891821b1e77a46..0000000000000000000000000000000000000000 --- a/example.env +++ /dev/null @@ -1 +0,0 @@ -export BING_U="" diff --git a/requirements.txt b/requirements.txt index 4b4e8d16226a8321408209aae2aaa08ec9fe123c..412782e0a9e5cfc2582a4c18d937b7373ada940f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,16 @@ -asyncio -requests -rich -websockets +asyncpg==0.27.0 +click==8.1.3 +databases==0.7.0 +fastapi==0.92.0 +Flask==2.2.2 +greenlet==2.0.2 +itsdangerous==2.1.2 +orm==0.3.1 +psycopg2-binary==2.9.5 +SQLAlchemy==1.4.46 +starlette==0.25.0 +typesystem==0.3.1 +Werkzeug==2.2.2 +passlib # for password hashing +pydantic[email] +python-multipart \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 999a811e451acc4ae5dc01a12b1e31bce6ab4f22..0000000000000000000000000000000000000000 --- a/setup.cfg +++ /dev/null @@ -1,3 +0,0 @@ -[metadata] -description_file=README.md -license_files=LICENSE diff --git a/setup.py b/setup.py deleted file mode 100644 index 7d26aed10b5ee2fe563f8ef0b3323f8f56b98a05..0000000000000000000000000000000000000000 --- a/setup.py +++ /dev/null @@ -1,35 +0,0 @@ -from setuptools import find_packages -from setuptools import setup - -setup( - name="EdgeGPT", - version="0.0.60", - license="GNU General Public License v2.0", - author="Antonio Cheong", - author_email="acheong@student.dalat.org", - description="Reverse engineered Edge Chat API", - packages=find_packages("src"), - package_dir={"": "src"}, - url="https://github.com/acheong08/EdgeGPT", - project_urls={"Bug Report": "https://github.com/acheong08/EdgeGPT/issues/new"}, - install_requires=[ - "asyncio", - "httpx", - "websockets", - "rich", - "certifi", - "prompt_toolkit", - ], - long_description=open("README.md", encoding="utf-8").read(), - long_description_content_type="text/markdown", - py_modules=["EdgeGPT"], - classifiers=[ - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", - "Intended Audience :: Developers", - "Topic :: Software Development :: Libraries :: Python Modules", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - ], -) diff --git a/src/EdgeGPT.py b/src/EdgeGPT.py deleted file mode 100644 index f41d0da6d0d39441418da6f98949d77b3ece5928..0000000000000000000000000000000000000000 --- a/src/EdgeGPT.py +++ /dev/null @@ -1,465 +0,0 @@ -""" -Main.py -""" -from __future__ import annotations - -import argparse -import asyncio -import json -import os -import random -import ssl -import uuid -from enum import Enum -from typing import Generator -from typing import Literal -from typing import Optional -from typing import Union - -import certifi -import httpx -import websockets.client as websockets -from prompt_toolkit import PromptSession -from prompt_toolkit.auto_suggest import AutoSuggestFromHistory -from prompt_toolkit.completion import WordCompleter -from prompt_toolkit.history import InMemoryHistory -from rich.live import Live -from rich.markdown import Markdown - -DELIMITER = "\x1e" - - -# Generate random IP between range 13.104.0.0/14 -FORWARDED_IP = ( - f"13.{random.randint(104, 107)}.{random.randint(0, 255)}.{random.randint(0, 255)}" -) - -HEADERS = { - "accept": "application/json", - "accept-language": "en-US,en;q=0.9", - "content-type": "application/json", - "sec-ch-ua": '"Not_A Brand";v="99", "Microsoft Edge";v="110", "Chromium";v="110"', - "sec-ch-ua-arch": '"x86"', - "sec-ch-ua-bitness": '"64"', - "sec-ch-ua-full-version": '"109.0.1518.78"', - "sec-ch-ua-full-version-list": '"Chromium";v="110.0.5481.192", "Not A(Brand";v="24.0.0.0", "Microsoft Edge";v="110.0.1587.69"', - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-model": "", - "sec-ch-ua-platform": '"Windows"', - "sec-ch-ua-platform-version": '"15.0.0"', - "sec-fetch-dest": "empty", - "sec-fetch-mode": "cors", - "sec-fetch-site": "same-origin", - "x-ms-client-request-id": str(uuid.uuid4()), - "x-ms-useragent": "azsdk-js-api-client-factory/1.0.0-beta.1 core-rest-pipeline/1.10.0 OS/Win32", - "Referer": "https://www.bing.com/search?q=Bing+AI&showconv=1&FORM=hpcodx", - "Referrer-Policy": "origin-when-cross-origin", - "x-forwarded-for": FORWARDED_IP, -} - -HEADERS_INIT_CONVER = { - "authority": "edgeservices.bing.com", - "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7", - "accept-language": "en-US,en;q=0.9", - "cache-control": "max-age=0", - "sec-ch-ua": '"Chromium";v="110", "Not A(Brand";v="24", "Microsoft Edge";v="110"', - "sec-ch-ua-arch": '"x86"', - "sec-ch-ua-bitness": '"64"', - "sec-ch-ua-full-version": '"110.0.1587.69"', - "sec-ch-ua-full-version-list": '"Chromium";v="110.0.5481.192", "Not A(Brand";v="24.0.0.0", "Microsoft Edge";v="110.0.1587.69"', - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-model": '""', - "sec-ch-ua-platform": '"Windows"', - "sec-ch-ua-platform-version": '"15.0.0"', - "sec-fetch-dest": "document", - "sec-fetch-mode": "navigate", - "sec-fetch-site": "none", - "sec-fetch-user": "?1", - "upgrade-insecure-requests": "1", - "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.69", - "x-edge-shopping-flag": "1", -} - -ssl_context = ssl.create_default_context() -ssl_context.load_verify_locations(certifi.where()) - - -class NotAllowedToAccess(Exception): - pass - - -class ConversationStyle(Enum): - creative = "h3relaxedimg" - balanced = "galileo" - precise = "h3precise" - - -CONVERSATION_STYLE_TYPE = Optional[ - Union[ConversationStyle, Literal["creative", "balanced", "precise"]] -] - - -def append_identifier(msg: dict) -> str: - """ - Appends special character to end of message to identify end of message - """ - # Convert dict to json string - return json.dumps(msg) + DELIMITER - - -class ChatHubRequest: - """ - Request object for ChatHub - """ - - def __init__( - self, - conversation_signature: str, - client_id: str, - conversation_id: str, - invocation_id: int = 0, - ) -> None: - self.struct: dict = {} - - self.client_id: str = client_id - self.conversation_id: str = conversation_id - self.conversation_signature: str = conversation_signature - self.invocation_id: int = invocation_id - - def update( - self, - prompt: str, - conversation_style: CONVERSATION_STYLE_TYPE, - options: list | None = None, - ) -> None: - """ - Updates request object - """ - if options is None: - options = [ - "deepleo", - "enable_debug_commands", - "disable_emoji_spoken_text", - "enablemm", - ] - if conversation_style: - if not isinstance(conversation_style, ConversationStyle): - conversation_style = getattr(ConversationStyle, conversation_style) - options = [ - "deepleo", - "enable_debug_commands", - "disable_emoji_spoken_text", - "enablemm", - conversation_style.value, - ] - self.struct = { - "arguments": [ - { - "source": "cib", - "optionsSets": options, - "isStartOfSession": self.invocation_id == 0, - "message": { - "author": "user", - "inputMethod": "Keyboard", - "text": prompt, - "messageType": "Chat", - }, - "conversationSignature": self.conversation_signature, - "participant": { - "id": self.client_id, - }, - "conversationId": self.conversation_id, - }, - ], - "invocationId": str(self.invocation_id), - "target": "chat", - "type": 4, - } - self.invocation_id += 1 - - -class Conversation: - """ - Conversation API - """ - - def __init__(self, cookiePath: str = "", cookies: dict | None = None) -> None: - self.struct: dict = { - "conversationId": None, - "clientId": None, - "conversationSignature": None, - "result": {"value": "Success", "message": None}, - } - self.session = httpx.Client() - self.session.headers.update( - { - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36", - }, - ) - if cookies is not None: - cookie_file = cookies - else: - f = ( - open(cookiePath, encoding="utf8").read() - if cookiePath - else open(os.environ.get("COOKIE_FILE"), encoding="utf-8").read() - ) - cookie_file = json.loads(f) - for cookie in cookie_file: - self.session.cookies.set(cookie["name"], cookie["value"]) - url = "https://edgeservices.bing.com/edgesvc/turing/conversation/create" - # Send GET request - response = self.session.get( - url, - timeout=30, - headers=HEADERS_INIT_CONVER, - ) - if response.status_code != 200: - print(f"Status code: {response.status_code}") - print(response.text) - raise Exception("Authentication failed") - try: - self.struct = response.json() - if self.struct["result"]["value"] == "UnauthorizedRequest": - raise NotAllowedToAccess(self.struct["result"]["message"]) - except (json.decoder.JSONDecodeError, NotAllowedToAccess) as exc: - raise Exception( - "Authentication failed. You have not been accepted into the beta.", - ) from exc - - -class ChatHub: - """ - Chat API - """ - - def __init__(self, conversation: Conversation) -> None: - self.wss: websockets.WebSocketClientProtocol | None = None - self.request: ChatHubRequest - self.loop: bool - self.task: asyncio.Task - self.request = ChatHubRequest( - conversation_signature=conversation.struct["conversationSignature"], - client_id=conversation.struct["clientId"], - conversation_id=conversation.struct["conversationId"], - ) - - async def ask_stream( - self, - prompt: str, - conversation_style: CONVERSATION_STYLE_TYPE = None, - ) -> Generator[str, None, None]: - """ - Ask a question to the bot - """ - if self.wss: - if not self.wss.closed: - await self.wss.close() - # Check if websocket is closed - self.wss = await websockets.connect( - "wss://sydney.bing.com/sydney/ChatHub", - extra_headers=HEADERS, - max_size=None, - ssl=ssl_context, - ) - await self.__initial_handshake() - # Construct a ChatHub request - self.request.update(prompt=prompt, conversation_style=conversation_style) - # Send request - await self.wss.send(append_identifier(self.request.struct)) - final = False - while not final: - objects = str(await self.wss.recv()).split(DELIMITER) - for obj in objects: - if obj is None or obj == "": - continue - response = json.loads(obj) - if response.get("type") == 1 and response["arguments"][0].get( - "messages", - ): - yield False, response["arguments"][0]["messages"][0][ - "adaptiveCards" - ][0]["body"][0].get("text") - elif response.get("type") == 2: - final = True - yield True, response - - async def __initial_handshake(self): - await self.wss.send(append_identifier({"protocol": "json", "version": 1})) - await self.wss.recv() - - async def close(self): - """ - Close the connection - """ - if self.wss and not self.wss.closed: - await self.wss.close() - - -class Chatbot: - """ - Combines everything to make it seamless - """ - - def __init__(self, cookiePath: str = "", cookies: dict | None = None) -> None: - self.cookiePath: str = cookiePath - self.cookies: dict | None = cookies - self.chat_hub: ChatHub = ChatHub(Conversation(self.cookiePath, self.cookies)) - - async def ask( - self, - prompt: str, - conversation_style: CONVERSATION_STYLE_TYPE = None, - ) -> dict: - """ - Ask a question to the bot - """ - async for final, response in self.chat_hub.ask_stream( - prompt=prompt, - conversation_style=conversation_style, - ): - if final: - return response - self.chat_hub.wss.close() - - async def ask_stream( - self, - prompt: str, - conversation_style: CONVERSATION_STYLE_TYPE = None, - ) -> Generator[str, None, None]: - """ - Ask a question to the bot - """ - async for response in self.chat_hub.ask_stream( - prompt=prompt, - conversation_style=conversation_style, - ): - yield response - - async def close(self): - """ - Close the connection - """ - await self.chat_hub.close() - - async def reset(self): - """ - Reset the conversation - """ - await self.close() - self.chat_hub = ChatHub(Conversation(self.cookiePath, self.cookies)) - - -async def get_input_async( - session: PromptSession = None, - completer: WordCompleter = None, -) -> str: - """ - Multiline input function. - """ - return await session.prompt_async( - completer=completer, - multiline=True, - auto_suggest=AutoSuggestFromHistory(), - ) - - -def create_session() -> PromptSession: - return PromptSession(history=InMemoryHistory()) - - -async def main(): - """ - Main function - """ - print("Initializing...") - print("Enter `alt+enter` or `escape+enter` to send a message") - bot = Chatbot() - session = create_session() - while True: - print("\nYou:") - question = await get_input_async(session=session) - print() - print() - if question == "!exit": - break - elif question == "!help": - print( - """ - !help - Show this help message - !exit - Exit the program - !reset - Reset the conversation - """, - ) - continue - elif question == "!reset": - await bot.reset() - continue - print("Bot:") - if args.no_stream: - print( - (await bot.ask(prompt=question, conversation_style=args.style))["item"][ - "messages" - ][1]["adaptiveCards"][0]["body"][0]["text"], - ) - else: - if args.rich: - wrote = 0 - md = Markdown("") - with Live(md, auto_refresh=False) as live: - async for final, response in bot.ask_stream( - prompt=question, - conversation_style=args.style, - ): - if not final: - if wrote > len(response): - print(md) - print(Markdown("***Bing revoked the response.***")) - wrote = len(response) - md = Markdown(response) - live.update(md, refresh=True) - else: - wrote = 0 - async for final, response in bot.ask_stream( - prompt=question, - conversation_style=args.style, - ): - if not final: - print(response[wrote:], end="", flush=True) - wrote = len(response) - print() - await bot.close() - - -if __name__ == "__main__": - print( - """ - EdgeGPT - A demo of reverse engineering the Bing GPT chatbot - Repo: github.com/acheong08/EdgeGPT - By: Antonio Cheong - - !help for help - - Type !exit to exit - Enter twice to send message or set --enter-once to send one line message - """, - ) - parser = argparse.ArgumentParser() - parser.add_argument("--enter-once", action="store_true") - parser.add_argument("--no-stream", action="store_true") - parser.add_argument("--rich", action="store_true") - parser.add_argument( - "--style", - choices=["creative", "balanced", "precise"], - default="balanced", - ) - parser.add_argument( - "--cookie-file", - type=str, - default="cookies.json", - required=True, - ) - args = parser.parse_args() - os.environ["COOKIE_FILE"] = args.cookie_file - args = parser.parse_args() - asyncio.run(main()) diff --git a/src/__init__.py b/src/__init__.py deleted file mode 100644 index b6e690fd59145ce8900fd9ab8d8a996ee7d33834..0000000000000000000000000000000000000000 --- a/src/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from . import *