langflow-ai / langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. It’s Python-based and agnostic to any model, API, or database.
http://www.langflow.org
MIT License
33.29k stars 4.06k forks source link

Error connecting MPT model to ConversationChain #463

Closed amrohendawi closed 1 year ago

amrohendawi commented 1 year ago

When I initialize this MPT model as an LLM and connect it to a ConversationChain the status indicator turns green:

image

However, when I open the chat bubble I get a popup error in the UI:

Oops! An unknown error has occurred.

Please click the 'Reset Application' button to restore the application's state. If the error persists, please create an issue on our GitHub page. We apologize for any inconvenience this may have caused.

Terminal log:

Fetching 1 files: 100%|█████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 23696.63it/s]
Fetching 1 files: 100%|█████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 27962.03it/s]
Fetching 1 files: 100%|█████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 21620.12it/s]
Fetching 1 files: 100%|██████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 3045.97it/s]
Fetching 1 files: 100%|█████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 19878.22it/s]
Fetching 1 files: 100%|██████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 2189.09it/s]
[2023-06-08 19:49:42 +0200] [1077] [WARNING] Worker with pid 1102 was terminated due to signal 9
[2023-06-08 19:49:42 +0200] [1129] [INFO] Booting worker with pid: 1129
[2023-06-08 19:49:43 +0200] [1129] [INFO] Started server process [1129]
[2023-06-08 19:49:43 +0200] [1129] [INFO] Waiting for application startup.
[2023-06-08 19:49:43 +0200] [1129] [INFO] Application startup complete.
[2023-06-08 19:49:43 +0200] [1129] [INFO] ('127.0.0.1', 47124) - "WebSocket /chat/49b84f06-2247-470b-8467-f0f16905683b" [accepted]
[2023-06-08 19:49:43 +0200] [1129] [INFO] connection open
Fetching 1 files: 100%|██████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 2059.06it/s]
Fetching 1 files: 100%|█████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 20971.52it/s]
[19:49:44] ERROR    [19:49:44] - ERROR - Error building node CTransformers: _lock                                      validate.py:56
                    ╭────────────────────────────── Traceback (most recent call last) ───────────────────────────────╮
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/langflow/graph/base.py: │
                    │ 195 in _build                                                                                  │
                    │                                                                                                │
                    │   192 │   │   # and return the instance                                                        │
                    │   193 │   │                                                                                    │
                    │   194 │   │   try:                                                                             │
                    │ ❱ 195 │   │   │   self._built_object = loading.instantiate_class(                              │
                    │   196 │   │   │   │   node_type=self.node_type,                                                │
                    │   197 │   │   │   │   base_type=self.base_type,                                                │
                    │   198 │   │   │   │   params=self.params,                                                      │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/langflow/interface/load │
                    │ ing.py:41 in instantiate_class                                                                 │
                    │                                                                                                │
                    │    38 │   │   │   return custom_agent.initialize(**params)                                     │
                    │    39 │                                                                                        │
                    │    40 │   class_object = import_by_type(_type=base_type, name=node_type)                       │
                    │ ❱  41 │   return instantiate_based_on_type(class_object, base_type, node_type, params)         │
                    │    42                                                                                          │
                    │    43                                                                                          │
                    │    44 def convert_params_to_sets(params):                                                      │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/langflow/interface/load │
                    │ ing.py:83 in instantiate_based_on_type                                                         │
                    │                                                                                                │
                    │    80 │   elif base_type == "utilities":                                                       │
                    │    81 │   │   return instantiate_utility(node_type, class_object, params)                      │
                    │    82 │   else:                                                                                │
                    │ ❱  83 │   │   return class_object(**params)                                                    │
                    │    84                                                                                          │
                    │    85                                                                                          │
                    │    86 def instantiate_agent(class_object, params):                                             │
                    │                                                                                                │
                    │ in pydantic.main.BaseModel.__init__:339                                                        │
                    │                                                                                                │
                    │ in pydantic.main.validate_model:1102                                                           │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/langchain/llms/ctransfo │
                    │ rmers.py:70 in validate_environment                                                            │
                    │                                                                                                │
                    │    67 │   │   │   )                                                                            │
                    │    68 │   │                                                                                    │
                    │    69 │   │   config = values["config"] or {}                                                  │
                    │ ❱  70 │   │   values["client"] = AutoModelForCausalLM.from_pretrained(                         │
                    │    71 │   │   │   values["model"],                                                             │
                    │    72 │   │   │   model_type=values["model_type"],                                             │
                    │    73 │   │   │   model_file=values["model_file"],                                             │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/ctransformers/hub.py:13 │
                    │ 0 in from_pretrained                                                                           │
                    │                                                                                                │
                    │   127 │   │   Returns:                                                                         │
                    │   128 │   │   │   `LLM` object.                                                                │
                    │   129 │   │   """                                                                              │
                    │ ❱ 130 │   │   config = config or AutoConfig.from_pretrained(                                   │
                    │   131 │   │   │   model_path_or_repo_id,                                                       │
                    │   132 │   │   │   local_files_only=local_files_only,                                           │
                    │   133 │   │   │   **kwargs,                                                                    │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/ctransformers/hub.py:47 │
                    │ in from_pretrained                                                                             │
                    │                                                                                                │
                    │    44 │   │   if path_type == "dir":                                                           │
                    │    45 │   │   │   cls._update_from_dir(model_path_or_repo_id, auto_config)                     │
                    │    46 │   │   elif path_type == "repo":                                                        │
                    │ ❱  47 │   │   │   cls._update_from_repo(                                                       │
                    │    48 │   │   │   │   model_path_or_repo_id,                                                   │
                    │    49 │   │   │   │   auto_config,                                                             │
                    │    50 │   │   │   │   local_files_only=local_files_only,                                       │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/ctransformers/hub.py:69 │
                    │ in _update_from_repo                                                                           │
                    │                                                                                                │
                    │    66 │   │   auto_config: "AutoConfig",                                                       │
                    │    67 │   │   local_files_only: bool,                                                          │
                    │    68 │   ) -> None:                                                                           │
                    │ ❱  69 │   │   path = snapshot_download(                                                        │
                    │    70 │   │   │   repo_id=repo_id,                                                             │
                    │    71 │   │   │   allow_patterns="config.json",                                                │
                    │    72 │   │   │   local_files_only=local_files_only,                                           │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/huggingface_hub/utils/_ │
                    │ validators.py:120 in _inner_fn                                                                 │
                    │                                                                                                │
                    │   117 │   │   if check_use_auth_token:                                                         │
                    │   118 │   │   │   kwargs = smoothly_deprecate_use_auth_token(fn_name=fn.__name__,              │
                    │       has_token=has_token, kwargs=kwargs)                                                      │
                    │   119 │   │                                                                                    │
                    │ ❱ 120 │   │   return fn(*args, **kwargs)                                                       │
                    │   121 │                                                                                        │
                    │   122 │   return _inner_fn  # type: ignore                                                     │
                    │   123                                                                                          │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/huggingface_hub/_snapsh │
                    │ ot_download.py:235 in snapshot_download                                                        │
                    │                                                                                                │
                    │   232 │   │   for file in filtered_repo_files:                                                 │
                    │   233 │   │   │   _inner_hf_hub_download(file)                                                 │
                    │   234 │   else:                                                                                │
                    │ ❱ 235 │   │   thread_map(                                                                      │
                    │   236 │   │   │   _inner_hf_hub_download,                                                      │
                    │   237 │   │   │   filtered_repo_files,                                                         │
                    │   238 │   │   │   desc=f"Fetching {len(filtered_repo_files)} files",                           │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/tqdm/contrib/concurrent │
                    │ .py:69 in thread_map                                                                           │
                    │                                                                                                │
                    │    66 │   │   [default: max(32, cpu_count() + 4)].                                             │
                    │    67 │   """                                                                                  │
                    │    68 │   from concurrent.futures import ThreadPoolExecutor                                    │
                    │ ❱  69 │   return _executor_map(ThreadPoolExecutor, fn, *iterables, **tqdm_kwargs)              │
                    │    70                                                                                          │
                    │    71                                                                                          │
                    │    72 def process_map(fn, *iterables, **tqdm_kwargs):                                          │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/tqdm/contrib/concurrent │
                    │ .py:47 in _executor_map                                                                        │
                    │                                                                                                │
                    │    44 │   max_workers = kwargs.pop("max_workers", min(32, cpu_count() + 4))                    │
                    │    45 │   chunksize = kwargs.pop("chunksize", 1)                                               │
                    │    46 │   lock_name = kwargs.pop("lock_name", "")                                              │
                    │ ❱  47 │   with ensure_lock(tqdm_class, lock_name=lock_name) as lk:                             │
                    │    48 │   │   # share lock in case workers are already using `tqdm`                            │
                    │    49 │   │   with PoolExecutor(max_workers=max_workers, initializer=tqdm_class.set_lock,      │
                    │    50 │   │   │   │   │   │     initargs=(lk,)) as ex:                                         │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/contextlib.py:142 in __exit__         │
                    │                                                                                                │
                    │   139 │   def __exit__(self, typ, value, traceback):                                           │
                    │   140 │   │   if typ is None:                                                                  │
                    │   141 │   │   │   try:                                                                         │
                    │ ❱ 142 │   │   │   │   next(self.gen)                                                           │
                    │   143 │   │   │   except StopIteration:                                                        │
                    │   144 │   │   │   │   return False                                                             │
                    │   145 │   │   │   else:                                                                        │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/tqdm/contrib/concurrent │
                    │ .py:24 in ensure_lock                                                                          │
                    │                                                                                                │
                    │    21 │   tqdm_class.set_lock(lock)                                                            │
                    │    22 │   yield lock                                                                           │
                    │    23 │   if old_lock is None:                                                                 │
                    │ ❱  24 │   │   del tqdm_class._lock                                                             │
                    │    25 │   else:                                                                                │
                    │    26 │   │   tqdm_class.set_lock(old_lock)                                                    │
                    │    27                                                                                          │
                    ╰────────────────────────────────────────────────────────────────────────────────────────────────╯
                    AttributeError: _lock

                    The above exception was the direct cause of the following exception:

                    ╭────────────────────────────── Traceback (most recent call last) ───────────────────────────────╮
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/langflow/api/validate.p │
                    │ y:53 in post_validate_node                                                                     │
                    │                                                                                                │
                    │   50 │   │   if node is None:                                                                  │
                    │   51 │   │   │   raise ValueError(f"Node {node_id} not found")                                 │
                    │   52 │   │   if not isinstance(node, VectorStoreNode):                                         │
                    │ ❱ 53 │   │   │   node.build()                                                                  │
                    │   54 │   │   return json.dumps({"valid": True, "params": str(node._built_object_repr())})      │
                    │   55 │   except Exception as e:                                                                │
                    │   56 │   │   logger.exception(e)                                                               │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/langflow/graph/nodes.py │
                    │ :102 in build                                                                                  │
                    │                                                                                                │
                    │    99 │   │   │   │   │   # Build the PromptNode, passing the tools if available               │
                    │   100 │   │   │   │   │   self.params[key] = value.build(tools=tools, force=force)             │
                    │   101 │   │   │                                                                                │
                    │ ❱ 102 │   │   │   self._build()                                                                │
                    │   103 │   │                                                                                    │
                    │   104 │   │   #! Cannot deepcopy SQLDatabaseChain                                              │
                    │   105 │   │   if self.node_type in ["SQLDatabaseChain"]:                                       │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/langflow/graph/base.py: │
                    │ 160 in _build                                                                                  │
                    │                                                                                                │
                    │   157 │   │   │   │   if value == self:                                                        │
                    │   158 │   │   │   │   │   del self.params[key]                                                 │
                    │   159 │   │   │   │   │   continue                                                             │
                    │ ❱ 160 │   │   │   │   result = value.build()                                                   │
                    │   161 │   │   │   │   # If the key is "func", then we need to use the run method               │
                    │   162 │   │   │   │   if key == "func":                                                        │
                    │   163 │   │   │   │   │   if not isinstance(result, types.FunctionType):                       │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/langflow/graph/nodes.py │
                    │ :123 in build                                                                                  │
                    │                                                                                                │
                    │   120 │   │   if self.node_type == self.built_node_type:                                       │
                    │   121 │   │   │   return self.class_built_object                                               │
                    │   122 │   │   if not self._built or force:                                                     │
                    │ ❱ 123 │   │   │   self._build()                                                                │
                    │   124 │   │   │   self.built_node_type = self.node_type                                        │
                    │   125 │   │   │   self.class_built_object = self._built_object                                 │
                    │   126 │   │   # Avoid deepcopying the LLM                                                      │
                    │                                                                                                │
                    │ /home/lazerdance/miniconda3/envs/langflow/lib/python3.10/site-packages/langflow/graph/base.py: │
                    │ 201 in _build                                                                                  │
                    │                                                                                                │
                    │   198 │   │   │   │   params=self.params,                                                      │
                    │   199 │   │   │   )                                                                            │
                    │   200 │   │   except Exception as exc:                                                         │
                    │ ❱ 201 │   │   │   raise ValueError(                                                            │
                    │   202 │   │   │   │   f"Error building node {self.node_type}: {str(exc)}"                      │
                    │   203 │   │   │   ) from exc                                                                   │
                    │   204                                                                                          │
                    ╰────────────────────────────────────────────────────────────────────────────────────────────────╯
                    ValueError: Error building node CTransformers: _lock
ogabrielluiz commented 1 year ago

Hey, @amrohendawi

This seems to be a problem with tqdm. I've tried it here and it works. My suggestion is that you should download the model beforehand and use the path to the model, otherwise, you should wait for the download to end before you start the conversation.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.