-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhello_gemini.html
100 lines (87 loc) · 3.46 KB
/
hello_gemini.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Google Gemini API Demo</title>
</head>
<body>
<h1>Google Gemini API Demo</h1>
<form id="apiForm">
<label for="page_title">Page Title:</label><br>
<input type="text" id="page_title" name="page_title" style="width: 500px; height: 30px;""><br>
<label for="page_url">Page URL:</label><br>
<input type="text" id="page_url" name="page_url" style="width: 500px; height: 30px;"><br>
<label for="page_content">Page Content:</label><br>
<input type="text" id="page_content" name="page_content" style="width: 500px; height: 200px;"><br>
<!-- <label for="systemPrompt">System Prompt:</label><br>
<input type="text" id="systemPrompt" name="systemPrompt"><br><br> -->
<input type="button" value="Submit" onclick="fetchGeminiOutput()">
</form>
<h2>Output:</h2>
<p id="output"></p>
<script>
async function fetchGeminiOutput() {
const page_title = document.getElementById('page_title').value;
const page_url = document.getElementById('page_url').value;
const page_content = document.getElementById('page_content').value;
// const prompt = JSON.stringify({ page_title, page_url, page_content });
// const systemPrompt = document.getElementById('systemPrompt').value;
const response = await fetch('/classify', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
page_title,
page_url,
page_content
// prompt: prompt,
// system_prompt: systemPrompt
})
});
const data = await response.json();
document.getElementById('output').innerText = JSON.stringify(data);
}
</script>
</body>
</html>
<!-- <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Google Gemini API Demo</title>
</head>
<body>
<h1>Google Gemini API Demo</h1>
<form id="apiForm">
<label for="prompt">Prompt:</label><br>
<input type="text" id="prompt" name="prompt"><br>
<label for="systemPrompt">System Prompt:</label><br>
<input type="text" id="systemPrompt" name="systemPrompt"><br><br>
<input type="button" value="Submit" onclick="fetchGeminiOutput()">
</form>
<h2>Output:</h2>
<p id="output"></p>
<script>
async function fetchGeminiOutput() {
const prompt = document.getElementById('prompt').value;
const systemPrompt = document.getElementById('systemPrompt').value;
const response = await fetch('https://api.google.com/gemini/v1/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer YOUR_API_KEY`
},
body: JSON.stringify({
prompt: prompt,
system_prompt: systemPrompt
})
});
const data = await response.json();
document.getElementById('output').innerText = data.output;
}
</script>
</body>
</html> -->