Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embeddings compatibility for OpenAI [examples/server] #5190

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

wujjpp
Copy link
Contributor

@wujjpp wujjpp commented Jan 29, 2024

Add router for serve /v1/embeddings

  1. input as string
curl http://127.0.0.1:8080/v1/embeddings \
    -H 'Content-Type: application/json' \
    -d '{
        "input": "hello",
        "model":"GPT-4",
        "encoding_format": "float"
    }'

response

{
    "data": [
        {
            "embedding": [
                -3.697190046310425,
                ...
                -4.443967342376709
            ],
            "index": 0,
            "object": "embedding"
        }
    ],
    "model": "GPT-4",
    "object": "list",
    "usage": {
        "prompt_tokens": 0,
        "total_tokens": 0
    }
}
  1. input as string array
curl http://127.0.0.1:8080/v1/embeddings \
--header 'Content-Type: application/json' \
--data '{
        "input": ["hello","world"],
        "model":"GPT-4",
        "encoding_format": "float"
}'

response

{
    "data": [
        {
            "embedding": [
                -3.697190046310425,
                ...
                -4.443967342376709
            ],
            "index": 0,
            "object": "embedding"
        },
        {
            "embedding": [
                -0.35142484307289124,
                ...
                -4.626900672912598
            ],
            "index": 1,
            "object": "embedding"
        }
    ],
    "model": "GPT-4",
    "object": "list",
    "usage": {
        "prompt_tokens": 0,
        "total_tokens": 0
    }
}

@wujjpp wujjpp changed the title embedding compatibility for OpenAI embeddings compatibility for OpenAI [examples/server] Jan 29, 2024
@ggerganov ggerganov merged commit c82d18e into ggerganov:master Jan 29, 2024
49 of 50 checks passed
@wujjpp wujjpp deleted the openai-embedding-compatibility branch January 30, 2024 04:43
jordankanter pushed a commit to jordankanter/llama.cpp that referenced this pull request Feb 3, 2024
hodlen pushed a commit to hodlen/llama.cpp that referenced this pull request Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants