manateelazycat / mind-wave

Emacs AI plugin based on ChatGPT API
GNU General Public License v3.0
159 stars 26 forks source link

Issue with get_chunk_result #39

Open illgenr opened 10 months ago

illgenr commented 10 months ago

After installing dependencies I had an issue with the get_chunk_result function in mind_wave.py. The attributes being checked for were never found. Not sure if it's a python 3.10 issue.

This correctly checks the chunk

def get_chunk_result(self, chunk):
        delta = chunk.choices[0].delta
        if chunk.choices[0].finish_reason == "stop":
            return ("end", "")

        # Check if delta has the attribute 'role'
        if hasattr(delta, 'role') and delta.role is not None:
            return ("start", "")

        # Check if delta has the attribute 'content'
        if hasattr(delta, 'content') and delta.content is not None:
            return ("content", string_to_base64(delta.content))            

        # Handle any other case not covered above
        return ("unknown", "")