Spaces:
Runtime error
Runtime error
come
commited on
Commit
·
10363fa
1
Parent(s):
ff97dcd
Update app.py
Browse files
app.py
CHANGED
@@ -326,7 +326,7 @@ def HandleV2(params):
|
|
326 |
if Humanjudage[:2] != '合格':
|
327 |
flag = '不合格'
|
328 |
|
329 |
-
dataJson =
|
330 |
|
331 |
if len(dataJson) != 0:
|
332 |
newLine = [quesText, dataJson['Explain'], dataJson['Result'], flag, Humanjudage]
|
@@ -388,6 +388,16 @@ def JuageRewritevEffect(textA, rewriteTextB, textGPTTargetinput,gptVersion,slide
|
|
388 |
transLateJson['GPTWriteText_Cn'])
|
389 |
return ''
|
390 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
|
392 |
def HandleData():
|
393 |
book = openpyxl.load_workbook('PromptTestdataV2.xlsx')
|
@@ -420,13 +430,13 @@ def HandleData():
|
|
420 |
wb.save('testV17.xlsx')
|
421 |
|
422 |
|
423 |
-
def
|
424 |
system_msg = {
|
425 |
"role": "system",
|
426 |
"content": systemmessage
|
427 |
}
|
428 |
-
openai.api_key =
|
429 |
-
temperature = 0.4 # 温度参数
|
430 |
maxNum = 3
|
431 |
maxDistance = 4
|
432 |
minOverlap = 0.6
|
@@ -435,13 +445,14 @@ def GetChat(ques, systemmessage=''):
|
|
435 |
try:
|
436 |
completion = openai.ChatCompletion.create(
|
437 |
# model="gpt-3.5-turbo",
|
438 |
-
|
|
|
439 |
messages=[system_msg, {"role": "user", "content": ques}],
|
440 |
temperature=temperature)
|
441 |
# print(completion['choices'][0]['message']['content'])
|
442 |
print(completion['choices'][0]['message']['content'])
|
443 |
-
|
444 |
-
return
|
445 |
except Exception as e:
|
446 |
|
447 |
print(e)
|
@@ -561,8 +572,23 @@ def gradioDemo():
|
|
561 |
gptApiKey = gr.Textbox(label='GPTAPIKey', lines=2, placeholder='输入apiKey')
|
562 |
|
563 |
button2 = gr.Button('开始审核')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
564 |
|
565 |
button2.click(excelAIReviewTag, inputs=[inputs,textGPTTargetinput1,drop,slider,gptApiKey], outputs=outputs)
|
|
|
|
|
566 |
gr.Markdown("注:使用GPT4需要有gpt4权限的apiKey")
|
567 |
gr.Markdown("## 文本例子")
|
568 |
gr.Examples(
|
|
|
326 |
if Humanjudage[:2] != '合格':
|
327 |
flag = '不合格'
|
328 |
|
329 |
+
dataJson = Chat(prompt + quesText, systemPrompt)
|
330 |
|
331 |
if len(dataJson) != 0:
|
332 |
newLine = [quesText, dataJson['Explain'], dataJson['Result'], flag, Humanjudage]
|
|
|
388 |
transLateJson['GPTWriteText_Cn'])
|
389 |
return ''
|
390 |
|
391 |
+
def AnalyzingSemanticChanges(textA, rewriteTextB,gptVersion,slider,gptApiKey):
|
392 |
+
quesText = "文本A:{} GPT改写后的文本B:{}".format(PreHandle(textA), PreHandle(rewriteTextB))
|
393 |
+
systemMessage='请你扮演一个在AI时代诞生著名的AIGC内容审核员。你对日本的语言习惯、语言文化极度了解,也很擅长改写文本。稳定、精准、安全、可控、懂得变通是你的座右铭。面对任何要审核的内容都非常上心、仔细、认真且专注的去理解待审核文本、然后依据审核标准进行判断。在给定审核标准与审核结果的情况下,你清楚的知道自己为什么会给出这样的审核结果。'
|
394 |
+
promt='''
|
395 |
+
现在将给你一段由 文本A和GPT将文本A改写后的文本B组成的文本。
|
396 |
+
请你依据文本A的内容,针对GPT内容生成的文本B:在理解文本A和GPT改写后的文本B的基础上。分析文本A和GPT改写后的文本B的意思,提取两个文本的语义关键词,比较语义关键词是否有差异。然后从语义差异、情境变化、核心信息变化幅度这三个角度对着两个文本进行分析。求GPT改写的改写效果。
|
397 |
+
'''
|
398 |
+
res= Chat(promt+quesText,systemMessage,slider,gptVersion,gptApiKey)
|
399 |
+
return res
|
400 |
+
|
401 |
|
402 |
def HandleData():
|
403 |
book = openpyxl.load_workbook('PromptTestdataV2.xlsx')
|
|
|
430 |
wb.save('testV17.xlsx')
|
431 |
|
432 |
|
433 |
+
def Chat(ques, systemmessage,temperature,gptversion,api_key):
|
434 |
system_msg = {
|
435 |
"role": "system",
|
436 |
"content": systemmessage
|
437 |
}
|
438 |
+
openai.api_key = api_key
|
439 |
+
#temperature = 0.4 # 温度参数
|
440 |
maxNum = 3
|
441 |
maxDistance = 4
|
442 |
minOverlap = 0.6
|
|
|
445 |
try:
|
446 |
completion = openai.ChatCompletion.create(
|
447 |
# model="gpt-3.5-turbo",
|
448 |
+
# model="gpt-4",
|
449 |
+
model=gptversion,
|
450 |
messages=[system_msg, {"role": "user", "content": ques}],
|
451 |
temperature=temperature)
|
452 |
# print(completion['choices'][0]['message']['content'])
|
453 |
print(completion['choices'][0]['message']['content'])
|
454 |
+
|
455 |
+
return completion['choices'][0]['message']['content']
|
456 |
except Exception as e:
|
457 |
|
458 |
print(e)
|
|
|
572 |
gptApiKey = gr.Textbox(label='GPTAPIKey', lines=2, placeholder='输入apiKey')
|
573 |
|
574 |
button2 = gr.Button('开始审核')
|
575 |
+
with gr.Tab('GPT改写效果解析_文本'):
|
576 |
+
text_input = gr.Textbox(label='文本A', lines=2, placeholder='输入改写前文本...')
|
577 |
+
textGPTinput = gr.Textbox(label='GPT改写后文本B', lines=2, placeholder='输入GPT改写后的文本...')
|
578 |
+
|
579 |
+
drop = gr.components.Dropdown(label="GPTVersion", choices=GPTVersion,
|
580 |
+
value='gpt-4')
|
581 |
+
|
582 |
+
slider = gr.components.Slider(0, 1, label="Temperature", step=None, value=0.7)
|
583 |
+
gptApiKey = gr.Textbox(label='GPTAPIKey', lines=2, placeholder='输入apiKey...')
|
584 |
+
outputText = gr.Textbox(label='AI审核结果', lines=2, placeholder='...')
|
585 |
+
button3 = gr.Button('开始审核')
|
586 |
+
|
587 |
+
|
588 |
|
589 |
button2.click(excelAIReviewTag, inputs=[inputs,textGPTTargetinput1,drop,slider,gptApiKey], outputs=outputs)
|
590 |
+
button3.click(AnalyzingSemanticChanges,inputs=[text_input,textGPTinput,drop,slider,gptApiKey],outputs=outputText)
|
591 |
+
|
592 |
gr.Markdown("注:使用GPT4需要有gpt4权限的apiKey")
|
593 |
gr.Markdown("## 文本例子")
|
594 |
gr.Examples(
|