Blaizzy / fastmlx

FastMLX is a high performance production ready API to host MLX models.
Other
159 stars 12 forks source link

Using OpenAI API compliant to support vision models #30

Open madroidmaq opened 2 weeks ago

madroidmaq commented 2 weeks ago

curl

curl http://localhost:8000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer OPENAI_API_KEY" \
  -d '{
    "model": "microsoft/Phi-3.5-vision-instruct",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What’s in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": "http://images.cocodataset.org/val2017/000000039769.jpg"
            }
          }
        ]
      }
    ],
    "max_tokens": 300
  }'

response:

{
    "id": "chatcmpl-6a138c4c",
    "object": "chat.completion",
    "created": 1724780023,
    "model": "microsoft/Phi-3.5-vision-instruct",
    "choices": [{
        "index": 0,
        "message": {
            "role": "assistant",
            "content": "The image shows two cats lying on a pink couch. There are two remote controls placed on the couch next to the cats.<|end|>"
        },
        "finish_reason": "stop"
    }],
    "tool_calls": []
}
Blaizzy commented 4 days ago

Hey @madroidmaq

Sorry for the late response, I was unavaible these past couple weeks but I'm back.

Thank you very much for the PR!

Blaizzy commented 4 days ago

@madroidmaq the style checks are failling, please run:

 pre-commit run --all
Blaizzy commented 4 days ago

After that, if all tests pass we can merge :)