sashabaranov / go-openai

OpenAI ChatGPT, GPT-3, GPT-4, DALL·E, Whisper API wrapper for Go
Apache License 2.0
8.59k stars 1.29k forks source link

Add gpt-4o model #743

Open 4rc0s opened 1 month ago

4rc0s commented 1 month ago

gpt-4o now available and would be great to use. https://platform.openai.com/docs/models/gpt-4o

JanRuettinger commented 1 month ago

Can we tag the new commit that added the model?

jackmcguire1 commented 1 month ago

https://github.com/sashabaranov/go-openai/blob/master/completion.go#L25

https://github.com/sashabaranov/go-openai/commit/3b25e09da90715681fe4049955d7c7ce645e218c

vbrunko-voc commented 1 month ago

Do we need to perform migration too?

https://platform.openai.com/docs/assistants/migration

xiaocode337317439 commented 1 month ago
payload = {
  "model": "gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "What’s in this image?"
        },
        {
          "type": "image_url",
          "image_url": {
            "url": f"data:image/jpeg;base64,{base64_image}"
          }
        }
      ]
    }
  ],
  "max_tokens": 300
}

response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)

print(response.json())
RayendraSabandar commented 1 month ago

Do we need to perform migration too?

https://platform.openai.com/docs/assistants/migration

has this migration implemented in the latest version?

I'm trying to use CreateThreadAndRun this function but the ThreadMessage struct has not been updated

type ThreadMessage struct {
    Role     ThreadMessageRole `json:"role"`
    Content  string            `json:"content"`
    FileIDs  []string          `json:"file_ids,omitempty"`
    Metadata map[string]any    `json:"metadata,omitempty"`
}

I think there should be Attachments field, no?

image image
dezchai commented 2 weeks ago

Wasted an hour or two debugging before I realized the new attachments field still isn't supported yet. I'll see if I can create a PR otherwise I hope someone can get to it soon. Right now it's not possible at all to make a request with files with GPT-4o.

fernandops26 commented 1 week ago

Any update here?

dezchai commented 1 week ago

Any update here?

@735