Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions nnll_15/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,27 @@ def check_and_import() -> Tuple[bool]:
Returns True if the module is successfully imported or already available, False otherwise."""

import requests
import json

cortex_server: bool = False
llamafile_server: bool = False
for api in API_NAMES:
if api == "cortex":
response = requests.get("http://127.0.0.1:39281/v1/chat/completions", timeout=(3, 3))
if response is not None:
data = response.json()
try:
data = response.json()
except json.decoder.JSONDecodeError:
continue
if data.get("result") == "OK":
cortex_server = True
elif api == "llamafile":
response = requests.get("http://localhost:8080/v1", timeout=(3, 3))
if response is not None:
data = response.json()
try:
data = response.json()
except json.decoder.JSONDecodeError:
continue
if data.get("result") == "OK":
llamafile_server = True

Expand Down