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

Add OpenAI Chat Completion endpoint #61

Merged
merged 8 commits into from
Nov 12, 2024
Merged

Add OpenAI Chat Completion endpoint #61

merged 8 commits into from
Nov 12, 2024

Conversation

dnth
Copy link
Owner

@dnth dnth commented Nov 9, 2024

To query

from openai import OpenAI

client = OpenAI(
    api_key="dummy",
    base_url="http://127.0.0.1:8000/v1"
)

response = client.chat.completions.create(
    model="vikhyatk/moondream2",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": "https://raw.githubusercontent.com/dnth/x.infer/main/assets/demo/00aa2580828a9009.jpg"
                },
                {
                    "type": "text",
                    "text": "Caption this image"
                }
            ]
        }
    ]
)

Pass in inference kwargs

response = client.chat.completions.create(
    model="vikhyatk/moondream2",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": "https://raw.githubusercontent.com/dnth/x.infer/main/assets/demo/00aa2580828a9009.jpg"
                },
                {
                    "type": "infer_kwargs",
                    "infer_kwargs": {"text": "Caption.", "max_new_tokens": 5}
                },
            ]
        }
    ]
)

@dnth dnth merged commit 61a92fa into main Nov 12, 2024
5 checks passed
@dnth dnth deleted the openai branch November 12, 2024 13:36
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.

1 participant