Spaces:
Sleeping
Sleeping
Enoch
commited on
Commit
·
8dfaf01
1
Parent(s):
8de33e5
更新了应用代码,使用哦
Browse files
app.py
CHANGED
@@ -25,9 +25,9 @@ def call_openai_api(prompt, temperature=1):
|
|
25 |
"content": "你是一个专业的专利代理人,正在完成一份专利文档的撰写。\n\n" + prompt,
|
26 |
},
|
27 |
],
|
28 |
-
model="o1-
|
29 |
temperature=temperature,
|
30 |
-
max_tokens=
|
31 |
n=1
|
32 |
)
|
33 |
return chat_completion.choices[0].message.content.strip()
|
@@ -172,7 +172,7 @@ def generate_patent_document(
|
|
172 |
status = "正在生成背景技术部分..."
|
173 |
bg_prompt = BACKGROUND_PROMPT.format(user_input=bg_input)
|
174 |
background_content = call_openai_api(bg_prompt)
|
175 |
-
|
176 |
yield status, final_document
|
177 |
# progress(0.15, desc="已完成背景技术部分。")
|
178 |
|
@@ -184,7 +184,7 @@ def generate_patent_document(
|
|
184 |
user_input=shortcoming_input
|
185 |
)
|
186 |
shortcoming_content = call_openai_api(short_prompt)
|
187 |
-
|
188 |
yield status, final_document
|
189 |
# progress(0.3, desc="已完成现有技术缺点部分。")
|
190 |
|
@@ -197,7 +197,7 @@ def generate_patent_document(
|
|
197 |
user_input=problem_input
|
198 |
)
|
199 |
problem_content = call_openai_api(problem_prompt_full)
|
200 |
-
|
201 |
yield status, final_document
|
202 |
# progress(0.45, desc="已完成技术问题部分。")
|
203 |
|
@@ -211,7 +211,7 @@ def generate_patent_document(
|
|
211 |
user_input=solution_input
|
212 |
)
|
213 |
solution_content = call_openai_api(solution_prompt_full)
|
214 |
-
|
215 |
yield status, final_document
|
216 |
# progress(0.6, desc="已完成技术方案部分。")
|
217 |
|
@@ -223,7 +223,7 @@ def generate_patent_document(
|
|
223 |
user_input=keypoint_input
|
224 |
)
|
225 |
keypoint_content = call_openai_api(keypoint_prompt_full)
|
226 |
-
|
227 |
yield status, final_document
|
228 |
# progress(0.75, desc="已完成关键点部分。")
|
229 |
|
@@ -237,7 +237,7 @@ def generate_patent_document(
|
|
237 |
user_input=advantage_input
|
238 |
)
|
239 |
advantage_content = call_openai_api(advantage_prompt_full)
|
240 |
-
|
241 |
yield status, final_document
|
242 |
# progress(0.9, desc="已完成优点部分。")
|
243 |
|
@@ -249,7 +249,7 @@ def generate_patent_document(
|
|
249 |
user_input=alternative_input
|
250 |
)
|
251 |
alternative_content = call_openai_api(alternative_prompt_full)
|
252 |
-
|
253 |
yield status, final_document
|
254 |
# progress(1.0, desc="已完成替代方案部分。")
|
255 |
|
|
|
25 |
"content": "你是一个专业的专利代理人,正在完成一份专利文档的撰写。\n\n" + prompt,
|
26 |
},
|
27 |
],
|
28 |
+
model="o1-mini",
|
29 |
temperature=temperature,
|
30 |
+
max_tokens=20000,
|
31 |
n=1
|
32 |
)
|
33 |
return chat_completion.choices[0].message.content.strip()
|
|
|
172 |
status = "正在生成背景技术部分..."
|
173 |
bg_prompt = BACKGROUND_PROMPT.format(user_input=bg_input)
|
174 |
background_content = call_openai_api(bg_prompt)
|
175 |
+
final_document += f"{background_content}"
|
176 |
yield status, final_document
|
177 |
# progress(0.15, desc="已完成背景技术部分。")
|
178 |
|
|
|
184 |
user_input=shortcoming_input
|
185 |
)
|
186 |
shortcoming_content = call_openai_api(short_prompt)
|
187 |
+
final_document += f"{shortcoming_content}"
|
188 |
yield status, final_document
|
189 |
# progress(0.3, desc="已完成现有技术缺点部分。")
|
190 |
|
|
|
197 |
user_input=problem_input
|
198 |
)
|
199 |
problem_content = call_openai_api(problem_prompt_full)
|
200 |
+
final_document += f"{problem_content}"
|
201 |
yield status, final_document
|
202 |
# progress(0.45, desc="已完成技术问题部分。")
|
203 |
|
|
|
211 |
user_input=solution_input
|
212 |
)
|
213 |
solution_content = call_openai_api(solution_prompt_full)
|
214 |
+
final_document += f"{solution_content}"
|
215 |
yield status, final_document
|
216 |
# progress(0.6, desc="已完成技术方案部分。")
|
217 |
|
|
|
223 |
user_input=keypoint_input
|
224 |
)
|
225 |
keypoint_content = call_openai_api(keypoint_prompt_full)
|
226 |
+
final_document += f"{keypoint_content}"
|
227 |
yield status, final_document
|
228 |
# progress(0.75, desc="已完成关键点部分。")
|
229 |
|
|
|
237 |
user_input=advantage_input
|
238 |
)
|
239 |
advantage_content = call_openai_api(advantage_prompt_full)
|
240 |
+
final_document += f"{advantage_content}"
|
241 |
yield status, final_document
|
242 |
# progress(0.9, desc="已完成优点部分。")
|
243 |
|
|
|
249 |
user_input=alternative_input
|
250 |
)
|
251 |
alternative_content = call_openai_api(alternative_prompt_full)
|
252 |
+
final_document += f"{alternative_content}"
|
253 |
yield status, final_document
|
254 |
# progress(1.0, desc="已完成替代方案部分。")
|
255 |
|