diff --git a/Backend/Dockerfile b/Backend/Dockerfile index 14b5f64..efd7a9e 100644 --- a/Backend/Dockerfile +++ b/Backend/Dockerfile @@ -1,17 +1,11 @@ - FROM python:3.12 - WORKDIR /app - COPY . . - -RUN pip install -r requirements.txt - - RUN chmod +x wait-for-elasticsearch.sh +RUN pip install --no-cache-dir -r requirements.txt -CMD ["./wait-for-elasticsearch.sh", "python", "server.py"] +CMD ["bash", "-c", "./wait-for-elasticsearch.sh && python server.py"] \ No newline at end of file diff --git a/Backend/requirements.txt b/Backend/requirements.txt index ac9d103..510632f 100644 --- a/Backend/requirements.txt +++ b/Backend/requirements.txt @@ -1,196 +1,12 @@ -aiofiles==23.2.1 -aiohttp==3.9.5 -aiosignal==1.3.1 -annotated-types==0.7.0 -anyio==4.4.0 -argcomplete==3.5.0 -attrs==23.2.0 -beautifulsoup4==4.12.3 -black==22.12.0 -blinker==1.8.2 -blobfile==3.0.0 -certifi==2024.7.4 -cffi==1.16.0 -cfgv==3.4.0 -charset-normalizer==3.3.2 -click==8.1.7 -colorama==0.4.6 -contourpy==1.2.1 -coverage==7.6.0 -cryptography==3.4.8 -cycler==0.12.1 -dataclasses-json==0.6.7 -decorator==5.1.1 -Deprecated==1.2.14 -dirtyjson==1.0.8 -distlib==0.3.8 -distro==1.9.0 -dnspython==2.6.1 -docstring_parser==0.16 -docx2txt==0.8 -elastic-transport==8.15.0 -elasticsearch==8.15.1 -email_validator==2.2.0 -eval_type_backport==0.2.0 -fastapi==0.111.1 -fastapi-cli==0.0.4 -ffmpy==0.4.0 -filelock==3.15.4 -fire==0.6.0 -Flask==3.0.3 -Flask-Cors==5.0.0 -fonttools==4.53.1 -frozenlist==1.4.1 -fsspec==2024.6.1 -gradio==4.39.0 -gradio_client==1.1.1 -greenlet==3.0.3 -grpcio==1.63.0 -grpcio-tools==1.62.2 -h11==0.14.0 -h2==4.1.0 -hpack==4.0.0 -httpcore==1.0.5 -httptools==0.6.1 -httpx==0.27.0 -huggingface-hub==0.24.3 -hyperframe==6.0.1 -identify==2.6.0 -idna==3.7 -importlib_metadata==8.4.0 -importlib_resources==6.4.0 -iniconfig==2.0.0 -injector==0.21.0 -itsdangerous==2.2.0 -Jinja2==3.1.4 -jiter==0.5.0 -joblib==1.4.2 -jsonpatch==1.33 -jsonpath-python==1.0.6 -jsonpointer==3.0.0 -jsonschema==4.23.0 -jsonschema-specifications==2023.12.1 -kiwisolver==1.4.5 -langchain==0.3.3 -langchain-community==0.3.2 -langchain-core==0.3.10 -langchain-elasticsearch==0.3.0 -langchain-huggingface==0.1.0 -langchain-text-splitters==0.3.0 -langsmith==0.1.132 -llama-index-core==0.10.58 -llama-index-embeddings-ollama==0.1.2 -llama-index-llms-ollama==0.2.2 -llama-index-readers-file==0.1.31 -llama-index-vector-stores-qdrant==0.2.14 -llama_models==0.0.19 -llama_toolchain==0.0.17 -lxml==5.3.0 -markdown-it-py==3.0.0 -MarkupSafe==2.1.5 -marshmallow==3.21.3 -matplotlib==3.9.1.post1 -mdurl==0.1.2 -minijinja==2.0.1 -mistral_common==1.4.2 -mistral_inference==1.4.0 -mistralai==1.1.0 -mpmath==1.3.0 -multidict==6.0.5 -mypy==1.11.0 -mypy-extensions==1.0.0 -nest-asyncio==1.6.0 -networkx==3.3 -nltk==3.8.1 -nodeenv==1.9.1 -numpy==1.26.4 -ollama==0.3.0 -openai==1.51.2 -opencv-python-headless==4.10.0.84 -opentelemetry-api==1.27.0 -orjson==3.10.6 -packaging==24.1 -pandas==2.2.2 -pathspec==0.12.1 -pillow==10.4.0 -pipx==1.7.1 -platformdirs==4.2.2 -pluggy==1.5.0 -portalocker==2.10.1 -pre-commit==2.21.0 -protobuf==4.25.4 -pycparser==2.22 -pycryptodomex==3.20.0 -pydantic==2.9.2 -pydantic-extra-types==2.9.0 -pydantic-settings==2.5.2 -pydantic_core==2.23.4 -pydub==0.25.1 -Pygments==2.18.0 -pyparsing==3.1.2 -pypdf==4.3.1 -pytest==7.4.4 -pytest-asyncio==0.21.2 -pytest-cov==3.0.0 -python-dateutil==2.8.2 -python-dotenv==1.0.1 -python-multipart==0.0.9 -pytz==2024.1 -PyYAML==6.0.1 -qdrant-client==1.10.1 -referencing==0.35.1 -regex==2024.7.24 -requests==2.32.3 -requests-toolbelt==1.0.0 -retry-async==0.1.4 -rich==13.7.1 -rpds-py==0.20.0 -ruff==0.5.5 -safetensors==0.4.3 -scikit-learn==1.5.2 -scipy==1.14.1 -semantic-version==2.10.0 -sentence-transformers==3.1.0 -sentencepiece==0.2.0 -shellingham==1.5.4 -simple-parsing==0.1.6 -simsimd==5.6.3 -six==1.16.0 -sniffio==1.3.1 -soupsieve==2.5 -SQLAlchemy==2.0.31 -starlette==0.37.2 -striprtf==0.0.26 -sympy==1.13.3 -tenacity==8.5.0 -termcolor==2.4.0 -threadpoolctl==3.5.0 -tiktoken==0.7.0 -tokenizers==0.19.1 -tomlkit==0.12.0 -torch==2.4.1 -tqdm==4.66.4 -transformers==4.43.3 -typer==0.12.3 -types-PyYAML==6.0.12.20240724 -typing-inspect==0.9.0 -typing_extensions==4.12.2 -tzdata==2024.1 -ujson==5.10.0 -urllib3==2.2.2 -userpath==1.9.2 -uvicorn==0.30.3 -virtualenv==20.26.3 -watchdog==4.0.1 -watchfiles==0.22.0 -websockets==11.0.3 -Werkzeug==3.0.4 -wrapt==1.16.0 -xformers==0.0.28.post1 -yarl==1.9.4 -zipp==3.20.2 -flask +Flask flask-cors +requests +elasticsearch +langchain +langchain-huggingface +langchain-elasticsearch psycopg2-binary google-auth - +transformers +sentence-transformers>=2.2.2 +accelerate diff --git a/Backend/server.py b/Backend/server.py index 471ec38..09b7d89 100644 --- a/Backend/server.py +++ b/Backend/server.py @@ -152,6 +152,42 @@ def login(): logger.error(f"Error during user login: {e}", exc_info=True) return jsonify({'error': str(e)}), 500 + +@app.route('/api/update_profile', methods=['PUT']) +def update_profile(): + data = request.get_json() + email = data.get('email') + if not email: + return jsonify({'error': 'Email is required'}), 400 + + # Fields to update; if not provided, the current value remains. + name = data.get('name') + phone = data.get('phone') + role = data.get('role') + bio = data.get('bio') + picture = data.get('picture') + + try: + with conn.cursor(cursor_factory=RealDictCursor) as cur: + cur.execute( + """ + UPDATE users + SET name = COALESCE(%s, name), + phone = COALESCE(%s, phone), + role = COALESCE(%s, role), + bio = COALESCE(%s, bio), + picture = COALESCE(%s, picture) + WHERE email = %s + """, + (name, phone, role, bio, picture, email) + ) + conn.commit() + logger.info(f"Profile updated for {email}") + return jsonify({'message': 'Profile updated successfully'}), 200 + except Exception as e: + logger.error(f"Error updating profile: {e}") + return jsonify({'error': str(e)}), 500 + @app.route('/api/chat', methods=['POST']) def chat(): logger.info("Received chat request") diff --git a/Backend/wait-for-elasticsearch.sh b/Backend/wait-for-elasticsearch.sh index cd6e8bc..262c396 100644 --- a/Backend/wait-for-elasticsearch.sh +++ b/Backend/wait-for-elasticsearch.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash echo "Waiting for Elasticsearch..." @@ -8,4 +8,4 @@ done echo "Elasticsearch is ready. Starting backend..." -exec "$@" +exec "$@" \ No newline at end of file diff --git a/frontend/src/pages/HomePage.tsx b/frontend/src/pages/HomePage.tsx index a9cab6a..b134ce8 100644 --- a/frontend/src/pages/HomePage.tsx +++ b/frontend/src/pages/HomePage.tsx @@ -127,7 +127,7 @@ const HomePage: React.FC = () => { console.error('Error:', error); setChatHistory((prev) => [ ...prev, - { sender: 'Assistant', text: 'Что-то пошло не так' }, + { sender: 'Assistant', text: 'Something went wrong' }, ]); } }; diff --git a/prepare.sh b/prepare.sh index d22742e..e103577 100644 --- a/prepare.sh +++ b/prepare.sh @@ -2,4 +2,4 @@ echo "Prepearing Docker images..." docker-compose up --build -echo "Preparation ended." +echo "Preparation ended." \ No newline at end of file