Spaces:
Running
Running
File size: 1,813 Bytes
3fdcc70 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
from re import I
from typing import List
from pathlib import Path
import os
import requests
__ALL__ = ["remote_logging", "select", "count"]
HOST = os.environ.get("CLLM_SERVICES_HOST", "localhost")
PORT = os.environ.get("CLLM_SERVICES_PORT", 10056)
def setup(host="localhost", port=10056):
global HOST, PORT
HOST = host
PORT = port
def select(**kwargs):
if "bbox_list" in kwargs:
list = kwargs["bbox_list"]
condition = kwargs["condition"]
return [l for l in list if l["label"] == condition]
if "mask_list" in kwargs:
list = kwargs["mask_list"]
condition = kwargs["condition"]
# return combine_masks([l for l in list if l['label'] == condition])
return [l for l in list if l["label"] == condition]
if "category_list" in kwargs:
list = kwargs["category_list"]
condition = kwargs["condition"]
# return combine_masks([l for l in list if l['label'] == condition])
return [l for l in list if l["label"] == condition]
def count(**kwargs):
len_of_list = 0
if "bbox_list" in kwargs:
len_of_list = len(kwargs["bbox_list"])
elif "mask_list" in kwargs:
len_of_list = len(kwargs["mask_list"])
return f"The length of the given list is {len_of_list}"
def remote_logging(
history_msgs: list,
task_decomposition: list,
solution: list,
record: str,
like: bool,
**kwargs,
):
host = kwargs.get("host", HOST)
port = kwargs.get("port", PORT)
url = f"http://{host}:{port}/remote_logging"
data = {
"history_msgs": history_msgs,
"task_decomposition": task_decomposition,
"solution": solution,
"record": record,
"like": like,
}
response = requests.post(url, data=data)
return response.content
|