Remote Copilot models (italdesign BYOK + AI credits) for shots/report
This commit is contained in:
+2
-5
@@ -2,8 +2,6 @@
|
||||
import base64, collections, json, re, subprocess, urllib.error, urllib.request
|
||||
import db, llama
|
||||
|
||||
API = f"http://127.0.0.1:{llama.PORT}/v1/chat/completions"
|
||||
_open = urllib.request.build_opener(urllib.request.ProxyHandler({})).open # corp proxy must not see localhost
|
||||
EMPTY = {"kind": "other", "title": None, "app": None, "summary": "", "text": "", "entities": {}, "people": [], "presenter": None, "meeting_title": None, "content_box": None}
|
||||
CONTENT_KINDS = {"slide", "code", "terminal", "browser", "document", "spreadsheet", "diagram", "dashboard", "ticket"}
|
||||
CROP_BOX = True
|
||||
@@ -39,13 +37,12 @@ EMAIL = re.compile(r"[\w.+-]+@[\w-]+\.[\w.-]+")
|
||||
|
||||
def _ask(path, json_mode=True):
|
||||
img = base64.b64encode(path.read_bytes()).decode()
|
||||
body = {"model": llama.current(True), "max_tokens": 1200, "temperature": 0.1,
|
||||
body = {"max_tokens": 1200, "temperature": 0.1,
|
||||
"chat_template_kwargs": {"enable_thinking": False},
|
||||
"messages": [{"role": "user", "content": [{"type": "text", "text": PROMPT},
|
||||
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64," + img}}]}]}
|
||||
if json_mode: body["response_format"] = {"type": "json_schema", "json_schema": {"name": "shot", "schema": SCHEMA}} if SCHEMA else {"type": "json_object"}
|
||||
req = urllib.request.Request(API, json.dumps(body).encode(), {"Content-Type": "application/json"})
|
||||
return llama.content(json.load(_open(req, timeout=900)), f"shot {path.name}")
|
||||
return llama.content(llama.post(body, True, 900), f"shot {path.name}")
|
||||
|
||||
|
||||
def read_shot(path):
|
||||
|
||||
Reference in New Issue
Block a user