Spaces:
Sleeping
Sleeping
def generate_paragraph_evaluate(paragraph, user_generate_paragraph_evaluate_prompt):
Browse files
app.py
CHANGED
@@ -176,6 +176,33 @@ def generate_paragraph(topic_sentence, supporting_sentences, conclusion_sentence
|
|
176 |
paragraph = f"{topic_sentence}\n{supporting_sentences}\n{conclusion_sentence}"
|
177 |
return paragraph
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
with gr.Blocks() as demo:
|
180 |
with gr.Row():
|
181 |
with gr.Column():
|
|
|
176 |
paragraph = f"{topic_sentence}\n{supporting_sentences}\n{conclusion_sentence}"
|
177 |
return paragraph
|
178 |
|
179 |
+
def generate_paragraph_evaluate(paragraph, user_generate_paragraph_evaluate_prompt):
|
180 |
+
"""
|
181 |
+
根据用户输入的段落,调用OpenAI API生成相关的段落分析。
|
182 |
+
"""
|
183 |
+
user_content = f"""
|
184 |
+
paragraph is {paragraph}
|
185 |
+
{user_generate_paragraph_evaluate_prompt}
|
186 |
+
"""
|
187 |
+
messages = [
|
188 |
+
{"role": "system", "content": paragraph},
|
189 |
+
{"role": "user", "content": user_content}
|
190 |
+
]
|
191 |
+
|
192 |
+
response_format = { "type": "json_object" }
|
193 |
+
|
194 |
+
request_payload = {
|
195 |
+
"model": "gpt-3.5-turbo",
|
196 |
+
"messages": messages,
|
197 |
+
"max_tokens": 500,
|
198 |
+
"response_format": response_format
|
199 |
+
}
|
200 |
+
|
201 |
+
response = OPEN_AI_CLIENT.chat.completions.create(**request_payload)
|
202 |
+
content = response.choices[0].message.content
|
203 |
+
|
204 |
+
return content
|
205 |
+
|
206 |
with gr.Blocks() as demo:
|
207 |
with gr.Row():
|
208 |
with gr.Column():
|