Skip to content

Commit

Permalink
chore: add setting
Browse files Browse the repository at this point in the history
  • Loading branch information
sverben committed Apr 17, 2024
1 parent be8b59f commit 66e7abd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.11-slim

RUN apt -yy update && apt -yy install ffmpeg && apt clean
RUN apt -yy update && apt -yy install ffmpeg cmake && apt clean

COPY app/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt
Expand Down
1 change: 1 addition & 0 deletions api/app/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Settings(BaseSettings):
database_url: str
client_id: str
client_secret: str
weaviate_url: str


settings = Settings()
1 change: 1 addition & 0 deletions api/app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ pycryptodome~=3.20.0
python-multipart~=0.0.9
baize~=0.20.8
alembic~=1.13.1
setuptools~=69.5.1
face-recognition~=1.3.0
weaviate-client~=4.5.5
9 changes: 5 additions & 4 deletions api/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from app.db import models
from app.db.crud import get_smoel, set_smoel, delete_items, create_item

client = connect_to_local()
host, port = settings.weaviate_url.lstrip("https://").split(":")
client = connect_to_local(host, port)
known_faces = client.collections.get('known_faces')


Expand Down Expand Up @@ -147,7 +148,7 @@ def parse_smoel(smoel):


def get_action(user):
current_result = requests.get(f"http://localhost:8080/v1/objects/known_faces/{user['id']}")
current_result = requests.get(f"{settings.weaviate_url}/v1/objects/known_faces/{user['id']}")

if current_result.status_code != 200:
return FaceAction.CREATE
Expand All @@ -172,7 +173,7 @@ def store_encoding(db: Session, user):
smoel = get_smoel(db, user["id"], user["name"])
smoel_vector = ndarray.tolist(encoding[0])
if action == FaceAction.CREATE:
requests.post("http://localhost:8080/v1/objects", json={
requests.post(f"{settings.weaviate_url}/v1/objects", json={
"class": "known_faces",
"id": str(user["id"]),
"vector": smoel_vector,
Expand All @@ -183,7 +184,7 @@ def store_encoding(db: Session, user):
}
})
elif action == FaceAction.UPDATE:
requests.put(f"http://localhost:8080/v1/objects/known_faces/{user['id']}", json={
requests.put(f"{settings.weaviate_url}/v1/objects/known_faces/{user['id']}", json={
"vector": smoel_vector,
"properties": {
"hash": user["hash"],
Expand Down

0 comments on commit 66e7abd

Please sign in to comment.