Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

[Question]: TypeError: 'NoneType' object is not callable #7230

Closed
1 task done
xinkeyb opened this issue Aug 11, 2023 · 3 comments
Closed
1 task done

[Question]: TypeError: 'NoneType' object is not callable #7230

xinkeyb opened this issue Aug 11, 2023 · 3 comments
Labels
question Further information is requested

Comments

@xinkeyb
Copy link

xinkeyb commented Aug 11, 2023

Question Validation

  • I have searched both the documentation and discord for an answer.

Question

Can someone help me? I would greatly appreciate it

The previous code worked fine and generated an answer, but in the end, an error was always reported:

Exception ignored in: <function Driver.del at 0x7f5670ae5ca0>
Traceback (most recent call last):
File "/home/zhaoxinke/miniconda3/envs/kgllm2/lib/python3.9/site-packages/neo4j/_sync/driver.py", line 485, in del
File "/home/zhaoxinke/miniconda3/envs/kgllm2/lib/python3.9/site-packages/neo4j/_meta.py", line 226, in unclosed_resource_warn
TypeError: 'NoneType' object is not callable

@xinkeyb xinkeyb added the question Further information is requested label Aug 11, 2023
@dosubot
Copy link

dosubot bot commented Aug 11, 2023

Answer generated by a 🤖

Answer

Hello,

The error you're encountering, "TypeError: 'NoneType' object is not callable", typically happens when you're trying to call a method on an object that is None. In your case, it seems like the error is coming from the Driver.__del__ method in the neo4j package.

The Driver.__del__ method is a destructor that is called when the object is about to be destroyed. If an error occurs in this method, it's usually because the object or its resources have already been cleaned up or are in an invalid state.

From the traceback, it seems like the error is happening in the unclosed_resource_warn function. This function is likely trying to call a method or function that is None, which is causing the error.

Without more information, it's hard to say exactly what's causing the error. However, it could be that the Driver object is being deleted before its resources have been properly cleaned up.

To debug this issue, you could try the following:

  1. Check if the Driver object is being used after it has been deleted. If it is, you'll need to ensure that it's not deleted until after you're done using it.

  2. Check if there's an issue with the unclosed_resource_warn function. It could be that this function is trying to call a method or function that doesn't exist or has already been deleted.

  3. Check if there's an issue with the way you're using the neo4j package. You might be using it in a way that's causing the Driver object to be in an invalid state when it's deleted.

I hope this helps! If you're still having issues, please provide more information about how you're using the neo4j package and the Driver object, and I'll do my best to assist you further.

Best regards,
Dosu

Sources


This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

@xinkeyb
Copy link
Author

xinkeyb commented Aug 11, 2023

In fact, I am using The example code in the llama_index's document. No changes have been made to it.

This is th whole code:

import os
import openai
import logging
import sys
from llama_index.llms import CustomLLM, CompletionResponse, LLMMetadata
from llama_index.llms.base import llm_chat_callback, llm_completion_callback
from llama_index import ServiceContext
import torch
from transformers import pipeline
from typing import Optional, List, Mapping, Any

from llama_index import (
    ServiceContext,
    SimpleDirectoryReader,
    LangchainEmbedding,
    ListIndex
)

from llama_index.llms.base import CompletionResponseGen
from llama_index.callbacks import CallbackManager

openai.api_key = "sk-HimVsxWOdru4j46CdRq9eR8GXnWpCtVbyO5y4L8JeAt9c9EH"


import logging
import sys
from llama_index.llms import OpenAI
from llama_index import ServiceContext

logging.basicConfig(stream=sys.stdout, level=logging.INFO)

# define LLM
llm = OpenAI(temperature=0, model="gpt-3.5-turbo")
service_context = ServiceContext.from_defaults(llm=llm, chunk_size=512, embed_model="local")


from llama_index import (
    KnowledgeGraphIndex,
    LLMPredictor,
    ServiceContext,
    SimpleDirectoryReader,
)
from llama_index.storage.storage_context import StorageContext
from llama_index.graph_stores import Neo4jGraphStore

from llama_index.llms import OpenAI
from IPython.display import Markdown, display


username = "neo4j"
password = "Shb9Sy5q_j_5hw_ZybKyfr6SPQsqqdB7Z-Xza4-pgQ"
url = "neo4j+s://46de362d.databases.neo4j.io:7687"
database = "neo4j"



documents = SimpleDirectoryReader(
    "./data"
).load_data()

graph_store = Neo4jGraphStore(
    username=username,
    password=password,
    url=url,
    database=database,
)

storage_context = StorageContext.from_defaults(graph_store=graph_store)



from llama_index.query_engine import KnowledgeGraphQueryEngine

query_engine = KnowledgeGraphQueryEngine(
    storage_context=storage_context,
    service_context=service_context,
    llm=llm,
    verbose=True,
)


response = query_engine.query("小明在哪里出生")
display(Markdown(f"<b>{response}</b>"))

This is the result:

INFO:sentence_transformers.SentenceTransformer:Load pretrained SentenceTransformer: sentence-transformers/all-MiniLM-L6-v2
INFO:sentence_transformers.SentenceTransformer:Use pytorch device: cuda
Graph Store Query: MATCH (p:Person {name: '小明'})-[:出生于]->(l:Location)
RETURN l.name
INFO:llama_index.query_engine.knowledge_graph_query_engine:Graph Store Query: MATCH (p:Person {name: '小明'})-[:出生于]->(l:Location)
RETURN l.name
Graph Store Response: [{'l.name': '中国'}]
INFO:llama_index.query_engine.knowledge_graph_query_engine:Graph Store Response: [{'l.name': '中国'}]
Final Response: 小明在中国出生。
小明在中国出生。
Exception ignored in: <function Driver.__del__ at 0x7fd572b36ca0>
Traceback (most recent call last):
  File "/home/zhaoxinke/miniconda3/envs/kgllm2/lib/python3.9/site-packages/neo4j/_sync/driver.py", line 485, in __del__
  File "/home/zhaoxinke/miniconda3/envs/kgllm2/lib/python3.9/site-packages/neo4j/_meta.py", line 226, in unclosed_resource_warn
TypeError: 'NoneType' object is not callable

@logan-markewich
Copy link
Collaborator

@xinkeyb does this error stop execution? It seems like it printed the final response there, the "error" just happens on shutdown?

@run-llama run-llama locked and limited conversation to collaborators Oct 24, 2023
@Disiok Disiok converted this issue into discussion #8383 Oct 24, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants