decula commited on
Commit ·
4925137
1
Parent(s): 6e2a9d9
max token 20000
Browse files
7b.py
CHANGED
|
@@ -156,7 +156,7 @@ with gr.Blocks(title=title) as demo:
|
|
| 156 |
with gr.Row():
|
| 157 |
with gr.Column():
|
| 158 |
prompt = gr.Textbox(lines=2, label="Prompt", value="")
|
| 159 |
-
token_count = gr.Slider(0,
|
| 160 |
temperature = gr.Slider(0.2, 2.0, label="Temperature", step=0.1, value=1.0)
|
| 161 |
top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.3)
|
| 162 |
presence_penalty = gr.Slider(0.0, 1.0, label="Presence Penalty", step=0.1, value=1)
|
|
|
|
| 156 |
with gr.Row():
|
| 157 |
with gr.Column():
|
| 158 |
prompt = gr.Textbox(lines=2, label="Prompt", value="")
|
| 159 |
+
token_count = gr.Slider(0, 20000, label="Max Tokens", step=200, value=100)
|
| 160 |
temperature = gr.Slider(0.2, 2.0, label="Temperature", step=0.1, value=1.0)
|
| 161 |
top_p = gr.Slider(0.0, 1.0, label="Top P", step=0.05, value=0.3)
|
| 162 |
presence_penalty = gr.Slider(0.0, 1.0, label="Presence Penalty", step=0.1, value=1)
|
ms.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import pymysql
|
| 3 |
+
db_config = {
|
| 4 |
+
'host': '192.168.100.188',
|
| 5 |
+
'user': 'root',
|
| 6 |
+
'password': 'Csiq@2019',
|
| 7 |
+
'db': 'porn',
|
| 8 |
+
'charset': 'utf8mb4',
|
| 9 |
+
'cursorclass': pymysql.cursors.DictCursor
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
# 连接到数据库
|
| 14 |
+
directory_path = 'C:\\games\\H\\h-corpus'
|
| 15 |
+
|
| 16 |
+
# 遍历指定目录下的所有.txt文件
|
| 17 |
+
for filename in os.listdir(directory_path):
|
| 18 |
+
if filename.endswith('.txt'):
|
| 19 |
+
file_path = os.path.join(directory_path, filename)
|
| 20 |
+
try:
|
| 21 |
+
# 打开数据库连接
|
| 22 |
+
connection = pymysql.connect(max_allowed_packet=1024 * 1024 * 64, **db_config)
|
| 23 |
+
with connection.cursor() as cursor:
|
| 24 |
+
with open(file_path, 'r', encoding='utf-8') as file:
|
| 25 |
+
title = file.readline().strip() # 读取标题
|
| 26 |
+
content = file.read().strip() # 读取内容
|
| 27 |
+
|
| 28 |
+
# 插入数据到数据库
|
| 29 |
+
sql = "INSERT INTO hnote (title, content) VALUES (%s, %s)"
|
| 30 |
+
cursor.execute(sql, (title, content))
|
| 31 |
+
|
| 32 |
+
# 提交事务
|
| 33 |
+
connection.commit()
|
| 34 |
+
except Exception as e:
|
| 35 |
+
print(f"An error occurred: {e}")
|
| 36 |
+
finally:
|
| 37 |
+
# 关闭数据库连接
|
| 38 |
+
if connection:
|
| 39 |
+
connection.close()
|
| 40 |
+
|
| 41 |
+
print("All .txt files have been processed and inserted into the database.")
|