mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
sa
This commit is contained in:
@@ -8,7 +8,10 @@ from flask import Blueprint, abort, jsonify, request
|
|||||||
bp = Blueprint("ingest_text", __name__)
|
bp = Blueprint("ingest_text", __name__)
|
||||||
BASE = Path(os.getenv("INGEST_DIR", "/home/pi/tmp_git")).resolve()
|
BASE = Path(os.getenv("INGEST_DIR", "/home/pi/tmp_git")).resolve()
|
||||||
BASE.mkdir(parents=True, exist_ok=True)
|
BASE.mkdir(parents=True, exist_ok=True)
|
||||||
TOKEN = os.getenv("INGEST_TOKEN", "change-me")
|
TOKEN = None
|
||||||
|
with open("/home/pi/gpt_cont_api_key", "r") as f:
|
||||||
|
TOKEN = f.read().strip()
|
||||||
|
|
||||||
|
|
||||||
# prosty bufor kawałków w RAM (na 1 proces)
|
# prosty bufor kawałków w RAM (na 1 proces)
|
||||||
chunks = {}
|
chunks = {}
|
||||||
@@ -34,6 +37,8 @@ def ingest_text():
|
|||||||
entry = chunks.setdefault(key, {})
|
entry = chunks.setdefault(key, {})
|
||||||
entry[index] = urllib.parse.unquote_plus(chunk)
|
entry[index] = urllib.parse.unquote_plus(chunk)
|
||||||
|
|
||||||
|
if TOKEN is None:
|
||||||
|
exit("No API token set!")
|
||||||
if len(entry) == total:
|
if len(entry) == total:
|
||||||
# składamy i zapisujemy
|
# składamy i zapisujemy
|
||||||
data = "".join(entry[i] for i in range(1, total + 1))
|
data = "".join(entry[i] for i in range(1, total + 1))
|
||||||
|
|||||||
Reference in New Issue
Block a user