-1

I have to send lists of text embeddings in flask output. The output looks as follows:

{"embeddings":[[0.1,0.2,0.3],[0.4,0.5,0.6],[0.7,0.8,0.9]]}

I tried doing json.dumps and jsonify from flask but still I get following error when sending above output in flask response:

TypeError: Object of type float32 is not JSON serializable

How can I fix it?

1
  • You should provide the code you want to get fixed. Commented Mar 1, 2023 at 9:19

1 Answer 1

0

You need to convert that into a native Python data type before serializing it to JSON

import numpy as np

embeddings = np.array([[0.1, 0.2, 0.3], [0.4, 0.5, 0.6], [0.7, 0.8, 0.9]], dtype=np.float32)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.