Spaces:
Runtime error
Runtime error
DSXiangLi
commited on
Commit
•
b13609f
1
Parent(s):
4c572ec
add pip
Browse files- app.py +7 -7
- self/generate.py +1 -0
app.py
CHANGED
@@ -82,7 +82,7 @@ with gr.Blocks(title="Automatic Prompt Engineer", theme=gr.themes.Glass()) as de
|
|
82 |
with gr.Row():
|
83 |
with gr.Column(scale=1):
|
84 |
score_instruction = gr.Textbox(lines=3, value="",
|
85 |
-
|
86 |
score_button = gr.Button("Evaluate")
|
87 |
with gr.Column(scale=1):
|
88 |
test_score = gr.Textbox(lines=1, value="", label="Log(p)", disabled=True)
|
@@ -102,9 +102,9 @@ with gr.Blocks(title="Automatic Prompt Engineer", theme=gr.themes.Glass()) as de
|
|
102 |
seed_file = gr.File(label='上传json文件, 格式参考./self/data/seed_task.json')
|
103 |
|
104 |
with gr.Column():
|
105 |
-
self_prompt_input = gr.Textbox(max_lines=100, lines=
|
106 |
-
|
107 |
-
|
108 |
init_self = gr.Button("初始化")
|
109 |
self_instance = gr.State()
|
110 |
|
@@ -131,7 +131,8 @@ with gr.Blocks(title="Automatic Prompt Engineer", theme=gr.themes.Glass()) as de
|
|
131 |
load_button.click(load_task, [task, file], [instance, load_flag])
|
132 |
|
133 |
# 2. 按 Configuration Sample数据 得到训练样本和验证集, 并在前端展示。支持重采样
|
134 |
-
sample_button.click(sample_data, [instance, n_train, n_few_shot, n_eval],
|
|
|
135 |
|
136 |
# 3. Estimate Cost for train + Eval
|
137 |
cost_button.click(esttimate_cost, [instance], [cost])
|
@@ -148,12 +149,11 @@ with gr.Blocks(title="Automatic Prompt Engineer", theme=gr.themes.Glass()) as de
|
|
148 |
# 7. 输入指令打分
|
149 |
score_button.click(score_single, [eval_prompt, instance, score_instruction, openai_key], [test_score])
|
150 |
|
151 |
-
|
152 |
"""
|
153 |
SELF Callback
|
154 |
"""
|
155 |
# 1. 加载种子文件
|
156 |
-
init_self.click(init_instance, inputs=[seed_file, openai_key2, n_human, n_machine, n_instruct,self_prompt_input],
|
157 |
outputs=[self_instance])
|
158 |
|
159 |
# 2. 生成
|
|
|
82 |
with gr.Row():
|
83 |
with gr.Column(scale=1):
|
84 |
score_instruction = gr.Textbox(lines=3, value="",
|
85 |
+
label="Prompt to Evaluate")
|
86 |
score_button = gr.Button("Evaluate")
|
87 |
with gr.Column(scale=1):
|
88 |
test_score = gr.Textbox(lines=1, value="", label="Log(p)", disabled=True)
|
|
|
102 |
seed_file = gr.File(label='上传json文件, 格式参考./self/data/seed_task.json')
|
103 |
|
104 |
with gr.Column():
|
105 |
+
self_prompt_input = gr.Textbox(max_lines=100, lines=15, interative=True,
|
106 |
+
placeholder=self_prompt,
|
107 |
+
value='', label="Prompt for self-instruct")
|
108 |
init_self = gr.Button("初始化")
|
109 |
self_instance = gr.State()
|
110 |
|
|
|
131 |
load_button.click(load_task, [task, file], [instance, load_flag])
|
132 |
|
133 |
# 2. 按 Configuration Sample数据 得到训练样本和验证集, 并在前端展示。支持重采样
|
134 |
+
sample_button.click(sample_data, [instance, n_train, n_few_shot, n_eval],
|
135 |
+
[train_str, eval_str, instance, sample_flag])
|
136 |
|
137 |
# 3. Estimate Cost for train + Eval
|
138 |
cost_button.click(esttimate_cost, [instance], [cost])
|
|
|
149 |
# 7. 输入指令打分
|
150 |
score_button.click(score_single, [eval_prompt, instance, score_instruction, openai_key], [test_score])
|
151 |
|
|
|
152 |
"""
|
153 |
SELF Callback
|
154 |
"""
|
155 |
# 1. 加载种子文件
|
156 |
+
init_self.click(init_instance, inputs=[seed_file, openai_key2, n_human, n_machine, n_instruct, self_prompt_input],
|
157 |
outputs=[self_instance])
|
158 |
|
159 |
# 2. 生成
|
self/generate.py
CHANGED
@@ -171,6 +171,7 @@ def init_instance(seed_file, openai_key, n_human, n_machine, n_instruct, prompt)
|
|
171 |
# 允许用户输入prompt修改前缀指令命令
|
172 |
if not prompt:
|
173 |
prompt = self_prompt
|
|
|
174 |
self_instance = SELF(seed_file.name, openai_key, n_human, n_machine, n_instruct, prompt)
|
175 |
return self_instance
|
176 |
|
|
|
171 |
# 允许用户输入prompt修改前缀指令命令
|
172 |
if not prompt:
|
173 |
prompt = self_prompt
|
174 |
+
print(openai_key)
|
175 |
self_instance = SELF(seed_file.name, openai_key, n_human, n_machine, n_instruct, prompt)
|
176 |
return self_instance
|
177 |
|