OvidijusParsiunas / deep-chat

Fully customizable AI chatbot component for your website
https://deepchat.dev
MIT License
1.43k stars 218 forks source link

Support for OpenAI's GPT-4o #201

Closed shobees-dev closed 2 months ago

shobees-dev commented 4 months ago

We are in the process of integrating Deep Chat into our app and wish to utilize OpenAI's GPT-4o due to its new features and improvements. However, it appears that GPT-4o is not supported. This leaves us uncertain about whether we should proceed with the integration of Deep Chat.

Could the maintainers please provide insights on the current compatibility status with GPT-4o and any planned updates to include support for it? Your prompt response and continuous efforts to enhance Deep Chat are highly appreciated.

OvidijusParsiunas commented 4 months ago

Hi @shobees-dev. Deep Chat does support the new GPT-4o model for both text and image communication. All you need to do is specify the model name in the OpenAI Chat property. For example:

directConnection = {
  openAI: {
    chat: { model: 'gpt-4o' },
    key: 'your-key'
  }
}

Let me know if you experience any issues. Thanks!

OvidijusParsiunas commented 4 months ago

To note, we will be making the gpt-4o model as the default model in our future release, so you will no longer need to specify it as so:

directConnection = {
  openAI: { key: 'your-key' }
}

This should be announced in the next month.

shobees-dev commented 4 months ago

Hi @OvidijusParsiunas,

Thank you for your quick reply. We are using OpenAI's Assistants API for text, image, and file inputs. However, when we use GPT-4o with the Assistants API, it doesn't seem to work. The responseInterceptor always displays the GPT-4 model.

directConnection={{
        openAI: {
          assistant: { model: "gpt-4o", function_handler: functionHandler },
          key: OPENAI_API_TEST_KEY,
        },
      }}

image

OvidijusParsiunas commented 4 months ago

When it comes to OpenAI assistants, the model needs to be specified when an assistant is created.

You can do this in 2 ways:

  1. Use the new_assistant object and specify the model there. It is important to note that a new assistant will be created when a new conversation has started, hence a long term solution is recommended in option 2:
    directConnection = {
    openAI: {
    assistant: { new_assistant: { model: 'gpt-4o' } },
    key: 'your-key'
    }
    }
  2. Use an already existing assistant that has a gpt-4o model assigned to it. You can either create a new one in the OpenAI Playground as follows: Screenshot 2024-05-18 at 14 09 56

Or you can find the one you created in Option 1. And then specify it using the assistant_id property:

directConnection = {
  openAI: {
    assistant: { assistant_id: 'yout-assistant-id' },
    key: 'your-key'
  }
}

Let me know if this helps. Thanks!

shobees-dev commented 4 months ago

Hi @OvidijusParsiunas,

I attempted both methods you suggested, but unfortunately, I encountered the same error with each approach. I believe this is the primary issue we're facing with GPT-4o. Do you have any workarounds or solutions for this? image

OvidijusParsiunas commented 4 months ago

That is interesting, it appears that OpenAI have limited the assistants to be able to use the new model only in their version 2. I am currently working on migrating the Deep Chat OpenAI Assistant code from v1 and v2. The real differences between the versions are actually just to do with files and not the text chat itself. Therefore if you want to just use text, you can actually use a temporary workaround where you can overwrite the request header containing the version via request headers property, e.g.:

request = {
  headers: {
    'OpenAI-Beta': 'assistants=v2'
  }
}

Let me know if this works for you.

For the file integration, please bare with me as I should have the code ready in dev soon. You can also track the issue here.

Thanks!!

OvidijusParsiunas commented 2 months ago

Hi, the functionality mentioned in this issue is now available in Deep Chat version 2.0.0.