-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1minAIChat.html
144 lines (137 loc) · 4.8 KB
/
1minAIChat.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Interaction Tool</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #ffffff;
color: #333;
}
h1 {
text-align: center;
}
form {
width: 600px; /* Set a fixed width of 600px */
margin: 20px auto; /* Center the form */
padding: 20px;
background: white;
border: 1px solid #ccc;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
label {
display: block;
margin-bottom: 10px;
}
input, textarea {
width: 100%;
padding: 8px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 4px;
box-sizing: border-box; /* Include padding in width */
}
button {
width: 100%;
padding: 10px;
background-color: #007BFF;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #0056b3;
}
pre {
width: 95%; /* Makes the response box stretch to 100% */
margin: 20px 0; /* Adjust margin */
padding: 20px;
background: #272822;
color: #f8f8f2;
border-radius: 8px;
overflow: auto; /* Allows scrolling if content exceeds */
white-space: pre-wrap;
word-wrap: break-word;
alignment: center;
}
</style>
</head>
<body>
<h1>API Interaction Tool</h1>
<form id="apiForm">
<label>
API Key:
<input type="password" id="apiKey" placeholder="Enter your API key" required>
</label>
<label>
Type:
<input type="text" id="type" placeholder="Enter type (e.g., CHAT_WITH_AI)" required>
</label>
<label>
Model:
<input type="text" id="model" placeholder="Enter model (e.g., gpt-4o-mini)" required>
</label>
<label>
Prompt:
<textarea id="prompt" placeholder="Enter a prompt" rows="3" required></textarea>
</label>
<button type="submit">Submit</button>
</form>
<pre id="response">API response will appear here...</pre>
<script>
// Function to auto-expand the textarea
const textarea = document.getElementById('prompt');
textarea.addEventListener('input', () => {
textarea.style.height = 'auto'; // Reset the height
textarea.style.height = `${textarea.scrollHeight}px`; // Set the height to the scroll height
});
document.getElementById('apiForm').addEventListener('submit', async (e) => {
e.preventDefault();
const apiKey = document.getElementById('apiKey').value;
const type = document.getElementById('type').value;
const model = document.getElementById('model').value;
const prompt = document.getElementById('prompt').value;
const responseElement = document.getElementById('response');
responseElement.textContent = 'Loading...';
try {
const response = await fetch('https://api.1min.ai/api/features?isStreaming=true', {
method: 'POST',
headers: {
'API-KEY': apiKey,
'Content-Type': 'application/json',
},
body: JSON.stringify({
type: type,
model: model,
promptObject: {
prompt: prompt,
isMixed: false,
imageList: [],
webSearch: false,
numOfSite: 0,
maxWord: 0
}
}),
});
console.log('Status Code:', response.status);
const textData = await response.text();
console.log('Raw Response:', textData);
if (response.ok) {
responseElement.textContent = textData;
} else {
responseElement.textContent = `Error: ${response.status} ${response.statusText}. Raw response: ${textData}`;
}
} catch (error) {
responseElement.textContent = 'Error: ' + error.message;
}
});
</script>
</body>
</html>