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

Enhance inference API to support OpenAI style #52

Closed
SeanHH86 opened this issue Mar 27, 2024 · 3 comments
Closed

Enhance inference API to support OpenAI style #52

SeanHH86 opened this issue Mar 27, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@SeanHH86
Copy link
Collaborator

Enhance inference API to support OpenAI style

@SeanHH86 SeanHH86 self-assigned this Mar 27, 2024
@SeanHH86
Copy link
Collaborator Author

SeanHH86 commented Apr 16, 2024

OpenAI API : https://platform.openai.com/docs/api-reference/introduction

  • Organizations and projects (optional)
curl https://api.openai.com/v1/models  -H "Authorization: Bearer $OPENAI_API_KEY"   -H "OpenAI-Organization: YOUR_ORG_ID"  -H "OpenAI-Project: $PROJECT_ID"
curl https://api.openai.com/v1/models  -H "Authorization: Bearer $OPENAI_API_KEY"

Response json data:
{
  "data": [
    {
      "id": "model-id-0",
      "object": "model",
      "owned_by": "organization-owner",
      "permission": [...]
    },
    {
      "id": "model-id-1",
      "object": "model",
      "owned_by": "organization-owner",
      "permission": [...]
    },
    {
      "id": "model-id-2",
      "object": "model",
      "owned_by": "openai",
      "permission": [...]
    },
  ],
  "object": "list"
}
curl https://api.openai.com/v1/chat/completions  -H "Content-Type: application/json" -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
     "model": "gpt-3.5-turbo",
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "temperature": 0.7
   }'

Response json data:
{
   "id":"chatcmpl-abc123",
   "object":"chat.completion",
   "created":1677858242,
   "model":"gpt-3.5-turbo-0301",
   "usage":{
      "prompt_tokens":13,
      "completion_tokens":7,
      "total_tokens":20
   },
   "choices":[
      {
         "message":{
            "role":"assistant",
            "content":"\n\nThis is a test!"
         },
         "finish_reason":"stop",
         "index":0
      }
   ]
}
curl https://api.openai.com/v1/chat/completions -H "Content-Type: application/json"  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-3.5-turbo",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hello!"
      }
    ],
    "stream": true
  }'

Response json data:
{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0125", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"role":"assistant","content":""},"logprobs":null,"finish_reason":null}]}

{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0125", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{"content":"Hello"},"logprobs":null,"finish_reason":null}]}

....

{"id":"chatcmpl-123","object":"chat.completion.chunk","created":1694268190,"model":"gpt-3.5-turbo-0125", "system_fingerprint": "fp_44709d6fcb", "choices":[{"index":0,"delta":{},"logprobs":null,"finish_reason":"stop"}]}

@SeanHH86 SeanHH86 added the enhancement New feature or request label Apr 16, 2024
@SeanHH86
Copy link
Collaborator Author

Sould be work when set OpenSDK endpoint.

@SeanHH86
Copy link
Collaborator Author

SeanHH86 commented May 7, 2024

done.

@SeanHH86 SeanHH86 closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant