This message was deleted.
# community-help
s
This message was deleted.
s
It seems to work without the embedding field. Also env is set correctly.
j
Hmm, the code seems fine. Could you try hard-coding the openai api key in the code just to be sure?
Could you also try replicating this with simple curl commands mentioned here: https://typesense.org/docs/guide/semantic-search.html
Finally, I would also recommend upgrading to
0.25.1
from the RC build you're on currently
s
I did all of the above, nothing worked. The version I am running is 0.25.1
j
Could you run this curl command and share the output:
Copy code
curl -X POST \
  'http://localhost:8108/collections' \
  -H 'Content-Type: application/json' \
  -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
  -d '{
        "name": "products",
        "fields": [
          {
            "name": "product_name",
            "type": "string"
          },
          {
            "name": "embedding",
            "type": "float[]",
            "embed": {
              "from": [
                "product_name"
              ],
              "model_config": {
                "model_name": "openai/text-embedding-ada-002",
                "api_key": "your_openai_api_key"
              }
            }
          }
        ]
      }'
s
Here are logs from the server
Sorry, here it is
j
Hmm it seems to work for me:
(Meaning it tries to make a call out to OpenAI to validate the provided API key)
s
I also get an error from OpenAI when I enter the wrong key
But it looks different
j
Oh, so only when you enter the correct key, it throws a Bad Request?
s
Yes
Here is the screenshot with the wrong key
Sorry for confusion
j
That also works for me
Could you show me a full screenshot of the terminal like I have above, blurring out just parts of your openAI api key? I suspect there's some string interpolation issues here
s
I revoked the key
j
Hmmmm... and you're running Typesense on port
8118
instead of the default
8108
?
s
Yes
I have multiple typesense instances on my machine
j
Could you try stopping the Typesense container, removing the data dir and then starting a new container?
s
With default port
?
j
Could you share the command you're using to start Typesense as well?
8118 is fine
s
Here is the command
Copy code
export TYPESENSE_API_KEY=xyz
    
mkdir $(pwd)/typesense-data-dilo

docker run -p 8118:8108 \
            -v$(pwd)/typesense-data-dilo:/data typesense/typesense:0.25.1 \
            --data-dir /data \
            --api-key=$TYPESENSE_API_KEY \
            --enable-cors
I did it, but still having bad request for the right OpenAPI key
j
May I know what host OS (and it's version) you're running docker on?
Also, what version of docker engine are you running?
s
Yes, I will check shortly
macOS: 13.4.1 (c) (22F770820d) Docker version 24.0.5, build ced0996
j
I'm using the same Docker engine version. I'm on macOS 13.5.2. Are you on a mac Intel or M1?
Oh could you also share the version of curl you're using?
s
I am on mac m2 curl 7.88.1
j
Could you try upgrading to curl 8 (via homebrew for eg) just in case?
(I'm kinda perplexed by this issue, so trying to eliminate all possible variables)
Also, could you stop all other Typesense instances, and just have one instance running on port 8108
s
The same shit
Wait, curl wasn't updated
Just a sec
Yeah, the same thing
j
Totally stumped now!
I'm on an M1... Wonder if this is how related to M2
But the fact that the log says JSON exception, somehow the post data is not making it's way properly to Typesense
I've seen this happen when quotes are messed up sometimes... Like instead of the simple
"
if a different unicode character is used for the double quote
s
Is there hardware dependent layer of JSON serialization?
j
I would think not... But may be the library we're using has some hardware specific optimizations...
s
I copied the snippet from docs
The server itself runs in docker
j
May I know which part of the docs? May be I can try copy-pasting from there too
s
One sec
j
https://typesense-community.slack.com/archives/C01P749MET0/p1695155778317229?thread_ts=1695148359.858939&cid=C01P749MET0
Yeah that's what I'd expect too, that Docker should abstract this out... But I've seen strange issues manifest on particular versions of Docker running on particular versions of Linux
s
j
Yup, that's what I did too...
😵‍💫
s
It's saying where the error occurs, maybe you could check which field gives an error?
j
It's a generic JSON exception that's thrown when there's bad JSON in the post body
s
Oh
I can try running typesense instance from a binary or something
j
The mac binary only works on Intel though
Would you be able to try this on M1 or a Linux VM?
s
I can try it in VM I guess
I will do that tomorrow and will let you know (it's late in my time zone)
👍 1
Thank you for being so responsive!
j
Happy to help!
Could you try using a built-in model like s-bert, instead of OpenAI, to see if that also has the same issue?
s
I've checked on M1 mac - the same result (bad request)
Checked built-in model - worked fine
j
Ah ok, so I wonder if somehow OpenAI is returning badly formed JSON data in its response when API keys from your particular account are used. Could you make sure it has enough credits, billing is ok, etc? Also, could you try making an embedding API call to OpenAI directly with a test string and see what the JSON output looks like?
s
Yes, I will check that.