Closed lonngxiang closed 12 months ago
What model
are you passing? That is likely the cause of the error you're seeing.
What
model
are you passing? That is likely the cause of the error you're seeing.
use vllm:
import openai
import json
# Modify OpenAI's API key and API base to use vLLM's API server.
openai.api_key = "EMPTY"
model = "/mnt/data/loong/AquilaChat2-7B"
openai.api_base = "http://localhost:10860/v1"
def test_embedding():
embedding = openai.Embedding.create(model =model,input="hello")
print(embedding)
print(embedding["data"][0]["embedding"].shape)
print(embedding["data"][0]["embedding"])
This is likely fixed in v1; please give it a try and open a new issue if the problem persists.
Describe the bug
To Reproduce
Traceback (most recent call last): File "C:\Users\loong.conda\envs\nlp\lib\site-packages\openai\api_requestor.py", line 403, in handle_error_response error_data = resp["error"] KeyError: 'error'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "D:\llm\NLP\aquila_openai_api_vllm.py", line 54, in
test_embedding()
File "D:\llm\NLP\aquila_openai_api_vllm.py", line 25, in test_embedding
embedding = openai.Embedding.create(model =model,input="你好")
File "C:\Users\loong.conda\envs\nlp\lib\site-packages\openai\api_resources\embedding.py", line 33, in create
response = super().create(*args, **kwargs)
File "C:\Users\loong.conda\envs\nlp\lib\site-packages\openai\api_resources\abstract\engine_apiresource.py", line 153, in create
response, , api_key = requestor.request(
File "C:\Users\loong.conda\envs\nlp\lib\site-packages\openai\api_requestor.py", line 298, in request
resp, got_stream = self._interpret_response(result, stream)
File "C:\Users\loong.conda\envs\nlp\lib\site-packages\openai\api_requestor.py", line 707, in _interpret_response
self._interpret_response_line(
File "C:\Users\loong.conda\envs\nlp\lib\site-packages\openai\api_requestor.py", line 772, in _interpret_response_line
raise self.handle_error_response(
File "C:\Users\loong.conda\envs\nlp\lib\site-packages\openai\api_requestor.py", line 405, in handle_error_response
raise error.APIError(
openai.error.APIError: Invalid response object from API: '{"detail":"Not Found"}' (HTTP response code was 404)
Code snippets
No response
OS
centos
Python version
3.10
Library version
0.28.0