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
30.22k stars 3.81k forks source link

PGBVector - 'CacheMiss' object has no attribute 'get' #2048

Closed ritzshah closed 2 months ago

ritzshah commented 4 months ago

Describe the bug A clear and concise description of what the bug is. While implementing a Vector Store using PostgreSQL (PGVector) connecting to localhost:5432, get error "'CacheMiss' object has no attribute 'get'"

Browser and Version

Langflow version - v1.0.0a43...

To Reproduce Steps to reproduce the behavior:

  1. Go to 'VectorStore'
  2. Drag 'PGVector' to canvas. Use Emedding as Ollama Embedding(sroecker/granite-7b-lab:latest) and input as Recursive Character Text with Chunk Size as 1024 (Input is from URL - https://www.ml.school/ image

& this is the error message image

Screenshots If applicable, add screenshots to help explain your problem.

Error message on langflow terminal venv/venv310/lib/python3.10/site-packages/langchain_community/vectorstores/pgvector.py:322: LangChainPendingDeprecationWarning: Please use JSONB instead of JSON for metadata. This change will allow for more efficient querying that involves filtering based on metadata.Please note that filtering operators have been changed when using JSOB metadata to be prefixed with a $ sign to avoid name collisions with columns. If you're using an existing database, you will need to create adb migration for your metadata column to be JSONB and update your queries to use the new operators. warn_deprecated( objc[34747]: +[NSCFConstantString initialize] may have been in progress in another thread when fork() was called. objc[34747]: +[NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug. [06/03/24 11:09:10] ERROR 2024-06-03 11:09:10 - ERROR - glogging - Worker (pid:34747) was sent SIGABRT! glogging.py:272 Starting Langflow v1.0.0a41... [06/03/24 11:09:14] ERROR 2024-06-03 11:09:14 - ERROR - chat - Error building vertex: 'CacheMiss' object has no attribute 'get' chat.py:232 ERROR 2024-06-03 11:09:14 - ERROR - chat - 'CacheMiss' object has no attribute 'get' chat.py:233 Traceback (most recent call last):

                           File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 196, in _run_module_as_main                    
                             return _run_code(code, main_globals, None,                                                                                                     
                                    |         |     -> {'__name__': '__main__', '__doc__': None, '__package__': 'langflow', '__loader__':                                   
                         <_frozen_importlib_external.SourceFileLoad...                                                                                                      
                                    |         -> <code object <module> at 0x1025f4500, file                                                                                 
                         "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/langflow/__main__.py"...                                                              
                                    -> <function _run_code at 0x1025deb00>                                                                                                  
                           File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 86, in _run_code                               
                             exec(code, run_globals)                                                                                                                        
                                  |     -> {'__name__': '__main__', '__doc__': None, '__package__': 'langflow', '__loader__':                                               
                         <_frozen_importlib_external.SourceFileLoad...                                                                                                      
                                  -> <code object <module> at 0x1025f4500, file                                                                                             
                         "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/langflow/__main__.py"...                                                              
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/langflow/__main__.py", line 583, in <module>                                   
                             main()                                                                                                                                         
                             -> <function main at 0x12415a950>                                                                                                              
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/langflow/__main__.py", line 579, in main                                       
                             app()                                                                                                                                          
                             -> <typer.main.Typer object at 0x10574ad10>                                                                                                    
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/typer/main.py", line 309, in __call__                                          
                             return get_command(self)(*args, **kwargs)                                                                                                      
                                    |           |      |       -> {}                                                                                                        
                                    |           |      -> ()                                                                                                                
                                    |           -> <typer.main.Typer object at 0x10574ad10>                                                                                 
                                    -> <function get_command at 0x1042827a0>                                                                                                
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/click/core.py", line 1157, in __call__                                         
                             return self.main(*args, **kwargs)                                                                                                              
                                    |    |     |       -> {}                                                                                                                
                                    |    |     -> ()                                                                                                                        
                                    |    -> <function TyperGroup.main at 0x104280ee0>                                                                                       
                                    -> <TyperGroup >                                                                                                                        
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/typer/core.py", line 723, in main                                              
                             return _main(                                                                                                                                  
                                    -> <function _main at 0x104280280>                                                                                                      
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/typer/core.py", line 193, in _main                                             
                             rv = self.invoke(ctx)                                                                                                                          
                                  |    |      -> <click.core.Context object at 0x124224490>                                                                                 
                                  |    -> <function MultiCommand.invoke at 0x103110a60>                                                                                     
                                  -> <TyperGroup >                                                                                                                          
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/click/core.py", line 1688, in invoke                                           
                             return _process_result(sub_ctx.command.invoke(sub_ctx))                                                                                        
                                    |               |       |       |      -> <click.core.Context object at 0x124227340>                                                    
                                    |               |       |       -> <function Command.invoke at 0x103110550>                                                             
                                    |               |       -> <TyperCommand run>                                                                                           
                                    |               -> <click.core.Context object at 0x124227340>                                                                           
                                    -> <function MultiCommand.invoke.<locals>._process_result at 0x12415af80>                                                               
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/click/core.py", line 1434, in invoke                                           
                             return ctx.invoke(self.callback, **ctx.params)                                                                                                 
                                    |   |      |    |           |   -> {'host': '127.0.0.1', 'workers': 1, 'timeout': 300, 'port': 7860, 'components_path':                 
                         PosixPath('/Users/riteshshah/venv/venv31...                                                                                                        
                                    |   |      |    |           -> <click.core.Context object at 0x124227340>                                                               
                                    |   |      |    -> <function run at 0x12415add0>                                                                                        
                                    |   |      -> <TyperCommand run>                                                                                                        
                                    |   -> <function Context.invoke at 0x1030f3250>                                                                                         
                                    -> <click.core.Context object at 0x124227340>                                                                                           
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/click/core.py", line 783, in invoke                                            
                             return __callback(*args, **kwargs)                                                                                                             
                                                |       -> {'host': '127.0.0.1', 'workers': 1, 'timeout': 300, 'port': 7860, 'components_path':                             
                         PosixPath('/Users/riteshshah/venv/venv31...                                                                                                        
                                                -> ()                                                                                                                       
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/typer/main.py", line 692, in wrapper                                           
                             return callback(**use_params)                                                                                                                  
                                    |          -> {'host': '127.0.0.1', 'workers': 1, 'timeout': 300, 'port': 7860, 'components_path':                                      
                         PosixPath('/Users/riteshshah/venv/venv31...                                                                                                        
                                    -> <function run at 0x12415a710>                                                                                                        
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/langflow/__main__.py", line 169, in run                                        
                             process = run_on_mac_or_linux(host, port, log_level, options, app)                                                                             
                                       |                   |     |     |          |        -> <fastapi.applications.FastAPI object at 0x124227f70>                          
                                       |                   |     |     |          -> {'bind': '127.0.0.1:7860', 'workers': 1, 'timeout': 300, 'worker_class':               
                         'langflow.server.LangflowUvicornWorker', 'logger_cla...                                                                                            
                                       |                   |     |     -> 'critical'                                                                                        
                                       |                   |     -> 7860                                                                                                    
                                       |                   -> '127.0.0.1'                                                                                                   
                                       -> <function run_on_mac_or_linux at 0x124158550>                                                                                     
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/langflow/__main__.py", line 192, in run_on_mac_or_linux                        
                             webapp_process.start()                                                                                                                         
                             |              -> <function BaseProcess.start at 0x1042a2710>                                                                                  
                             -> <Process name='Process-1' parent=24797 started>                                                                                             
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/multiprocess/process.py", line 121, in start                                   
                             self._popen = self._Popen(self)                                                                                                                
                             |    |        |    |      -> <Process name='Process-1' parent=24797 started>                                                                   
                             |    |        |    -> <staticmethod(<function Process._Popen at 0x1043bf370>)>                                                                 
                             |    |        -> <Process name='Process-1' parent=24797 started>                                                                               
                             |    -> None                                                                                                                                   
                             -> <Process name='Process-1' parent=24797 started>                                                                                             
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/multiprocess/context.py", line 224, in _Popen                                  
                             return _default_context.get_context().Process._Popen(process_obj)                                                                              
                                    |                |                            -> <Process name='Process-1' parent=24797 started>                                        
                                    |                -> <function DefaultContext.get_context at 0x1043bf520>                                                                
                                    -> <multiprocess.context.DefaultContext object at 0x10404a020>                                                                          
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/multiprocess/context.py", line 281, in _Popen                                  
                             return Popen(process_obj)                                                                                                                      
                                    |     -> <Process name='Process-1' parent=24797 started>                                                                                
                                    -> <class 'multiprocess.popen_fork.Popen'>                                                                                              
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/multiprocess/popen_fork.py", line 19, in __init__                              
                             self._launch(process_obj)                                                                                                                      
                             |    |       -> <Process name='Process-1' parent=24797 started>                                                                                
                             |    -> <function Popen._launch at 0x1245604c0>                                                                                                
                             -> <multiprocess.popen_fork.Popen object at 0x124523ac0>                                                                                       
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/multiprocess/popen_fork.py", line 71, in _launch                               
                             code = process_obj._bootstrap(parent_sentinel=child_r)                                                                                         
                                    |           |                          -> 6                                                                                             
                                    |           -> <function BaseProcess._bootstrap at 0x1042a3010>                                                                         
                                    -> <Process name='Process-1' parent=24797 started>                                                                                      
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/multiprocess/process.py", line 314, in _bootstrap                              
                             self.run()                                                                                                                                     
                             |    -> <function BaseProcess.run at 0x1042a2680>                                                                                              
                             -> <Process name='Process-1' parent=24797 started>                                                                                             
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/multiprocess/process.py", line 108, in run                                     
                             self._target(*self._args, **self._kwargs)                                                                                                      
                             |    |        |    |        |    -> {}                                                                                                         
                             |    |        |    |        -> <Process name='Process-1' parent=24797 started>                                                                 
                             |    |        |    -> ('127.0.0.1', 7860, 'critical', {'bind': '127.0.0.1:7860', 'workers': 1, 'timeout': 300, 'worker_class':                 
                         'langflow.server.Lan...                                                                                                                            
                             |    |        -> <Process name='Process-1' parent=24797 started>                                                                               
                             |    -> <function run_langflow at 0x12415a7a0>                                                                                                 
                             -> <Process name='Process-1' parent=24797 started>                                                                                             
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/langflow/__main__.py", line 413, in run_langflow                               
                             LangflowApplication(app, options).run()                                                                                                        
                             |                   |    -> {'bind': '127.0.0.1:7860', 'workers': 1, 'timeout': 300, 'worker_class':                                           
                         'langflow.server.LangflowUvicornWorker', 'logger_cla...                                                                                            
                             |                   -> <fastapi.applications.FastAPI object at 0x124227f70>                                                                    
                             -> <class 'langflow.server.LangflowApplication'>                                                                                               
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/gunicorn/app/base.py", line 72, in run                                         
                             Arbiter(self).run()                                                                                                                            
                             |       -> <langflow.server.LangflowApplication object at 0x1042b8040>                                                                         
                             -> <class 'gunicorn.arbiter.Arbiter'>                                                                                                          
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/gunicorn/arbiter.py", line 211, in run                                         
                             self.manage_workers()                                                                                                                          
                             |    -> <function Arbiter.manage_workers at 0x124588280>                                                                                       
                             -> <gunicorn.arbiter.Arbiter object at 0x124523820>                                                                                            
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/gunicorn/arbiter.py", line 571, in manage_workers                              
                             self.spawn_workers()                                                                                                                           
                             |    -> <function Arbiter.spawn_workers at 0x1245883a0>                                                                                        
                             -> <gunicorn.arbiter.Arbiter object at 0x124523820>                                                                                            
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/gunicorn/arbiter.py", line 642, in spawn_workers                               
                             self.spawn_worker()                                                                                                                            
                             |    -> <function Arbiter.spawn_worker at 0x124588310>                                                                                         
                             -> <gunicorn.arbiter.Arbiter object at 0x124523820>                                                                                            
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker                                
                             worker.init_process()                                                                                                                          
                             |      -> <function UvicornWorker.init_process at 0x124762d40>                                                                                 
                             -> <langflow.server.LangflowUvicornWorker object at 0x103bfc310>                                                                               
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/uvicorn/workers.py", line 68, in init_process                                  
                             super().init_process()                                                                                                                         
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/gunicorn/workers/base.py", line 142, in init_process                           
                             self.run()                                                                                                                                     
                             |    -> <function UvicornWorker.run at 0x124762f80>                                                                                            
                             -> <langflow.server.LangflowUvicornWorker object at 0x103bfc310>                                                                               
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/uvicorn/workers.py", line 100, in run                                          
                             return asyncio.run(self._serve())                                                                                                              
                                    |       |   |    -> <function LangflowUvicornWorker._serve at 0x1247630a0>                                                              
                                    |       |   -> <langflow.server.LangflowUvicornWorker object at 0x103bfc310>                                                            
                                    |       -> <function _patch_asyncio.<locals>.run at 0x124763be0>                                                                        
                                    -> <module 'asyncio' from '/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/__init__.py'>            
                           File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run                           
                             return loop.run_until_complete(main)                                                                                                           
                                    |    |                  -> <coroutine object LangflowUvicornWorker._serve at 0x124725000>                                               
                                    |    -> <function _patch_loop.<locals>.run_until_complete at 0x124b2c4c0>                                                               
                                    -> <_UnixSelectorEventLoop running=True closed=False debug=False>                                                                       
                           File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 633, in                          
                         run_until_complete                                                                                                                                 
                             self.run_forever()                                                                                                                             
                             |    -> <function _patch_loop.<locals>.run_forever at 0x124b2c430>                                                                             
                             -> <_UnixSelectorEventLoop running=True closed=False debug=False>                                                                              
                           File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 600, in run_forever              
                             self._run_once()                                                                                                                               
                             |    -> <function _patch_loop.<locals>._run_once at 0x124b2c550>                                                                               
                             -> <_UnixSelectorEventLoop running=True closed=False debug=False>                                                                              
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/nest_asyncio.py", line 133, in _run_once                                       
                             handle._run()                                                                                                                                  
                             |      -> <function Handle._run at 0x104447490>                                                                                                
                             -> <Handle Task.__wakeup(<Future finis... 48, 573761))>)>                                                                                      
                           File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/events.py", line 80, in _run                           
                             self._context.run(self._callback, *self._args)                                                                                                 
                             |    |            |    |           |    -> <member '_args' of 'Handle' objects>                                                                
                             |    |            |    |           -> <Handle Task.__wakeup(<Future finis... 48, 573761))>)>                                                   
                             |    |            |    -> <member '_callback' of 'Handle' objects>                                                                             
                             |    |            -> <Handle Task.__wakeup(<Future finis... 48, 573761))>)>                                                                    
                             |    -> <member '_context' of 'Handle' objects>                                                                                                
                             -> <Handle Task.__wakeup(<Future finis... 48, 573761))>)>                                                                                      
                           File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/tasks.py", line 315, in __wakeup                       
                             self.__step()                                                                                                                                  
                             -> <Task pending name='starlette.middleware.base.BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.coro' coro=<BaseHTTPMid...            
                           File "/opt/local/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/tasks.py", line 232, in __step                         
                             result = coro.send(None)                                                                                                                       
                                      |    -> <method 'send' of 'coroutine' objects>                                                                                        
                                      -> <coroutine object BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.coro at 0x291d8fa00>                                     
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/starlette/middleware/base.py", line 151, in coro                               
                             await self.app(scope, receive_or_disconnect, send_no_error)                                                                                    
                                   |    |   |      |                      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.send_no_error at             
                         0x291f4a950>                                                                                                                                       
                                   |    |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x291f4a830>               
                                   |    |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server':                         
                         ('127.0.0.1', 7860), 'cl...                                                                                                                        
                                   |    -> <starlette.middleware.cors.CORSMiddleware object at 0x124b07220>                                                                 
                                   -> <langflow.main.JavaScriptMIMETypeMiddleware object at 0x124b07070>                                                                    
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/starlette/middleware/cors.py", line 93, in __call__                            
                             await self.simple_response(scope, receive, send, request_headers=headers)                                                                      
                                   |    |               |      |        |                     -> Headers({'host': '127.0.0.1:7860', 'connection': 'keep-alive',             
                         'content-length': '0', 'sec-ch-ua': '"Chromium";v="124", "Goog...                                                                                  
                                   |    |               |      |        -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.send_no_error at               
                         0x291f4a950>                                                                                                                                       
                                   |    |               |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at                
                         0x291f4a830>                                                                                                                                       
                                   |    |               -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server':             
                         ('127.0.0.1', 7860), 'cl...                                                                                                                        
                                   |    -> <function CORSMiddleware.simple_response at 0x1065ead40>                                                                         
                                   -> <starlette.middleware.cors.CORSMiddleware object at 0x124b07220>                                                                      
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/starlette/middleware/cors.py", line 148, in simple_response                    
                             await self.app(scope, receive, send)                                                                                                           
                                   |    |   |      |        -> functools.partial(<bound method CORSMiddleware.send of <starlette.middleware.cors.CORSMiddleware             
                         object at 0x124b07220>>, sen...                                                                                                                    
                                   |    |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x291f4a830>               
                                   |    |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server':                         
                         ('127.0.0.1', 7860), 'cl...                                                                                                                        
                                   |    -> <starlette.middleware.exceptions.ExceptionMiddleware object at 0x124b07250>                                                      
                                   -> <starlette.middleware.cors.CORSMiddleware object at 0x124b07220>                                                                      
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 65, in __call__                      
                             await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)                                                                       
                                   |                            |    |    |     |      |        -> functools.partial(<bound method CORSMiddleware.send of                   
                         <starlette.middleware.cors.CORSMiddleware object at 0x124b07220>>, sen...                                                                          
                                   |                            |    |    |     |      -> <function                                                                         
                         BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x291f4a830>                                                      
                                   |                            |    |    |     -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'},                      
                         'http_version': '1.1', 'server': ('127.0.0.1', 7860), 'cl...                                                                                       
                                   |                            |    |    -> <starlette.requests.Request object at 0x291c4f490>                                             
                                   |                            |    -> <fastapi.routing.APIRouter object at 0x1242268c0>                                                   
                                   |                            -> <starlette.middleware.exceptions.ExceptionMiddleware object at 0x124b07250>                              
                                   -> <function wrap_app_handling_exceptions at 0x106577490>                                                                                
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app                      
                             await app(scope, receive, sender)                                                                                                              
                                   |   |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x291f4b520>                       
                                   |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x291f4a830>                    
                                   |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1',                
                         7860), 'cl...                                                                                                                                      
                                   -> <fastapi.routing.APIRouter object at 0x1242268c0>                                                                                     
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/starlette/routing.py", line 756, in __call__                                   
                             await self.middleware_stack(scope, receive, send)                                                                                              
                                   |    |                |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at                  
                         0x291f4b520>                                                                                                                                       
                                   |    |                |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at               
                         0x291f4a830>                                                                                                                                       
                                   |    |                -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server':            
                         ('127.0.0.1', 7860), 'cl...                                                                                                                        
                                   |    -> <bound method Router.app of <fastapi.routing.APIRouter object at 0x1242268c0>>                                                   
                                   -> <fastapi.routing.APIRouter object at 0x1242268c0>                                                                                     
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/starlette/routing.py", line 776, in app                                        
                             await route.handle(scope, receive, send)                                                                                                       
                                   |     |      |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x291f4b520>              
                                   |     |      |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at                        
                         0x291f4a830>                                                                                                                                       
                                   |     |      -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server':                     
                         ('127.0.0.1', 7860), 'cl...                                                                                                                        
                                   |     -> <function Route.handle at 0x10659cca0>                                                                                          
                                   -> APIRoute(path='/api/v1/build/{flow_id}/vertices/{vertex_id}', name='build_vertex', methods=['POST'])                                  
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/starlette/routing.py", line 297, in handle                                     
                             await self.app(scope, receive, send)                                                                                                           
                                   |    |   |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x291f4b520>                  
                                   |    |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x291f4a830>               
                                   |    |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server':                         
                         ('127.0.0.1', 7860), 'cl...                                                                                                                        
                                   |    -> <function request_response.<locals>.app at 0x1242d0e50>                                                                          
                                   -> APIRoute(path='/api/v1/build/{flow_id}/vertices/{vertex_id}', name='build_vertex', methods=['POST'])                                  
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/starlette/routing.py", line 77, in app                                         
                             await wrap_app_handling_exceptions(app, request)(scope, receive, send)                                                                         
                                   |                            |    |        |      |        -> <function                                                                  
                         wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x291f4b520>                                                                  
                                   |                            |    |        |      -> <function                                                                           
                         BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x291f4a830>                                                      
                                   |                            |    |        -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'},                        
                         'http_version': '1.1', 'server': ('127.0.0.1', 7860), 'cl...                                                                                       
                                   |                            |    -> <starlette.requests.Request object at 0x291c4fdf0>                                                  
                                   |                            -> <function request_response.<locals>.app.<locals>.app at 0x291f4b5b0>                                     
                                   -> <function wrap_app_handling_exceptions at 0x106577490>                                                                                
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app                      
                             await app(scope, receive, sender)                                                                                                              
                                   |   |      |        -> <function wrap_app_handling_exceptions.<locals>.wrapped_app.<locals>.sender at 0x291f4b640>                       
                                   |   |      -> <function BaseHTTPMiddleware.__call__.<locals>.call_next.<locals>.receive_or_disconnect at 0x291f4a830>                    
                                   |   -> {'type': 'http', 'asgi': {'version': '3.0', 'spec_version': '2.4'}, 'http_version': '1.1', 'server': ('127.0.0.1',                
                         7860), 'cl...                                                                                                                                      
                                   -> <function request_response.<locals>.app.<locals>.app at 0x291f4b5b0>                                                                  
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/starlette/routing.py", line 72, in app                                         
                             response = await func(request)                                                                                                                 
                                              |    -> <starlette.requests.Request object at 0x291c4fdf0>                                                                    
                                              -> <function get_request_handler.<locals>.app at 0x12415b400>                                                                 
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/fastapi/routing.py", line 278, in app                                          
                             raw_response = await run_endpoint_function(                                                                                                    
                                                  -> <function run_endpoint_function at 0x10659db40>                                                                        
                           File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/fastapi/routing.py", line 191, in run_endpoint_function                        
                             return await dependant.call(**values)                                                                                                          
                                          |         |      -> {'chat_service': <langflow.services.chat.service.ChatService object at 0x291c4ca00>,                          
                         'current_user': User(username='langflow'...                                                                                                        
                                          |         -> <function build_vertex at 0x114bfc5e0>                                                                               
                                          -> <fastapi.dependencies.models.Dependant object at 0x1242919f0>                                                                  
                         > File "/Users/riteshshah/venv/venv310/lib/python3.10/site-packages/langflow/api/v1/chat.py", line 160, in build_vertex                            
                             graph = cache.get("result")                                                                                                                    
                                     -> <CACHE_MISS>                                                                                                                        

                         AttributeError: 'CacheMiss' object has no attribute 'get'                                                                                          

                         ╭───────────────────────────────────────────────── Traceback (most recent call last) ─────────────────────────────────────────────────╮            
                         │ /Users/riteshshah/venv/venv310/lib/python3.10/site-packages/langflow/api/v1/chat.py:160 in build_vertex                             │            
                         │                                                                                                                                     │            
                         │   157 │   │   │   │   flow_id=flow_id_str, session=next(get_session()),                                                             │            
                         │       chat_service=chat_service                                                                                                     │            
                         │   158 │   │   │   )                                                                                                                 │            
                         │   159 │   │   else:                                                                                                                 │            
                         │ ❱ 160 │   │   │   graph = cache.get("result")                                                                                       │            
                         │   161 │   │   vertex = graph.get_vertex(vertex_id)                                                                                  │            
                         │   162 │   │   try:                                                                                                                  │            
                         │   163 │   │   │   lock = chat_service._cache_locks[flow_id_str]                                                                     │            
                         ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯            
                         AttributeError: 'CacheMiss' object has no attribute 'get'   

Additional context Add any other context about the problem here.

dosubot[bot] commented 4 months ago

Hey @ritzshah, I'm here to assist you with the issue you've encountered. I'm a bot designed to help with bug fixes, answer questions, and guide you through becoming a contributor. Let's tackle this together!

To resolve the error "'CacheMiss' object has no attribute 'get'" when trying to build a vertex in the Langflow application using PGVector with PostgreSQL, ensure that the inputs parameter is correctly passed and handled. The error suggests an issue with how the inputs parameter is being accessed or used.

Here is the relevant code snippet from the PGVectorComponent class:

def build(
    self,
    embedding: Embeddings,
    pg_server_url: str,
    collection_name: str,
    inputs: Optional[Record] = None,
) -> Union[VectorStore, BaseRetriever]:
    documents = []
    for _input in inputs or []:
        if isinstance(_input, Record):
            documents.append(_input.to_lc_document())
        else:
            documents.append(_input)
    try:
        if documents is None:
            vector_store = PGVector.from_existing_index(
                embedding=embedding,
                collection_name=collection_name,
                connection_string=pg_server_url,
            )
        else:
            vector_store = PGVector.from_documents(
                embedding=embedding,
                documents=documents,  # type: ignore
                collection_name=collection_name,
                connection_string=pg_server_url,
            )
    except Exception as e:
        raise RuntimeError(f"Failed to build PGVector: {e}")
    return vector_store

Ensure that the inputs parameter is correctly passed as a list of Record objects. The inputs parameter should not be None or an incorrect type that does not have the required attributes.

If the inputs parameter is being fetched from a cache or another source, make sure that the fetched object is indeed a list of Record objects and not a CacheMiss object or any other type that does not have the required attributes.

Here is an example of how you might call the build method correctly:

embedding = ...  # Your Embeddings object
pg_server_url = "your_postgresql_server_url"
collection_name = "your_collection_name"
inputs = [...]  # A list of Record objects

pg_vector_component = PGVectorComponent()
vector_store = pg_vector_component.build(
    embedding=embedding,
    pg_server_url=pg_server_url,
    collection_name=collection_name,
    inputs=inputs
)

Make sure that inputs is a list of Record objects and not None or any other incorrect type. Additionally, refer to the Langflow documentation for more details on the correct usage and configuration of the PGVectorComponent [1][2][3].

To continue talking to Dosu, mention @dosu.

ritzshah commented 4 months ago

Hi Thanks for response @Dosu I see that the Ollama Embeddings have output None and maybe that is causing issue.. When I run the Ollama Embeddings I get this validation error. For further information visit https://errors.pydantic.dev/2.7/v/missing
[06/03/24 11:40:17] ERROR 2024-06-03 11:40:17 - ERROR - utils - Error logging transaction: 4 validation errors for TransactionModel utils.py:200 flow_id
Field required
For further information visit https://errors.pydantic.dev/2.7/v/missing
source
Field required
For further information visit https://errors.pydantic.dev/2.7/v/missing
target
Field required
For further information visit https://errors.pydantic.dev/2.7/v/missing
target_args
Field required
For further information visit https://errors.pydantic.dev/2.7/v/missing

I see that the ollama model is running. ollama ps NAME ID SIZE PROCESSOR UNTIL
sroecker/granite-7b-lab:latest 206d6e1e0e42 5.9 GB 100% GPU 4 minutes from now

This is snapshot from langflow image

Any suggestions as I am providing proper url and the model name as well as temperature but I see output as None which is going as Embedding input to PGVector. Is this an issue and how to fix this?

dosubot[bot] commented 4 months ago

To fix the issue with the Ollama Embeddings component outputting None, ensure that the OllamaEmbeddings object is correctly instantiated and that the API connection is successful. Here is the relevant code snippet from the OllamaEmbeddingsComponent class:

from typing import Optional
from langflow import CustomComponent
from langchain.embeddings.base import Embeddings
from langchain_community.embeddings import OllamaEmbeddings

class OllamaEmbeddingsComponent(CustomComponent):
    display_name: str = "Ollama Embeddings"
    description: str = "Embeddings model from Ollama."
    documentation = "https://python.langchain.com/docs/integrations/text_embedding/ollama"
    beta = True

    def build_config(self):
        return {
            "model": {
                "display_name": "Ollama Model",
            },
            "base_url": {"display_name": "Ollama Base URL"},
            "temperature": {"display_name": "Model Temperature"},
            "code": {"show": False},
        }

    def build(
        self,
        model: str = "llama2",
        base_url: str = "http://localhost:11434",
        temperature: Optional[float] = None,
    ) -> Embeddings:
        try:
            output = OllamaEmbeddings(model=model, base_url=base_url, temperature=temperature)  # type: ignore
        except Exception as e:
            raise ValueError("Could not connect to Ollama API.") from e
        return output

Ensure that:

  1. The model, base_url, and temperature parameters are correctly set and valid.
  2. The Ollama API is running and accessible at the specified base_url.
  3. The OllamaEmbeddings class is correctly imported and used.

If the API connection fails, the ValueError will be raised, indicating the connection issue. You can add logging to capture more details about the exception:

import logging

def build(
    self,
    model: str = "llama2",
    base_url: str = "http://localhost:11434",
    temperature: Optional[float] = None,
) -> Embeddings:
    try:
        output = OllamaEmbeddings(model=model, base_url=base_url, temperature=temperature)  # type: ignore
    except Exception as e:
        logging.error(f"Failed to connect to Ollama API: {e}")
        raise ValueError("Could not connect to Ollama API.") from e
    return output

This will help you diagnose why the embeddings might be None and ensure the component outputs valid embeddings [1][2].

To continue talking to Dosu, mention @dosu.

ritzshah commented 3 months ago

Can you provide details here on what should be the connection string for postgres PGVector DB access using PGVEctor DB Store for storing the embeddings.

dosubot[bot] commented 3 months ago

To correctly set up a connection string for PostgreSQL PGVector DB access and ensure that embeddings are correctly stored, follow these steps:

  1. Define the Connection String: Ensure that your PostgreSQL server connection string is correctly formatted. It should look something like this:

    postgresql://username:password@hostname:port/database
  2. Set Up the PGVectorComponent: Use the PGVectorComponent class to build the vector store. Here is an example of how to use it:

    from langchain.embeddings.base import Embeddings
    from langflow.schema import Record
    from your_module import PGVectorComponent  # Adjust the import based on your module structure
    
    # Example embedding object
    embedding = Embeddings()
    
    # PostgreSQL server connection string
    pg_server_url = "postgresql://username:password@hostname:port/database"
    
    # Name of the table to store the vectors
    collection_name = "your_table_name"
    
    # Optional: List of documents to store
    documents = [Record(content="Your document content")]
    
    # Initialize the PGVectorComponent
    pg_vector_component = PGVectorComponent()
    
    # Build the vector store
    try:
       vector_store = pg_vector_component.build(
           embedding=embedding,
           pg_server_url=pg_server_url,
           collection_name=collection_name,
           inputs=documents  # Optional
       )
    except RuntimeError as e:
       print(f"Error: {e}")
  3. Handle Errors: The build method in the PGVectorComponent class already includes error handling. If there is an issue with building the vector store, it will raise a RuntimeError with the appropriate message.

By following these steps, you can ensure that your connection string is correctly set up and that embeddings are correctly stored in the PostgreSQL PGVector DB. The PGVectorComponent class handles the conversion of inputs to the appropriate document format and manages the connection to the PostgreSQL server, ensuring a smooth setup process [1][2][3].

To continue talking to Dosu, mention @dosu.

anovazzi1 commented 3 months ago

Hello, Sorry for the delay. Did you try using the new version? Does the error still persist?

carlosrcoelho commented 2 months ago

Hi @ritzshah , 
 I hope you're doing well. Just a friendly reminder that if we do not hear back from you within the next 3 days, we will close this issue. If you need more time or further assistance, please let us know.


Thank you for your understanding!

carlosrcoelho commented 2 months ago

Thank you for your contribution! This issue will be closed. If you have any questions or encounter another problem, please open a new issue and we will be ready to assist you.