Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name 'Document' from 'llama_index.core' (unknown location) #1078

Closed
2 tasks
AbrahamQll opened this issue Mar 1, 2024 · 8 comments
Closed
2 tasks
Assignees

Comments

@AbrahamQll
Copy link

Describe the bug
When I want to run "memgpt run" or "memgpt configure" on my Windows 10 X64 machine, using python 3.11.7 I get the following error:

memgpt run Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "C:\Program Files\Python311\Scripts\memgpt.exe\__main__.py", line 4, in <module> File "C:\Program Files\Python311\Lib\site-packages\memgpt\__init__.py", line 3, in <module> from memgpt.client.client import create_client File "C:\Program Files\Python311\Lib\site-packages\memgpt\client\client.py", line 8, in <module> from memgpt.cli.cli import QuickstartChoice File "C:\Program Files\Python311\Lib\site-packages\memgpt\cli\cli.py", line 26, in <module> from memgpt.agent import Agent, save_agent File "C:\Program Files\Python311\Lib\site-packages\memgpt\agent.py", line 15, in <module> from memgpt.persistence_manager import LocalStateManager File "C:\Program Files\Python311\Lib\site-packages\memgpt\persistence_manager.py", line 5, in <module> from memgpt.memory import ( File "C:\Program Files\Python311\Lib\site-packages\memgpt\memory.py", line 10, in <module> from memgpt.embeddings import embedding_model, query_embedding, parse_and_chunk_text File "C:\Program Files\Python311\Lib\site-packages\memgpt\embeddings.py", line 14, in <module> from llama_index.core import Document as LlamaIndexDocument ImportError: cannot import name 'Document' from 'llama_index.core' (unknown location)

Please describe your setup

  • How did you install memgpt?
    • pip install pymemgpt and pip install pymemgpt[postgres]
  • Describe your setup
    • What's your OS (Windows/MacOS/Linux)? Windows 10 X64
    • How are you running memgpt? cmd.exe

MemGPT Config
Please attach your ~/.memgpt/config file or copy past it below.


I am using OpenAI

@quantumalchemy
Copy link

quantumalchemy commented Mar 1, 2024

getting same in linux (debian) pip install pymemgpt -U
pymemgpt v0.3.4
did the path change in the install ? ie: /root/.memgpt

@Minktong
Copy link

Minktong commented Mar 2, 2024

I have just installed the package using the command pip install -U pymemgpt and I am getting the same error.

@yekamu
Copy link

yekamu commented Mar 3, 2024

same here. I install with pip -e. then I update llama-index to 0.1-14, same error before and after the update

@sarahwooders sarahwooders self-assigned this Mar 8, 2024
@sarahwooders sarahwooders moved this from To triage to Ready in 🐛 MemGPT issue tracker Mar 8, 2024
@jkothamb-sai
Copy link

jkothamb-sai commented Mar 21, 2024

Had to make following changes and install from source i.e pip install -e "."

diff --git a/memgpt/data_sources/connectors.py b/memgpt/data_sources/connectors.py
index 00d93d8..fad929f 100644
--- a/memgpt/data_sources/connectors.py
+++ b/memgpt/data_sources/connectors.py
@@ -6,7 +6,7 @@ from memgpt.data_types import Document, Passage

from typing import List, Iterator, Dict, Tuple, Optional
import typer
-from llama_index.core import Document as LlamaIndexDocument
+from llama_index.core.schema import Document as LlamaIndexDocument

class DataConnector:
@@ -103,7 +103,7 @@ class DirectoryConnector(DataConnector):
assert self.input_directory is not None, "Must provide input directory if recursive is True."

 def generate_documents(self) -> Iterator[Tuple[str, Dict]]:  # -> Iterator[Document]:

- from llama_index.core import SimpleDirectoryReader
+ from llama_index.core.readers import SimpleDirectoryReader

     if self.input_directory is not None:
         reader = SimpleDirectoryReader(

diff --git a/memgpt/embeddings.py b/memgpt/embeddings.py
index ee7d4b8..5792641 100644
--- a/memgpt/embeddings.py
+++ b/memgpt/embeddings.py
@@ -11,7 +11,7 @@ from memgpt.constants import MAX_EMBEDDING_DIM, EMBEDDING_TO_TOKENIZER_MAP, EMBE

# from llama_index.core.base.embeddings import BaseEmbedding
from llama_index.core.node_parser import SentenceSplitter
-from llama_index.core import Document as LlamaIndexDocument
+from llama_index.core.schema import Document as LlamaIndexDocument

# from llama_index.core.base.embeddings import BaseEmbedding
# from llama_index.core.embeddings import BaseEmbedding

@sarahwooders
Copy link
Collaborator

Is this still an issue on the latest version?

@vivekagb
Copy link

I am still facing this. Just updated from version 0.3.0 to 0.3.14

@lastrosade
Copy link

lastrosade commented May 19, 2024

I can confirm that this is still an issue on latest via pypy.
Installing from repo, pip install --upgrade --no-cache-dir --force-reinstall git+https://github.com/cpacker/MemGPT.git results in:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\Scripts\memgpt.exe\__main__.py", line 7, in <module>
    sys.exit(app())
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\typer\main.py", line 328, in __call__
    raise e
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\typer\main.py", line 311, in __call__
    return get_command(self)(*args, **kwargs)
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\typer\core.py", line 783, in main
    return _main(
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\typer\core.py", line 225, in _main
    rv = self.invoke(ctx)
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\typer\main.py", line 683, in wrapper
    return callback(**use_params)  # type: ignore
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\memgpt\cli\cli.py", line 651, in run
    memgpt_agent = Agent(
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\memgpt\agent.py", line 282, in __init__
    self.persistence_manager = LocalStateManager(agent_state=self.agent_state)
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\memgpt\persistence_manager.py", line 51, in __init__
    self.archival_memory = EmbeddingArchivalMemory(agent_state)
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\memgpt\memory.py", line 385, in __init__
    self.embed_model = embedding_model(agent_state.embedding_config)
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\memgpt\embeddings.py", line 205, in embedding_model
    return default_embedding_model()
  File "C:\Users\pedr0\AppData\Roaming\Python\Python310\site-packages\memgpt\embeddings.py", line 141, in default_embedding_model
    from llama_index.embeddings.huggingface import HuggingFaceEmbedding
ModuleNotFoundError: No module named 'llama_index.embeddings.huggingface'

Fixed by installing llama-index-embeddings-huggingface

Copy link

github-actions bot commented Dec 6, 2024

This issue has been automatically closed due to 60 days of inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants