Skip to content
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

[BUG] NULL pointer access for text interface #189

Open
fbesoainp opened this issue Oct 25, 2024 · 0 comments
Open

[BUG] NULL pointer access for text interface #189

fbesoainp opened this issue Oct 25, 2024 · 0 comments
Labels
🐞 bug Something isn't working

Comments

@fbesoainp
Copy link

fbesoainp commented Oct 25, 2024

Issue Description

I’m encountering a ValueError: NULL pointer access error when calling create_completion or create_chat_completion in the NexaTextInference interface. This issue started unexpectedly, despite previously working fine. Restarting my computer didn’t resolve the issue.

Code sample:

from threading import Lock
from nexa_sdk import NexaTextInference, CreateChatCompletionResponse, CreateChatCompletionStreamResponse
from typing import Iterator

class NexaaiIntegration:
    _instance: NexaaiIntegration | None = None
    _lock: Lock = Lock()
    inference: NexaTextInference | None = None

    def __new__(cls, model_path="llama3-uncensored") -> NexaaiIntegration:
        with cls._lock:
            if cls._instance is None:
                cls._instance = super(NexaaiIntegration, cls).__new__(cls)
                cls._instance.inference = NexaTextInference(
                    model_path=model_path,
                    local_path=None,
                    stop_words=[],
                    temperature=0.5,
                    max_new_tokens=100,
                    top_k=20,
                    top_p=0.9,
                    profiling=True,
                    embedding=True
                )
                cls._instance.inference.create_embedding("You are an AI assistant for a software engineering team.")

            return cls._instance

    def create_text_completion(
        self, message: str
    ) -> CreateChatCompletionResponse | Iterator[CreateChatCompletionStreamResponse]:
        """Returns a completion for a chat message."""
        return self._instance.inference.create_completion(message)


nexa = NexaaiIntegration()
completion = nexa.create_text_completion("Hello, how are you?")
print(completion)

Steps to Reproduce

Run this code sample:

from threading import Lock
from nexa_sdk import NexaTextInference, CreateChatCompletionResponse, CreateChatCompletionStreamResponse
from typing import Iterator

class NexaaiIntegration:
    _instance: NexaaiIntegration | None = None
    _lock: Lock = Lock()
    inference: NexaTextInference | None = None

    def __new__(cls, model_path="llama3-uncensored") -> NexaaiIntegration:
        with cls._lock:
            if cls._instance is None:
                cls._instance = super(NexaaiIntegration, cls).__new__(cls)
                cls._instance.inference = NexaTextInference(
                    model_path=model_path,
                    local_path=None,
                    stop_words=[],
                    temperature=0.5,
                    max_new_tokens=100,
                    top_k=20,
                    top_p=0.9,
                    profiling=True,
                    embedding=True
                )
                cls._instance.inference.create_embedding("You are an AI assistant for a software engineering team.")

            return cls._instance

    def create_text_completion(
        self, message: str
    ) -> CreateChatCompletionResponse | Iterator[CreateChatCompletionStreamResponse]:
        """Returns a completion for a chat message."""
        return self._instance.inference.create_completion(message)


nexa = NexaaiIntegration()
completion = nexa.create_text_completion("Hello, how are you?")
print(completion)

OS

macOS

Python Version

3.11.7

Nexa SDK Version

0.0.9.0

GPU (if using one)

Apple M1 Pro

@fbesoainp fbesoainp added the 🐞 bug Something isn't working label Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant