Spaces:
Runtime error
Runtime error
Update custom.py
Browse files
custom.py
CHANGED
@@ -12,7 +12,7 @@ gpt_svg = """
|
|
12 |
"""
|
13 |
# 内容背景
|
14 |
user_background_color = ''
|
15 |
-
gpt_background_color = 'rgba(225,
|
16 |
# 模型初始设置
|
17 |
model = "gpt-3.5-turbo"
|
18 |
initial_content_history = [{"role": 'system',
|
@@ -108,7 +108,7 @@ js_code = """
|
|
108 |
textinput.focus();
|
109 |
} else {
|
110 |
tabs[0].click();
|
111 |
-
const waitMs =
|
112 |
|
113 |
function waitForFocus() {
|
114 |
if (window.parent.document.activeElement === textinput) {
|
@@ -127,14 +127,14 @@ js_code = """
|
|
127 |
event.preventDefault();
|
128 |
}
|
129 |
});
|
130 |
-
textinput.addEventListener('focusin', function(event) {
|
131 |
-
event.stopPropagation();
|
132 |
-
textarea.style.borderColor = 'rgb(255,
|
133 |
-
|
134 |
-
textinput.addEventListener('focusout', function(event) {
|
135 |
-
event.stopPropagation();
|
136 |
textarea.style.borderColor = 'white';
|
137 |
-
|
138 |
|
139 |
// Ctrl + Enter快捷方式
|
140 |
window.parent.document.addEventListener("keydown", event => {
|
@@ -174,5 +174,20 @@ js_code = """
|
|
174 |
waitForLayout();
|
175 |
});
|
176 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
</script>
|
178 |
-
"""
|
|
|
12 |
"""
|
13 |
# 内容背景
|
14 |
user_background_color = ''
|
15 |
+
gpt_background_color = 'rgba(225, 230, 235, 0.5)'
|
16 |
# 模型初始设置
|
17 |
model = "gpt-3.5-turbo"
|
18 |
initial_content_history = [{"role": 'system',
|
|
|
108 |
textinput.focus();
|
109 |
} else {
|
110 |
tabs[0].click();
|
111 |
+
const waitMs = 10;
|
112 |
|
113 |
function waitForFocus() {
|
114 |
if (window.parent.document.activeElement === textinput) {
|
|
|
127 |
event.preventDefault();
|
128 |
}
|
129 |
});
|
130 |
+
textinput.addEventListener('focusin', function (event) {
|
131 |
+
event.stopPropagation();
|
132 |
+
textarea.style.borderColor = 'rgb(255,75,75)';
|
133 |
+
});
|
134 |
+
textinput.addEventListener('focusout', function (event) {
|
135 |
+
event.stopPropagation();
|
136 |
textarea.style.borderColor = 'white';
|
137 |
+
});
|
138 |
|
139 |
// Ctrl + Enter快捷方式
|
140 |
window.parent.document.addEventListener("keydown", event => {
|
|
|
174 |
waitForLayout();
|
175 |
});
|
176 |
});
|
177 |
+
|
178 |
+
// 设置 Tab 键
|
179 |
+
textinput.addEventListener('keydown', function (event) {
|
180 |
+
if (event.keyCode === 9) {
|
181 |
+
// 阻止默认行为
|
182 |
+
event.preventDefault();
|
183 |
+
// 获取当前光标位置
|
184 |
+
const start = this.selectionStart;
|
185 |
+
const end = this.selectionEnd;
|
186 |
+
// 在光标位置插入制表符
|
187 |
+
this.value = this.value.substring(0, start) + '\t' + this.value.substring(end);
|
188 |
+
// 将光标移动到插入的制表符之后
|
189 |
+
this.selectionStart = this.selectionEnd = start + 1;
|
190 |
+
}
|
191 |
+
});
|
192 |
</script>
|
193 |
+
"""
|