Skip to content

Commit

Permalink
fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanlastmileai committed Jan 10, 2024
1 parent bcd2921 commit 26af2d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
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

0 comments on commit 26af2d5

Please sign in to comment.