mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-16 05:19:40 +02:00
- Restructure chat as apps/mobile, apps/web, apps/landing, backend - Add NestJS backend for secure Azure OpenAI API calls - Remove exposed API key from mobile app (security fix) - Add shared chat-types package - Create SvelteKit web app scaffold - Create Astro landing page scaffold - Update pnpm workspace configuration - Add project-level CLAUDE.md documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
50 lines
No EOL
1.3 KiB
JavaScript
50 lines
No EOL
1.3 KiB
JavaScript
// Simple Azure OpenAI API Test
|
|
const fetch = require('node-fetch');
|
|
|
|
async function testAzureOpenAI() {
|
|
const apiKey = '3082103c9b0d4270a795686ccaa89921';
|
|
const endpoint = 'https://memoroseopenai.openai.azure.com';
|
|
const deployment = 'gpt-o3-mini-se';
|
|
const apiVersion = '2024-12-01-preview';
|
|
|
|
const url = `${endpoint}/openai/deployments/${deployment}/chat/completions?api-version=${apiVersion}`;
|
|
|
|
const messages = [
|
|
{ role: "system", content: "You are a helpful assistant." },
|
|
{ role: "user", content: "Hello, who are you?" }
|
|
];
|
|
|
|
try {
|
|
console.log("Sending request to:", url);
|
|
|
|
const response = await fetch(url, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'api-key': apiKey
|
|
},
|
|
body: JSON.stringify({
|
|
messages: messages,
|
|
max_completion_tokens: 800
|
|
})
|
|
});
|
|
|
|
const status = response.status;
|
|
console.log("Response status:", status);
|
|
|
|
const data = await response.text();
|
|
console.log("Response data:", data);
|
|
|
|
if (!response.ok) {
|
|
console.error("Error:", data);
|
|
} else {
|
|
const jsonData = JSON.parse(data);
|
|
console.log("Content:", jsonData.choices[0].message.content);
|
|
}
|
|
} catch (error) {
|
|
console.error("Fetch error:", error);
|
|
}
|
|
}
|
|
|
|
// Run the test
|
|
testAzureOpenAI().catch(console.error); |