Inference.
Browse files- app/api/api_v1/endpoints/openai.py +21 -1
- start +2 -2
app/api/api_v1/endpoints/openai.py
CHANGED
|
@@ -28,6 +28,11 @@ import shutil
|
|
| 28 |
import nbformat as nbf
|
| 29 |
import random
|
| 30 |
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
from langchain.vectorstores.pgvector import (
|
| 33 |
CollectionStore,
|
|
@@ -85,7 +90,22 @@ def embed(db: Session, payload: schemas.LabelStudio):
|
|
| 85 |
|
| 86 |
notebook_dir = "{}/notebooks".format(tmp_dir)
|
| 87 |
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
with zipfile.ZipFile(tmp_archive, 'r') as zip_ref:
|
| 91 |
zip_ref.extractall(tmp_dir)
|
|
|
|
| 28 |
import nbformat as nbf
|
| 29 |
import random
|
| 30 |
import time
|
| 31 |
+
import requests
|
| 32 |
+
from app.core.config import settings
|
| 33 |
+
import pathlib
|
| 34 |
+
import io
|
| 35 |
+
|
| 36 |
|
| 37 |
from langchain.vectorstores.pgvector import (
|
| 38 |
CollectionStore,
|
|
|
|
| 90 |
|
| 91 |
notebook_dir = "{}/notebooks".format(tmp_dir)
|
| 92 |
|
| 93 |
+
response = requests.get(
|
| 94 |
+
"{}/api/projects/{}/export?export_type=COCO&ids[]={}".format(settings.LABEL_STUDIO_URL, label_studio_project.id, task_id),
|
| 95 |
+
headers={"Authorization": "Token {}".format(settings.LABEL_STUDIO_API_KEY)})
|
| 96 |
+
|
| 97 |
+
#label_studio_project.export_tasks("COCO", False, True, [task_id], tmp_archive)
|
| 98 |
+
|
| 99 |
+
export_path = pathlib.Path(tmp_archive)
|
| 100 |
+
|
| 101 |
+
# ensure that parent location exists even if it is in some subdirectory
|
| 102 |
+
export_path.parent.mkdir(parents=True, exist_ok=True)
|
| 103 |
+
|
| 104 |
+
with open(export_path, "wb") as out_file:
|
| 105 |
+
for chunk in response.iter_content(
|
| 106 |
+
chunk_size=1024
|
| 107 |
+
): # 1 kib seems reasonable
|
| 108 |
+
out_file.write(chunk)
|
| 109 |
|
| 110 |
with zipfile.ZipFile(tmp_archive, 'r') as zip_ref:
|
| 111 |
zip_ref.extractall(tmp_dir)
|
start
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
alembic upgrade head
|
| 4 |
|
| 5 |
if [ "$PYTHON_ENV" == "development" ]; then
|
| 6 |
-
uvicorn app.main:app --host 0.0.0.0 --port 8080 --reload
|
| 7 |
else
|
| 8 |
-
uvicorn app.main:app --host 0.0.0.0 --port 8080
|
| 9 |
fi
|
|
|
|
| 3 |
alembic upgrade head
|
| 4 |
|
| 5 |
if [ "$PYTHON_ENV" == "development" ]; then
|
| 6 |
+
uvicorn app.main:app --host 0.0.0.0 --port 8080 --workers 4 --reload
|
| 7 |
else
|
| 8 |
+
uvicorn app.main:app --host 0.0.0.0 --workers 4 --port 8080
|
| 9 |
fi
|