upd endpoint saving data, upd dockerfile backend with fixing elasticsearch waiting
This commit is contained in:
parent
b2acfd7643
commit
d1e5ec019d
@ -1,17 +1,11 @@
|
|||||||
|
|
||||||
FROM python:3.12
|
FROM python:3.12
|
||||||
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
|
||||||
RUN pip install -r requirements.txt
|
|
||||||
|
|
||||||
|
|
||||||
RUN chmod +x wait-for-elasticsearch.sh
|
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"]
|
@ -1,196 +1,12 @@
|
|||||||
aiofiles==23.2.1
|
Flask
|
||||||
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-cors
|
flask-cors
|
||||||
|
requests
|
||||||
|
elasticsearch
|
||||||
|
langchain
|
||||||
|
langchain-huggingface
|
||||||
|
langchain-elasticsearch
|
||||||
psycopg2-binary
|
psycopg2-binary
|
||||||
google-auth
|
google-auth
|
||||||
|
transformers
|
||||||
|
sentence-transformers>=2.2.2
|
||||||
|
accelerate
|
||||||
|
@ -152,6 +152,42 @@ def login():
|
|||||||
logger.error(f"Error during user login: {e}", exc_info=True)
|
logger.error(f"Error during user login: {e}", exc_info=True)
|
||||||
return jsonify({'error': str(e)}), 500
|
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'])
|
@app.route('/api/chat', methods=['POST'])
|
||||||
def chat():
|
def chat():
|
||||||
logger.info("Received chat request")
|
logger.info("Received chat request")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
|
|
||||||
echo "Waiting for Elasticsearch..."
|
echo "Waiting for Elasticsearch..."
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ const HomePage: React.FC = () => {
|
|||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
setChatHistory((prev) => [
|
setChatHistory((prev) => [
|
||||||
...prev,
|
...prev,
|
||||||
{ sender: 'Assistant', text: 'Что-то пошло не так' },
|
{ sender: 'Assistant', text: 'Something went wrong' },
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user