From 26af2d5ee135daebb9b5558e61675bed88e0f610 Mon Sep 17 00:00:00 2001 From: Jonathan Lessinger Date: Tue, 9 Jan 2024 21:36:37 -0500 Subject: [PATCH] fix? --- .../local_inference/text_translation.py | 3 ++- python/src/aiconfig/editor/server/server_utils.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/extensions/HuggingFace/python/src/aiconfig_extension_hugging_face/local_inference/text_translation.py b/extensions/HuggingFace/python/src/aiconfig_extension_hugging_face/local_inference/text_translation.py index 9ee8bb357..4c9a71878 100644 --- a/extensions/HuggingFace/python/src/aiconfig_extension_hugging_face/local_inference/text_translation.py +++ b/extensions/HuggingFace/python/src/aiconfig_extension_hugging_face/local_inference/text_translation.py @@ -240,12 +240,13 @@ async def run_inference(self, prompt: Prompt, aiconfig: "AIConfigRuntime", optio model_name: str = aiconfig.get_model_name(prompt) if isinstance(model_name, str) and model_name not in self.translators: - self.translators[model_name] = pipeline(model_name) + self.translators[model_name] = pipeline("translation_en_to_fr") translator = self.translators[model_name] # if stream enabled in runtime options and config, then stream. Otherwise don't stream. streamer = None should_stream = (options.stream if options else False) and (not "stream" in completion_data or completion_data.get("stream") != False) + should_stream = False if should_stream: raise NotImplementedError("Streaming is not supported for HuggingFace Text Translation") diff --git a/python/src/aiconfig/editor/server/server_utils.py b/python/src/aiconfig/editor/server/server_utils.py index 072e03e9d..7d945c33b 100644 --- a/python/src/aiconfig/editor/server/server_utils.py +++ b/python/src/aiconfig/editor/server/server_utils.py @@ -34,7 +34,7 @@ LOGGER.addHandler(log_handler) # TODO unhardcode -LOGGER.setLevel(logging.INFO) +LOGGER.setLevel(logging.DEBUG) UnvalidatedPath = NewType("UnvalidatedPath", str) @@ -123,20 +123,26 @@ def get_validated_path(raw_path: str | None, allow_create: bool = False) -> Resu def _import_module_from_path(path_to_module: str) -> Result[ModuleType, str]: LOGGER.debug(f"{path_to_module=}") + print(f"{path_to_module=}") resolved_path = resolve_path(path_to_module) LOGGER.debug(f"{resolved_path=}") module_name = os.path.basename(resolved_path).replace(".py", "") try: + LOGGER.debug(f"running spec_from_file_location({module_name}, {resolved_path})") spec = importlib.util.spec_from_file_location(module_name, resolved_path) if spec is None: return Err(f"Could not import module from path: {resolved_path}") elif spec.loader is None: return Err(f"Could not import module from path: {resolved_path} (no loader)") else: + LOGGER.debug(f"{spec=}") module = importlib.util.module_from_spec(spec) + LOGGER.debug(f"{module=}") sys.modules[module_name] = module - spec.loader.exec_module(module) + exec_module_result = spec.loader.exec_module(module) + LOGGER.debug(f"{exec_module_result=}") + LOGGER.debug(f"{module=}") return Ok(module) except Exception as e: return core_utils.ErrWithTraceback(e)