Closed wwjCMP closed 2 months ago
The error NameError: name 'self' is not defined
suggests there's a problem with how self
is used in your code. In Python, self
is used within class methods to refer to the instance of the class. If you're seeing this error, it likely means self
is being used outside of a class method or in a context where it's not defined.
From the code snippet you shared, self
is not explicitly used, which indicates the issue might be in another part of your code not shown here. It's important to ensure that self
is only used within class instance methods.
Additionally, the instantiation of OllamaEmbeddings
in your code does not show a misuse of self
, but make sure the parameters you're passing (like model="ollama/nomic-embed-text:latest"
) match the expected parameters of the OllamaEmbeddings
class. Specifically, if OllamaEmbeddings
expects a base_url
parameter, ensure you're providing it correctly.
If the problem persists, please provide more context or the specific part of the code where self
is used, along with any additional error messages or tracebacks. This will help in diagnosing the issue more accurately.
To continue the conversation, mention @dosu.
What happened?
def get_embeddings(): settings = BrainSettings() # pyright: ignore reportPrivateUsage=none if settings.ollama_api_base_url: embeddings = OllamaEmbeddings( model="ollama/nomic-embed-text:latest" ) # pyright: ignore reportPrivateUsage=none else: embeddings = OpenAIEmbeddings() # pyright: ignore reportPrivateUsage=none return embeddings
I have set it as above, but the following error occurred:
Relevant log output
Twitter / LinkedIn details
No response