Skip to content
Draft

fix? #843

Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
10 changes: 8 additions & 2 deletions python/src/aiconfig/editor/server/server_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
LOGGER.addHandler(log_handler)

# TODO unhardcode
LOGGER.setLevel(logging.INFO)
LOGGER.setLevel(logging.DEBUG)


UnvalidatedPath = NewType("UnvalidatedPath", str)
Expand Down Expand Up @@ -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)
Expand Down