sudarshan-koirala / llama2-chat-with-documents

Simple Chainlit app to have interaction with your documents.
MIT License
49 stars 38 forks source link

'Message' object has no attribute 'replace' #5

Open aalesann opened 10 months ago

aalesann commented 10 months ago

Hi! I've this error when i try to send first question. How to resolve this error?

2023-12-18 09:03:41 - Loaded .env file 2023-12-18 09:03:41 - Your app is available at http://localhost:8000 Abriendo en una sesión existente del navegador 2023-12-18 09:03:45 - Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2 2023-12-18 09:03:45 - Anonymized telemetry enabled. See https://docs.trychroma.com/telemetry for more information. 2023-12-18 09:04:49 - 'Message' object has no attribute 'replace' Traceback (most recent call last): File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/chainlit/utils.py", line 39, in wrapper return await user_function(*params_values) File "/home/developer/Documentos/llama2-chat-with-documents/main.py", line 203, in process_chat_message response = await qa_chain.acall(message, callbacks=[callback_handler]) File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain/chains/base.py", line 381, in acall raise e File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain/chains/base.py", line 375, in acall await self._acall(inputs, run_manager=run_manager) File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain/chains/retrieval_qa/base.py", line 184, in _acall docs = await self._aget_docs(question, run_manager=_run_manager) File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain/chains/retrieval_qa/base.py", line 232, in _aget_docs return await self.retriever.aget_relevant_documents( File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain_core/retrievers.py", line 269, in aget_relevant_documents raise e File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain_core/retrievers.py", line 262, in aget_relevant_documents result = await self._aget_relevant_documents( File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain_core/vectorstores.py", line 676, in _aget_relevant_documents docs = await self.vectorstore.asimilarity_search( File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain_core/vectorstores.py", line 387, in asimilarity_search return await asyncio.get_event_loop().run_in_executor(None, func) File "/usr/lib/python3.10/asyncio/futures.py", line 285, in await yield self # This tells Task to wait for completion. File "/usr/lib/python3.10/asyncio/tasks.py", line 304, in __wakeup future.result() File "/usr/lib/python3.10/asyncio/futures.py", line 201, in result raise self._exception.with_traceback(self._exception_tb) File "/usr/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(self.args, **self.kwargs) File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain_community/vectorstores/chroma.py", line 348, in similarity_search docs_and_scores = self.similarity_search_with_score(query, k, filter=filter) File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain_community/vectorstores/chroma.py", line 432, in similarity_search_with_score query_embedding = self._embedding_function.embed_query(query) File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain_community/embeddings/huggingface.py", line 104, in embed_query return self.embed_documents([text])[0] File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain_community/embeddings/huggingface.py", line 85, in embed_documents texts = list(map(lambda x: x.replace("\n", " "), texts)) File "/home/developer/Documentos/llama2-chat-with-documents/venv/lib/python3.10/site-packages/langchain_community/embeddings/huggingface.py", line 85, in texts = list(map(lambda x: x.replace("\n", " "), texts)) AttributeError: 'Message' object has no attribute 'replace'

diogogonnelli commented 10 months ago

Same here

iamsohel commented 8 months ago

i am getting same problem

sny-verma commented 6 months ago

In main.py @ func- process_chat_message(message)

response = await qa_chain.acall(message, callbacks=[callback_handler])

response = await qa_chain.acall(message.content, callbacks=[callback_handler])