Comments (10)
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.
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.
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.
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.
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.
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.
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.
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.
+1
from chatgpt-web.
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)
- feature request: be able to use fine tuned models in the chat settings
- QoL Chat Feature Requests HOT 1
- How can I enable code-interpreter?
- Issue with chrome browser HOT 1
- Feature Request: Temporary Prompts for Context-Independent Queries
- Why token counts & costs are 40x? HOT 3
- How often do backups save? HOT 1
- Access to GPT4 0125 preview? HOT 1
- Enhancement: Change favicon HOT 4
- Enter button automatically trigger confirmation of the input text. HOT 1
- Is it possible to start a new chat directly from a URL? HOT 2
- It stucks while responding HOT 1
- [Feature Request] Auto-type as you dictate (speech to text)
- Error: TypeError: Failed to fetch when attempting to generate images with DallE-3
- my local history has gone suddenly, is there any way to get it back, and can I prevent this from happening again? HOT 1
- BUG caused by multiple people using the local area network HOT 1
- Plans on supporting Claude? HOT 4
- Please add support for https HOT 2
- Why can't save API key? HOT 2
- Add Support for gpt-4-turbo-2024-04-09 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chatgpt-web.