QuangBK / generativeAgent_LLM

Implementation of "Generative Agents: Interactive Simulacra of Human Behavior" paper with Guidance and Langchain. Full features and work with local LLMs.
Other
270 stars 36 forks source link

BaseRetriever.get_relevant_documents() takes 2 positional arguments but 3 were given #6

Closed chris-aeviator closed 1 year ago

chris-aeviator commented 1 year ago
sam_observations = [
    "Sam wake up in the morning",
]
sam.add_memories(sam_observations)

summary = sam.get_summary(force_refresh=True)
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ in <cell line: 1>:1                                                                              │
│                                                                                                  │
│ /content/generativeAgent_LLM/server/generativeAgent.py:163 in get_summary                        │
│                                                                                                  │
│   160 │   │   │   or since_refresh >= self.summary_refresh_seconds                               │
│   161 │   │   │   or force_refresh                                                               │
│   162 │   │   ):                                                                                 │
│ ❱ 163 │   │   │   core_characteristics = self._run_characteristics()                             │
│   164 │   │   │   daily_occupation = self._run_occupation()                                      │
│   165 │   │   │   feeling = self._run_feeling()                                                  │
│   166                                                                                            │
│                                                                                                  │
│ /content/generativeAgent_LLM/server/generativeAgent.py:173 in _run_characteristics               │
│                                                                                                  │
│   170 │   │   return self.summary                                                                │
│   171 │                                                                                          │
│   172 │   def _run_characteristics(self,):                                                       │
│ ❱ 173 │   │   docs = self.retriever.get_relevant_documents(self.name + "'s core characteristic   │
│   174 │   │   statements = get_text_from_docs(docs, include_time = False)                        │
│   175 │   │                                                                                      │
│   176 │   │   prompt = self.guidance(PROMPT_CHARACTERISTICS, silent=self.silent)                 │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: BaseRetriever.get_relevant_documents() takes 2 positional arguments but 3 were given

Update

I can get around this by making def get_relevant_documents(self, query: str, current_time=None)

and invoking

with mock_now(datetime.datetime(2011, 2, 3, 10, 11)):
    print(sam.retriever.get_relevant_documents("sam's core characteristics")

[Document(page_content='Sam is a Ph.D student, his major is CS', metadata={'importance': 7, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 0}), Document(page_content='Sam likes computer', metadata={'importance': 1, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 1}), Document(page_content='Wants to get his AI company to be successful.', metadata={'importance': 8, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 5}), Document(page_content='Sam really wants to get to work to get the marketing project for his AI company done', metadata={'importance': 3, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 7}), Document(page_content='Sam wake up in the morning', metadata={'importance': 1, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 6}), Document(page_content='Sam has a dog, named Max', metadata={'importance': 1, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 4}), Document(page_content="Sam's farther is a doctor", metadata={'importance': 1, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 3}), Document(page_content='Sam lives with his friend, Bob', metadata={'importance': 1, 'created_at': datetime.datetime(2023, 7, 19, 7, 25, 42, 649173), 'last_accessed_at': MockDateTime(2011, 2, 3, 10, 11), 'buffer_idx': 2})]

I really don't understand the issue - is it the timestamp passed?

QuangBK commented 1 year ago

Hi, I think it is a problem with the new langchain version. Before I can make it work with the latest langchain, you may downgrade langchain as pip install langchain==0.0.190