From 17257394e983aef571722481a1aeba12c0a5848f Mon Sep 17 00:00:00 2001 From: InnerHeiwa <162490166+InnerHeiwa@users.noreply.github.com> Date: Fri, 22 Nov 2024 11:27:37 +0000 Subject: [PATCH 1/2] testing --- backend/.env.example | 12 ------------ backend/authentication/views.py | 1 + backend/backend/settings.py | 7 +++++-- backend/dependencies.txt | 2 +- backend/gpt/views.py | 1 + backend/src/libs/__init__.py | 6 +++--- backend/src/utils/gpt.py | 3 +-- frontend/{.env.local.example => .env} | 0 8 files changed, 12 insertions(+), 20 deletions(-) delete mode 100644 backend/.env.example rename frontend/{.env.local.example => .env} (100%) diff --git a/backend/.env.example b/backend/.env.example deleted file mode 100644 index 2cffd6649..000000000 --- a/backend/.env.example +++ /dev/null @@ -1,12 +0,0 @@ -FRONTEND_URL=http://127.0.0.1:3000 -BACKEND_URL=http://127.0.0.1:8000 - -BE_ADMIN_EMAIL=admin@admin.com -BE_ADMIN_PASSWORD=admin - -DJANGO_SECRET_KEY=... - -OPENAI_API_TYPE=... -OPENAI_API_BASE=... -OPENAI_API_VERSION=... -OPENAI_API_KEY=... diff --git a/backend/authentication/views.py b/backend/authentication/views.py index 068100805..bb035e8f1 100644 --- a/backend/authentication/views.py +++ b/backend/authentication/views.py @@ -59,6 +59,7 @@ def logout_view(request): @api_view(["POST"]) + def register_view(request): email = request.data.get("email") password = request.data.get("password") diff --git a/backend/backend/settings.py b/backend/backend/settings.py index 9de4f024a..2af00a15f 100644 --- a/backend/backend/settings.py +++ b/backend/backend/settings.py @@ -138,12 +138,15 @@ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" CORS_ALLOWED_ORIGINS = [ - FRONTEND_URL, + "http://127.0.0.1:3000", + "http://localhost:3000", + ] CORS_ALLOW_CREDENTIALS = True CSRF_TRUSTED_ORIGINS = [ - FRONTEND_URL, + "http://localhost:3000", + ] SESSION_COOKIE_SECURE = True diff --git a/backend/dependencies.txt b/backend/dependencies.txt index 2363ba87e..13cc84e0f 100644 --- a/backend/dependencies.txt +++ b/backend/dependencies.txt @@ -1,4 +1,4 @@ -aiohttp==3.8.5 +aiohttp==3.9.0 aiosignal==1.3.1 asgiref==3.7.2 async-timeout==4.0.3 diff --git a/backend/gpt/views.py b/backend/gpt/views.py index e9c81cb2e..fbfa7a4f6 100644 --- a/backend/gpt/views.py +++ b/backend/gpt/views.py @@ -29,6 +29,7 @@ def get_answer(request): @api_view(["POST"]) def get_conversation(request): data = request.data + print(data) return StreamingHttpResponse( get_conversation_answer(data["conversation"], data["model"], stream=True), content_type="text/html" ) diff --git a/backend/src/libs/__init__.py b/backend/src/libs/__init__.py index 214cf63db..95d6d7199 100644 --- a/backend/src/libs/__init__.py +++ b/backend/src/libs/__init__.py @@ -6,7 +6,7 @@ __all__ = ["openai"] load_dotenv() -openai.api_type = os.getenv("OPENAI_API_TYPE") -openai.api_base = os.getenv("OPENAI_API_BASE") -openai.api_version = os.getenv("OPENAI_API_VERSION") +# openai.api_type = os.getenv("OPENAI_API_TYPE") +# openai.api_base = os.getenv("OPENAI_API_BASE") +# openai.api_version = os.getenv("OPENAI_API_VERSION") openai.api_key = os.getenv("OPENAI_API_KEY") diff --git a/backend/src/utils/gpt.py b/backend/src/utils/gpt.py index f8a4aa023..d3cd01963 100644 --- a/backend/src/utils/gpt.py +++ b/backend/src/utils/gpt.py @@ -63,12 +63,11 @@ def get_gpt_title(prompt: str, response: str): def get_conversation_answer(conversation: list[dict[str, str]], model: str, stream: bool = True): kwargs = {**GPT_40_PARAMS, **dict(stream=stream)} engine = GPT_VERSIONS[model].engine - for resp in openai.ChatCompletion.create( engine=engine, messages=[{"role": "system", "content": "You are a helpful assistant."}, *conversation], **kwargs, - ): + ): choices = resp.get("choices", []) if not choices: continue diff --git a/frontend/.env.local.example b/frontend/.env similarity index 100% rename from frontend/.env.local.example rename to frontend/.env From 095caddc4bbbfa3b59975bdfe4f49d88e0ceabd8 Mon Sep 17 00:00:00 2001 From: InnerHeiwa <162490166+InnerHeiwa@users.noreply.github.com> Date: Fri, 22 Nov 2024 12:00:47 +0000 Subject: [PATCH 2/2] Initial commit