Skip to content

Commit 2c3228a

Browse files
committed
add simple page for fans.
1 parent 4b8afb0 commit 2c3228a

File tree

1 file changed

+236
-78
lines changed

1 file changed

+236
-78
lines changed

chatgpt-web.html

+236-78
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,241 @@
1-
21
<!DOCTYPE html>
3-
<html lang="en">
4-
<head>
5-
<meta charset="UTF-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<title>ChatGPT-Web</title>
8-
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
9-
<script src="https://unpkg.com/[email protected]/dist/axios.min.js"></script>
10-
</head>
11-
<body>
12-
<a href="https://github.com/SmileBuild/ChatGPT-Web">Version 0.1.0</a>
13-
<div id="hello-vue" class="demo">
14-
<div>
15-
<form>
16-
<label>Key</label>
17-
<input type="text" v-model="key"/>
18-
<label>Prompt:</label>
19-
<textarea type="text" v-model="prompt" rows="20" cols="50"></textarea>
20-
<label>Temperature:</label>
21-
<input v-model="temperature" type="number" min="0" max="1" step="0.1" />
22-
<label>Top P:</label>
23-
<input v-model="top_p" type="number" min="0" max="1" step="0.1" />
24-
<label>Model:</label>
25-
<select v-model="model">
26-
<option v-for="m in models" :value="m">{{ m }}</option>
27-
</select>
28-
</form>
29-
<button @click="submitForm">Confirm</button>
30-
<p style="color:red;white-space: pre-wrap;">{{response}}</p>
31-
</div>
32-
</div>
33-
34-
<script>
35-
const HelloVueApp = {
36-
data() {
37-
return {
38-
key: '',
39-
prompt: '',
40-
temperature: 0.7,
41-
top_p: 1,
42-
max_tokens: 2048,
43-
frequency_penalty: 0,
44-
presence_penalty: 0.6,
45-
stop:["Human:","AI:"],
46-
model: 'text-davinci-003',
47-
models: ['text-davinci-003','text-davinci-002', 'text-curie-001'],
48-
response: ''
2+
<html lang="zh-cn">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>ChatGPT-Web</title>
8+
<script src="https://cdn.bootcdn.net/ajax/libs/vue/3.2.45/vue.global.js"></script>
9+
<link href="https://cdn.bootcdn.net/ajax/libs/element-plus/2.2.28/index.css" rel="stylesheet" />
10+
11+
12+
<script src="https://cdn.bootcdn.net/ajax/libs/axios/1.2.5/axios.min.js"></script>
13+
<script src="https://cdn.bootcdn.net/ajax/libs/element-plus/2.2.28/index.full.js"></script>
14+
15+
<style >
16+
.github-corner:hover .octo-arm {
17+
animation: octocat-wave 560ms ease-in-out
4918
}
50-
},
51-
methods: {
52-
submitForm() {
53-
let data = {
54-
prompt: this.prompt,
55-
temperature: this.temperature,
56-
top_p: this.top_p,
57-
model: this.model,
58-
max_tokens: this.max_tokens,
59-
frequency_penalty: this.frequency_penalty,
60-
presence_penalty: this.presence_penalty,
61-
stop:this.stop
19+
20+
@keyframes octocat-wave {
21+
22+
0%,
23+
100% {
24+
transform: rotate(0)
6225
}
63-
axios.post('https://api.openai.com/v1/completions', data, {
64-
headers: {
65-
'Content-Type': 'application/json',
66-
'Authorization': `Bearer `+ this.key,
67-
}
68-
})
69-
.then(response => {
70-
this.response = response.data.choices[0].text;
71-
console.log(this.response)
72-
})
73-
.catch(error => {
74-
console.log(error);
75-
});
26+
27+
20%,
28+
60% {
29+
transform: rotate(-25deg)
30+
}
31+
32+
40%,
33+
80% {
34+
transform: rotate(10deg)
35+
}
36+
}
37+
38+
@media (max-width:500px) {
39+
.github-corner:hover .octo-arm {
40+
animation: none
41+
}
42+
43+
.github-corner .octo-arm {
44+
animation: octocat-wave 560ms ease-in-out
45+
}
46+
}
47+
48+
.el-header {
49+
background: var(--el-color-black);
50+
color: aliceblue;
51+
}
52+
53+
.slider-block {
54+
display: flex;
55+
align-items: center;
56+
}
57+
58+
.slider-block .el-slider {
59+
margin-top: 0;
60+
margin-left: 12px;
61+
}
62+
63+
.slider-block .slider-laber {
64+
font-size: 14px;
65+
color: var(--el-text-color-secondary);
66+
line-height: 44px;
67+
flex: 1;
68+
overflow: hidden;
69+
text-overflow: ellipsis;
70+
white-space: nowrap;
71+
margin-bottom: 0;
7672
}
77-
}
73+
74+
.slider-block .slider-laber+.el-slider {
75+
flex: 0 0 70%;
76+
}
77+
78+
body {
79+
margin: 0 !important;
80+
height: 100%;
81+
}
82+
</style>
83+
84+
</head>
85+
86+
<body>
87+
<a href="https://github.com/SmileBuild/ChatGPT-Web" class="github-corner" aria-label="View source on GitHub"><svg
88+
width="80" height="80" viewBox="0 0 250 250"
89+
style="fill:#70B7FD; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true">
90+
<path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
91+
<path
92+
d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
93+
fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
94+
<path
95+
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
96+
fill="currentColor" class="octo-body"></path>
97+
</svg></a>
98+
<div id="hello-vue">
99+
100+
<el-container>
101+
<el-header>
102+
<h1>ChatGPT-Web v0.2.1 </h1>
103+
</el-header>
104+
<el-main>
105+
<el-row :gutter="40">
106+
<el-col :span="8" class="col-params" v-loading="loading" element-loading-text="Loading..."
107+
:element-loading-spinner="svg" element-loading-svg-view-box="-10, -10, 50, 50"
108+
element-loading-background="rgba(122, 122, 122, 0.8)">
109+
<h2>Params 参数配置</h2>
110+
111+
112+
<el-form>
113+
<h4>API Key</h4>
114+
<el-input v-model="key" placeholder="API秘钥" show-password type="password"></el-input>
115+
<h4>Prompt</h4>
116+
<el-input type="textarea" v-model="prompt" placeholder="输入内容" rows="10"></el-input>
117+
118+
<h4>Max_tokens</h4>
119+
120+
<el-input-number type="number" v-model="max_tokens"></el-input-number>
121+
<h4>Temperature</h4>
122+
<div class="slider-block">
123+
<span class="slider-laber">Temperature</span>
124+
<el-slider v-model="temperature" :step="0.1" :min="0" :max="1" show-input />
125+
</div>
126+
<h4>Top_p</h4>
127+
<div class="slider-block">
128+
<span class="slider-laber">Top_p</span>
129+
<el-slider v-model="top_p" :step="0.1" :min="0" :max="1" show-input />
130+
</div>
131+
<h4>Frequency_penalty</h4>
132+
<div class="slider-block">
133+
<span class="slider-laber">Frequency_penalty</span>
134+
<el-slider v-model="frequency_penalty" :step="0.1" :min="-2" :max="2" show-input />
135+
</div>
136+
<h4>Presence_penalty</h4>
137+
<div class="slider-block">
138+
<span class="slider-laber">Presence_penalty</span>
139+
<el-slider v-model="presence_penalty" :step="0.1" :min="-2" :max="2" show-input />
140+
</div>
141+
<h4>Model</h4>
142+
<el-select v-model="model" class="m-2" placeholder="Model" size="large">
143+
<el-option v-for="item in models" :key="item.value" :label="item.label" :value="item.value">{{
144+
item
145+
}}</el-option>
146+
</el-select>
147+
</el-form>
148+
149+
<el-button size="large" type="success" @click="submitForm">Confirm 确定</el-button>
150+
151+
<el-link href="https://beta.openai.com/docs/api-reference/completions/create#completions/create-model"
152+
target="_blank" type="danger">param info (参数说明)</el-link>
153+
154+
155+
156+
</el-col>
157+
<el-col :span="16">
158+
159+
<h2>Repsonse 结果</h2>
160+
<el-button size="large" type="warning" @click="downloadTxt" :disabled="download_disable">save 保存</el-button>
161+
162+
<p id="result" style="color:red;white-space: pre-wrap;">{{ response }}</p>
163+
</el-col>
164+
</el-row>
165+
</el-main>
166+
</el-container>
167+
</div>
168+
169+
<script>
170+
const HelloVueApp = {
171+
data() {
172+
return {
173+
loading: false,
174+
key: '',
175+
prompt: '',
176+
temperature: 0.7,
177+
top_p: 1,
178+
max_tokens: 2048,
179+
frequency_penalty: 0,
180+
presence_penalty: 0.6,
181+
stop: ["Human:", "AI:"],
182+
model: 'text-davinci-003',
183+
models: ['text-davinci-003', 'text-davinci-002', 'text-curie-001'],
184+
response: '',
185+
download_disable: true
186+
}
187+
},
188+
watch: {
189+
response(resp) {
190+
if (resp == '') {
191+
this.download_disable = true;
192+
} else {
193+
this.download_disable = false;
194+
}
195+
}
196+
},
197+
methods: {
198+
downloadTxt() {
199+
let text = 'Prompt: ' + this.prompt + '\n' + document.getElementById('result').innerText;
200+
let element = document.createElement("a");
201+
let file = new Blob([text], { type: 'text/plain' });
202+
element.href = URL.createObjectURL(file);
203+
element.download = "download.txt";
204+
element.click();
205+
},
206+
submitForm() {
207+
let data = {
208+
prompt: this.prompt,
209+
temperature: this.temperature,
210+
top_p: this.top_p,
211+
model: this.model,
212+
max_tokens: this.max_tokens,
213+
frequency_penalty: this.frequency_penalty,
214+
presence_penalty: this.presence_penalty,
215+
stop: this.stop
216+
}
217+
this.loading = true
218+
axios.post('https://api.openai.com/v1/completions', data, {
219+
headers: {
220+
'Content-Type': 'application/json',
221+
'Authorization': `Bearer ` + this.key,
222+
}
223+
})
224+
.then(response => {
225+
this.loading = false
226+
this.response = response.data.choices[0].text;
227+
console.log(this.response)
228+
})
229+
.catch(error => {
230+
this.loading = false
231+
console.log(error);
232+
});
233+
}
234+
}
78235
}
79-
80-
Vue.createApp(HelloVueApp).mount('#hello-vue')
81-
</script>
82-
</body>
83-
</html>
236+
237+
Vue.createApp(HelloVueApp).use(ElementPlus).mount('#hello-vue')
238+
</script>
239+
</body>
240+
241+
</html>

0 commit comments

Comments
 (0)