Bulk embedding error
I am getting Failed to Fetch error when I wanted to test batch embedding here: https://jina.ai/embeddings/#faq:~:text=research%20paper%20below.-,Embedding%20API,-Try%20our%20world
Also, i tried to test bulk embedding below. input.csv has only 3 sentences with newlines. But it is raising Error 500: Internal Server Error. I wonder why is this happening and will it be fixed soon?
import requests
import json
File and model details
file_path = "/content/input.csv"
model_name = "jina-embeddings-v3"
email = "[email protected]"
token = userdata.get("JINA_API_KEY")
url = 'https://api.jina.ai/v1/bulk-embeddings'
headers = {"Authorization": f"Bearer {token}"}
data = {'model': model_name, 'email': email}
Send the file in the request
with open(file_path, 'rb') as file:
response = requests.post(url, headers=headers, data=data, files={'file': file})
Handle response
if response.ok:
print("Success:", response.json())
else:
print(f"Error {response.status_code}: {response.text}")
Hello @aikokul ,
We have identified the problem and we are working on solving it.
However, there is also a bug in your code, it should look something like this:
import requests
# Define the API endpoint
url = 'http://api.jina.ai/v1/bulk-embeddings'
# Define the headers
headers = {
'accept': 'application/json',
'Authorization': 'Bearer <jina_api_token>,
}
# Define the files and data for the POST request
files = {
'file': ('<file_path>', open('<file_path>', 'rb'), 'text/plain'),
}
data = {
'email': '<your-email>',
'model': 'jina-embeddings-v3',
}
# Send the POST request
response = requests.post(url, headers=headers, files=files, data=data)
# Output the response
print(response.status_code)
print(response.json())
This is not working yet, will let you know when it does.
Got it, thanks!
This is now working, Thanks for the patience
Closing the issue as it's resolved