Giter Club home page Giter Club logo

Comments (10)

Niek avatar Niek commented on August 19, 2024 2

Should be rather trivial, looking at https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#chat-completions

It's unfortunate they are so super-strict with the API access. I applied a few times but haven't heard anything since then.

from chatgpt-web.

Niek avatar Niek commented on August 19, 2024 1

OK, that's not too bad. If someone can share an Azure OpenAI key with me privately (see contact info in my profile), I'll try to implement support for both APIs.

from chatgpt-web.

kiwizznz avatar kiwizznz commented on August 19, 2024

Same here! I've seen other attempts and the suggestion was a translator service of sorts (so apps like this don't need to take into consideration the different formatting for Azure OpenAI) but I'd rather have native support!

from chatgpt-web.

kiwizznz avatar kiwizznz commented on August 19, 2024

Should be rather trivial, looking at https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#chat-completions

It's unfortunate they are so super-strict with the API access. I applied a few times but haven't heard anything since then.

Happy to help with testing Niek. I've got access. There's another discussion which might help over here: mckaywrigley/chatbot-ui#243

from chatgpt-web.

othmanelhoufi avatar othmanelhoufi commented on August 19, 2024

I am trying to make some changes in order to connect with Microsoft Azure OpenAI, I can't find the 'new' instance of OpenAI API. Any help?

from chatgpt-web.

othmanelhoufi avatar othmanelhoufi commented on August 19, 2024

Finally I managed to edit the code so that it works with Azure OpenAI API, and it's pretty easy, you should edit these two functions in "Chat.svelte":

response = await (
        await fetch(apiBase + `deployments/${modelSetting.default}/chat/completions?api-version=2023-03-15-preview`, {
          method: 'POST',
          headers: {
            "api-key": `${$apiKeyStorage}`,
            "Content-Type": "application/json",
          },
          body: JSON.stringify(request)
        })
      ).json()
    } catch (e) {
      response = { error: { message: e.message } } as Response
    }

    // Hide updating bar
    updating = false

    return response
  }
const showSettings = async () => {
    settings.classList.add('is-active')

    // Load available models from OpenAI
    const allModels = (await (
      await fetch(apiBase + 'models?api-version=2023-03-15-preview', {
        method: 'GET',
        headers: {
          'api-key': `${$apiKeyStorage}`,
          'Content-Type': 'application/json'
        }
      })
    ).json()) as ResponseModels
    const filteredModels = supportedModels.filter((model) => allModels.data.find((m) => m.id === model))

    // Update the models in the settings
    modelSetting.options = filteredModels
    settingsMap = settingsMap
  }

Basically is only the link and the header format that changes, then edit the link in apiBase:

  const apiBase = 'https://[YOUR_ENDPOINT].openai.azure.com/openai/'

Finally, wherever there is "gpt-3.5-turbo" change it to "gpt-35-turbo" because that's the deployement name in Azure OpenAI.

from chatgpt-web.

KrisQuack avatar KrisQuack commented on August 19, 2024

OK, that's not too bad. If someone can share an Azure OpenAI key with me privately (see contact info in my profile), I'll try to implement support for both APIs.

Hey just seeing this project and it looks great, Did you have any luck/need any help with this? I have full access on Azure so can provide a key for testing if needed

from chatgpt-web.

melonique avatar melonique commented on August 19, 2024

I did connect your app to our Azure setup.
I dont have time to make it an option and a PR and everything, but here is the code that works great for us:

<script context="module" lang="ts">
  import { type Request, type Response } from './Types.svelte'

  const OPENAI_API_BASE = import.meta.env.VITE_OPENAI_BASE_URL
  const OPENAI_API_KEY = import.meta.env.VITE_OPENAI_API_KEY

  export const sendAPIRequest = async (request: Request): Promise<Response> => {
    let response: Response
    try {
      response = await (
        await fetch(
          OPENAI_API_BASE +
            '/openai/deployments/' +
            request.model +
            '/chat/completions?api-version=2023-03-15-preview',
          {
            method: 'POST',
            headers: {
              Authorization: `Bearer ${OPENAI_API_KEY}`,
              'Content-Type': 'application/json',
              'api-key': `${OPENAI_API_KEY}`
            },
            body: JSON.stringify(request)
          }
        )
      ).json()
    } catch (e) {
      response = { error: { message: e.message } } as Response
    }
    return response
  }
</script>

from chatgpt-web.

nodomain avatar nodomain commented on August 19, 2024

+1

from chatgpt-web.

810220822 avatar 810220822 commented on August 19, 2024

Finally I managed to edit the code so that it works with Azure OpenAI API, and it's pretty easy, you should edit these two functions in "Chat.svelte":

response = await (
        await fetch(apiBase + `deployments/${modelSetting.default}/chat/completions?api-version=2023-03-15-preview`, {
          method: 'POST',
          headers: {
            "api-key": `${$apiKeyStorage}`,
            "Content-Type": "application/json",
          },
          body: JSON.stringify(request)
        })
      ).json()
    } catch (e) {
      response = { error: { message: e.message } } as Response
    }

    // Hide updating bar
    updating = false

    return response
  }
const showSettings = async () => {
    settings.classList.add('is-active')

    // Load available models from OpenAI
    const allModels = (await (
      await fetch(apiBase + 'models?api-version=2023-03-15-preview', {
        method: 'GET',
        headers: {
          'api-key': `${$apiKeyStorage}`,
          'Content-Type': 'application/json'
        }
      })
    ).json()) as ResponseModels
    const filteredModels = supportedModels.filter((model) => allModels.data.find((m) => m.id === model))

    // Update the models in the settings
    modelSetting.options = filteredModels
    settingsMap = settingsMap
  }

Basically is only the link and the header format that changes, then edit the link in apiBase:

  const apiBase = 'https://[YOUR_ENDPOINT].openai.azure.com/openai/'

Finally, wherever there is "gpt-3.5-turbo" change it to "gpt-35-turbo" because that's the deployement name in Azure OpenAI.

code changed?
can't find the tow functions

from chatgpt-web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.