weird embeddings error
Trying
curl -X 'POST' \
'https://api-llm.147.pm/embeddings' \
-H 'accept: application/json' \
-H 'Authorization: Bearer *******' \
-H 'Content-Type: application/json' \
-d '{
"input": "Hello, world!",
"type": "query"
}'
I get
INFO: 172.18.0.2:58812 - "POST /embeddings HTTP/1.1" 500 Internal Server Error
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 408, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/usr/local/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
return await self.app(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 374, in _sentry_patched_asgi_app
return await middleware(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py", line 152, in _run_asgi3
return await self._run_app(scope, receive, send, asgi_version=3)
File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py", line 246, in _run_app
raise exc from None
File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/asgi.py", line 241, in _run_app
return await self.app(
File "/usr/local/lib/python3.10/site-packages/starlette/applications.py", line 113, in __call__
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 169, in _create_span_call
return await old_call(app, scope, new_receive, new_send, **kwargs)
File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 187, in __call__
raise exc
File "/usr/local/lib/python3.10/site-packages/starlette/middleware/errors.py", line 165, in __call__
await self.app(scope, receive, _send)
File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 169, in _create_span_call
return await old_call(app, scope, new_receive, new_send, **kwargs)
File "/usr/local/lib/python3.10/site-packages/starlette/middleware/cors.py", line 85, in __call__
await self.app(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 268, in _sentry_exceptionmiddleware_call
await old_call(self, scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/starlette.py", line 169, in _create_span_call
return await old_call(app, scope, new_receive, new_send, **kwargs)
File "/usr/local/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
raise exc
File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 715, in __call__
await self.middleware_stack(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 735, in app
await route.handle(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 76, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 62, in wrapped_app
raise exc
File "/usr/local/lib/python3.10/site-packages/starlette/_exception_handler.py", line 51, in wrapped_app
await app(scope, receive, sender)
File "/usr/local/lib/python3.10/site-packages/starlette/routing.py", line 73, in app
response = await f(request)
File "/usr/local/lib/python3.10/site-packages/sentry_sdk/integrations/fastapi.py", line 137, in _sentry_app
return await old_app(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 301, in app
raw_response = await run_endpoint_function(
File "/usr/local/lib/python3.10/site-packages/fastapi/routing.py", line 212, in run_endpoint_function
return await dependant.call(**values)
File "/app/./api/server.py", line 450, in embeddings
results = generate_embeddings(text, prompt_name=prompt_name)
File "/app/api/embeddings.py", line 62, in generate_embeddings
embeddings = model.encode(texts, prompt_name=prompt_name).tolist() # type: ignore
File "/usr/local/lib/python3.10/site-packages/sentence_transformers/SentenceTransformer.py", line 556, in encode
raise ValueError(
ValueError: Prompt name 'query' not found in the configured prompts dictionary with keys [].
while running locally and trying
curl -X 'POST' \
'http://localhost:8889/embeddings' \
-H 'accept: application/json' \
-H 'Authorization: Bearer *************' \
-H 'Content-Type: application/json' \
-d '{
"input": "Hello, world!",
"type": "query"
}'
returns
{"data":[{"embedding":[-0.005389475263655186,0.02732149325311184,…
could be a python version issue, see Dockerfile