« first day (4811 days earlier)      last day (362 days later) » 

09:11
unclear (why does anything actually need to be done? Is the needed information not already right there?) stackoverflow.com/questions/54160957
09:36
Closed
 
9 hours later…
18:49
Hello
19:09
o/
 
3 hours later…
21:49
I'm at a loss here... I have a piece of code that JSON serializes some data, and occasionally users accidentally pass in numpy datatypes instead of regular ints/floats, so if numpy is imported I create a mapping of types that I need to convert to regular ints/floats. Simplified code:
NUMPY_TYPES = {}

if 'numpy' in sys.modules:
    NUMPY_TYPES[sys.modules['numpy'].integer] = int

def json_serialize(data):
    return json.dumps(data, default=default)

def default(data):
    try:
        convert = NUMPY_TYPES[type(data)]
    except KeyError:
        raise TypeError(f"Can't serialize {data!r}")

    return convert(data)
The problem is... a user wrote an app where numpy is imported, but for some reason a numpy.int32 can't be JSON serialized. If I execute the exact same code on my machine, it works. Anyone have a clue what could be causing that?
On the user's PC we also got an error when we tried to compare a numpy int to a string (like np.int32(0) == 'foo') and I also can't reproduce that on my PC
And we have the same version of numpy
Are you sure they are actually using numpy-numpy, and not a weird-but-totally-user-friendly-wrapper-numpy? Speaking based on experience of a friend who got swallowed whole by a numpython...
Might want to compare the full pip freeze.
Also: Same OS? Not mixing Windows and Unix, are we?
22:18
Yup, same OS and import numpy as np
23:01
Numpy types have never been serialised?
For the longest time I've converted back to python in flask
Been serializable* I do apologise, I just woke up and checked my phone :P
Hello, Python beginner here.

I am trying to create a chatbot using openai (assistants api) + python
But getting an error "The model asst_XXXXXXXX does not exist"

My code is here, I do not know what to do.

    import openai

    openai.api_key = "APIKEY"

    def chatbot_my(conversation_history, assistant_id):
        response = openai.chat.completions.create(
            model=assistant_id,
            messages=conversation_history
        )
        return response.choices[0].message.content.strip()

« first day (4811 days earlier)      last day (362 days later) »