|
1 | | -const TUNNEL_URL = "https://clients-update-scientists-mouth.trycloudflare.com"; // Zkontroluj, zda je tato URL stále aktuální! |
| 1 | +const TUNNEL_URL = "https://clients-update-scientists-mouth.trycloudflare.com"; |
2 | 2 |
|
3 | 3 | export const sendMessageToGemini = async (prompt: string) => { |
4 | 4 | try { |
5 | 5 | const response = await fetch(`${TUNNEL_URL}/api/generate`, { |
6 | 6 | method: 'POST', |
7 | | - headers: { |
8 | | - 'Content-Type': 'application/json', |
9 | | - }, |
| 7 | + headers: { 'Content-Type': 'application/json' }, |
10 | 8 | body: JSON.stringify({ |
11 | 9 | model: 'gemma3:4b', |
12 | 10 | prompt: prompt, |
13 | 11 | stream: false |
14 | 12 | }) |
15 | 13 | }); |
16 | 14 |
|
17 | | - if (!response.ok) { |
18 | | - const errorText = await response.text(); |
19 | | - console.error('Chyba z Raspberry:', errorText); |
20 | | - throw new Error(`Raspberry Pi vrátilo chybu: ${response.status}`); |
21 | | - } |
| 15 | + if (!response.ok) throw new Error(`Raspberry Pi vrátilo chybu: ${response.status}`); |
22 | 16 |
|
23 | 17 | const data = await response.json(); |
24 | | - console.log('Data z Ollamy:', data); // Toto uvidíš v konzoli F12 |
25 | | - |
26 | | - // Ollama vrací text v poli "response" |
27 | 18 | return data.response || "AI vrátila prázdnou odpověď."; |
28 | | - |
29 | 19 | } catch (error) { |
30 | 20 | console.error('Chyba při volání AI:', error); |
31 | 21 | throw error; |
32 | 22 | } |
33 | 23 | }; |
| 24 | + |
| 25 | +// TYTO FUNKCE NESMÍ CHYBĚT, JINAK BUILD SPADNE: |
| 26 | +export const generateScriptFromMaterial = async (material: any) => { |
| 27 | + const prompt = `Vytvoř studijní scénář z tohoto materiálu: ${JSON.stringify(material)}`; |
| 28 | + return await sendMessageToGemini(prompt); |
| 29 | +}; |
| 30 | + |
| 31 | +export const generatePodcastAudio = async (text: string) => { |
| 32 | + // Zatím jen simulace, aby aplikace běžela |
| 33 | + console.log("Generuji audio pro:", text); |
| 34 | + return ""; |
| 35 | +}; |
0 commit comments