diff --git a/etc/scallopy-plugins/gpt/src/scallop_gpt/fp_gpt.py b/etc/scallopy-plugins/gpt/src/scallop_gpt/fp_gpt.py index e593ec9..e222ae7 100644 --- a/etc/scallopy-plugins/gpt/src/scallop_gpt/fp_gpt.py +++ b/etc/scallopy-plugins/gpt/src/scallop_gpt/fp_gpt.py @@ -1,4 +1,4 @@ -from typing import Tuple +from typing import Tuple, Generator import openai import scallopy @@ -9,7 +9,7 @@ @scallopy.foreign_predicate -def gpt(s: str) -> scallopy.Generator[None, str]: +def gpt(s: str) -> scallopy.Facts[None, str]: # Check if the storage already contains the response if s in STORAGE: response = STORAGE[s] diff --git a/etc/scallopy-plugins/plip/src/scallop_plip/plip.py b/etc/scallopy-plugins/plip/src/scallop_plip/plip.py index b976ece..fe228fa 100644 --- a/etc/scallopy-plugins/plip/src/scallop_plip/plip.py +++ b/etc/scallopy-plugins/plip/src/scallop_plip/plip.py @@ -40,7 +40,7 @@ def plip( assert args[2].ty.is_string() and (args[2].adornment is None or args[2].adornment.is_free()), f"{ERR_HEAD} third argument has to be of free type `String`" @scallopy.foreign_predicate(name=relation_decl.name.name) - def plip_classify(img: scallopy.Tensor) -> scallopy.Generator[float, Tuple[str]]: + def plip_classify(img: scallopy.Tensor) -> scallopy.Facts[float, Tuple[str]]: device = get_device() maybe_plip_model = get_plip_model(debug=debug) if maybe_plip_model is None: @@ -64,7 +64,7 @@ def plip_classify(img: scallopy.Tensor) -> scallopy.Generator[float, Tuple[str]] # Generate the foreign predicate for dynamic labels @scallopy.foreign_predicate(name=relation_decl.name.name) - def plip_classify_with_labels(img: scallopy.Tensor, list: scallopy.String) -> scallopy.Generator[float, Tuple[str]]: + def plip_classify_with_labels(img: scallopy.Tensor, list: scallopy.String) -> scallopy.Facts[float, Tuple[str]]: nonlocal labels labels = [item.strip() for item in list.split(DELIMITER)] return plip_classify(img) diff --git a/experiments/clutrr-v2/kinship_scallop.py b/experiments/clutrr-v2/kinship_scallop.py index 464ebd6..c009d40 100644 --- a/experiments/clutrr-v2/kinship_scallop.py +++ b/experiments/clutrr-v2/kinship_scallop.py @@ -1,4 +1,3 @@ -import openai import json from tqdm import tqdm from io import StringIO @@ -24,6 +23,12 @@ def __init__(self): def test_kinship(range=range(N)): out = {"score": 0, "data": [], "logs": []} + + plugins = scallopy_ext.PluginRegistry() + parser = argparse.ArgumentParser() + plugins.setup_argument_parser(parser) + known_args, unknown_args = parser.parse_known_args() + plugins.configure(known_args, unknown_args) for i in tqdm(range): (ctx, query), ans = TASK[i] @@ -33,14 +38,7 @@ def test_kinship(range=range(N)): sys.stdout = buffer try: ctx = scallopy.ScallopContext(provenance="unit") - plugins = scallopy_ext.PluginRegistry() - - parser = argparse.ArgumentParser() - plugins.setup_argument_parser(parser) - known_args, unknown_args = parser.parse_known_args() - plugins.configure(known_args, unknown_args) plugins.load_into_ctx(ctx) - ctx.import_file(SCALLOP_FILE) ctx.add_facts("context", [(input,)]) ctx.run()