mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-22 00:46:42 +02:00
style: auto-format codebase with Prettier
Applied formatting to 1487+ files using pnpm format:write - TypeScript/JavaScript files - Svelte components - Astro pages - JSON configs - Markdown docs 13 files still need manual review (Astro JSX comments)
This commit is contained in:
parent
0241f5554c
commit
d36b321d9d
3952 changed files with 661498 additions and 739751 deletions
|
|
@ -2,79 +2,92 @@
|
|||
const fetch = require('node-fetch');
|
||||
|
||||
async function testAzureOpenAI() {
|
||||
const config = {
|
||||
endpoint: 'https://memoroseopenai.openai.azure.com',
|
||||
deployment: 'gpt-o3-mini-se',
|
||||
apiVersion: '2024-12-01-preview',
|
||||
apiKey: '3082103c9b0d4270a795686ccaa89921',
|
||||
};
|
||||
const config = {
|
||||
endpoint: 'https://memoroseopenai.openai.azure.com',
|
||||
deployment: 'gpt-o3-mini-se',
|
||||
apiVersion: '2024-12-01-preview',
|
||||
apiKey: '3082103c9b0d4270a795686ccaa89921',
|
||||
};
|
||||
|
||||
const url = `${config.endpoint}/openai/deployments/${config.deployment}/chat/completions?api-version=${config.apiVersion}`;
|
||||
|
||||
console.log('Sende Anfrage an:', url);
|
||||
console.log('API-Key (gekürzt):', config.apiKey.substring(0, 5) + '...' + config.apiKey.substring(config.apiKey.length - 5));
|
||||
|
||||
const requestBody = {
|
||||
messages: [
|
||||
{ role: 'system', content: 'Du bist ein hilfreicher Assistent.' },
|
||||
{ role: 'user', content: 'Hallo, wie geht es dir?' }
|
||||
],
|
||||
max_completion_tokens: 800,
|
||||
};
|
||||
|
||||
console.log('Request Body:', JSON.stringify(requestBody, null, 2));
|
||||
|
||||
try {
|
||||
console.log('Sende Anfrage...');
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'api-key': config.apiKey,
|
||||
},
|
||||
body: JSON.stringify(requestBody),
|
||||
});
|
||||
const url = `${config.endpoint}/openai/deployments/${config.deployment}/chat/completions?api-version=${config.apiVersion}`;
|
||||
|
||||
console.log('Antwort-Status:', response.status, response.statusText);
|
||||
console.log('Antwort-Headers:', JSON.stringify(Object.fromEntries([...response.headers.entries()]), null, 2));
|
||||
|
||||
const responseText = await response.text();
|
||||
console.log('Antwort-Text-Länge:', responseText.length);
|
||||
console.log('Antwort-Text (gekürzt):', responseText.length > 1000 ?
|
||||
responseText.substring(0, 500) + '\n...\n' + responseText.substring(responseText.length - 500) :
|
||||
responseText);
|
||||
|
||||
try {
|
||||
const data = JSON.parse(responseText);
|
||||
console.log('Geparste Antwort:', JSON.stringify(data, null, 2));
|
||||
|
||||
if (data.choices && data.choices.length > 0) {
|
||||
const message = data.choices[0].message;
|
||||
if (message && message.content) {
|
||||
console.log('Antwort des Assistenten:', message.content);
|
||||
} else {
|
||||
console.error('Unerwartetes Antwortformat:', data.choices[0]);
|
||||
}
|
||||
} else {
|
||||
console.error('Keine choices in der Antwort gefunden');
|
||||
}
|
||||
} catch (parseError) {
|
||||
console.error('Fehler beim Parsen der Antwort:', parseError);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Fehler bei der API-Anfrage:', error);
|
||||
if (error.response) {
|
||||
console.error('Fehler-Response:', await error.response.text());
|
||||
}
|
||||
console.error('Stack:', error.stack);
|
||||
}
|
||||
console.log('Sende Anfrage an:', url);
|
||||
console.log(
|
||||
'API-Key (gekürzt):',
|
||||
config.apiKey.substring(0, 5) + '...' + config.apiKey.substring(config.apiKey.length - 5)
|
||||
);
|
||||
|
||||
const requestBody = {
|
||||
messages: [
|
||||
{ role: 'system', content: 'Du bist ein hilfreicher Assistent.' },
|
||||
{ role: 'user', content: 'Hallo, wie geht es dir?' },
|
||||
],
|
||||
max_completion_tokens: 800,
|
||||
};
|
||||
|
||||
console.log('Request Body:', JSON.stringify(requestBody, null, 2));
|
||||
|
||||
try {
|
||||
console.log('Sende Anfrage...');
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'api-key': config.apiKey,
|
||||
},
|
||||
body: JSON.stringify(requestBody),
|
||||
});
|
||||
|
||||
console.log('Antwort-Status:', response.status, response.statusText);
|
||||
console.log(
|
||||
'Antwort-Headers:',
|
||||
JSON.stringify(Object.fromEntries([...response.headers.entries()]), null, 2)
|
||||
);
|
||||
|
||||
const responseText = await response.text();
|
||||
console.log('Antwort-Text-Länge:', responseText.length);
|
||||
console.log(
|
||||
'Antwort-Text (gekürzt):',
|
||||
responseText.length > 1000
|
||||
? responseText.substring(0, 500) +
|
||||
'\n...\n' +
|
||||
responseText.substring(responseText.length - 500)
|
||||
: responseText
|
||||
);
|
||||
|
||||
try {
|
||||
const data = JSON.parse(responseText);
|
||||
console.log('Geparste Antwort:', JSON.stringify(data, null, 2));
|
||||
|
||||
if (data.choices && data.choices.length > 0) {
|
||||
const message = data.choices[0].message;
|
||||
if (message && message.content) {
|
||||
console.log('Antwort des Assistenten:', message.content);
|
||||
} else {
|
||||
console.error('Unerwartetes Antwortformat:', data.choices[0]);
|
||||
}
|
||||
} else {
|
||||
console.error('Keine choices in der Antwort gefunden');
|
||||
}
|
||||
} catch (parseError) {
|
||||
console.error('Fehler beim Parsen der Antwort:', parseError);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Fehler bei der API-Anfrage:', error);
|
||||
if (error.response) {
|
||||
console.error('Fehler-Response:', await error.response.text());
|
||||
}
|
||||
console.error('Stack:', error.stack);
|
||||
}
|
||||
}
|
||||
|
||||
// Führe den Test aus
|
||||
testAzureOpenAI().then(() => {
|
||||
console.log('Test abgeschlossen');
|
||||
}).catch(err => {
|
||||
console.error('Unbehandelter Fehler:', err);
|
||||
});
|
||||
testAzureOpenAI()
|
||||
.then(() => {
|
||||
console.log('Test abgeschlossen');
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Unbehandelter Fehler:', err);
|
||||
});
|
||||
|
||||
testAzureOpenAI();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue