Update app/main.py
Browse files- app/main.py +9 -7
app/main.py
CHANGED
@@ -19,8 +19,10 @@ BAIDU_API_KEY = os.getenv("BAIDU_API_KEY", "")
|
|
19 |
BAIDU_SECRET_KEY = os.getenv("BAIDU_SECRET_KEY", "")
|
20 |
|
21 |
# —— 指定代理站 & API Key —— #
|
22 |
-
openai.api_key = "Magic-123456"
|
23 |
-
openai.base_url = "https://freeapi.oaiopen.com/v1/"
|
|
|
|
|
24 |
openai.default_headers = {"x-foo": "true"}
|
25 |
|
26 |
# —— 初始化 v1 客户端 —— #
|
@@ -77,7 +79,7 @@ def process(image_pil):
|
|
77 |
"请帮我整理下面的英语作文文本格式,只整理英文正文部分(忽略英文正文外所有部分),保证原汁原味(明显错误空格换行、乱码、非常用字符比如☰需要改正除外),出现的拼写错误也不要帮助改正:\n\n"+ essay_text
|
78 |
)
|
79 |
fm_resp = openai.chat.completions.create(
|
80 |
-
model="gpt-4o",
|
81 |
messages=[{"role": "user", "content": fmt_prompt}]
|
82 |
)
|
83 |
revised = fm_resp.choices[0].message.content
|
@@ -91,7 +93,7 @@ def process(image_pil):
|
|
91 |
+ revised
|
92 |
)
|
93 |
cm_resp = openai.chat.completions.create(
|
94 |
-
model="gpt-4o",
|
95 |
messages=[{"role": "user", "content": corr_prompt}]
|
96 |
)
|
97 |
corrected = cm_resp.choices[0].message.content
|
@@ -124,7 +126,7 @@ def process(image_pil):
|
|
124 |
)
|
125 |
|
126 |
rm_resp = openai.chat.completions.create(
|
127 |
-
model="gpt-4o",
|
128 |
messages=[{"role": "user", "content": review_prompt}]
|
129 |
)
|
130 |
review = rm_resp.choices[0].message.content
|
@@ -165,7 +167,7 @@ def process(image_pil):
|
|
165 |
""" + revised
|
166 |
)
|
167 |
rr_resp = openai.chat.completions.create(
|
168 |
-
model="gpt-4o",
|
169 |
messages=[{"role": "user", "content": rate_prompt}]
|
170 |
)
|
171 |
rating = rr_resp.choices[0].message.content
|
@@ -179,7 +181,7 @@ def process(image_pil):
|
|
179 |
下面是这篇英文习作原文:\n\n""" + revised
|
180 |
)
|
181 |
wm_resp = openai.chat.completions.create(
|
182 |
-
model="gpt-4o",
|
183 |
messages=[{"role": "user", "content": rewrite_prompt}]
|
184 |
)
|
185 |
perfect = wm_resp.choices[0].message.content
|
|
|
19 |
BAIDU_SECRET_KEY = os.getenv("BAIDU_SECRET_KEY", "")
|
20 |
|
21 |
# —— 指定代理站 & API Key —— #
|
22 |
+
#openai.api_key = "Magic-123456"
|
23 |
+
#openai.base_url = "https://freeapi.oaiopen.com/v1/"
|
24 |
+
openai.api_key = "sk-7fD7AnAlQxGta0kZ11D1B793F9B244AcAf75470d5f3c5462"
|
25 |
+
openai.base_url = "https://free.v36.cm/v1/"
|
26 |
openai.default_headers = {"x-foo": "true"}
|
27 |
|
28 |
# —— 初始化 v1 客户端 —— #
|
|
|
79 |
"请帮我整理下面的英语作文文本格式,只整理英文正文部分(忽略英文正文外所有部分),保证原汁原味(明显错误空格换行、乱码、非常用字符比如☰需要改正除外),出现的拼写错误也不要帮助改正:\n\n"+ essay_text
|
80 |
)
|
81 |
fm_resp = openai.chat.completions.create(
|
82 |
+
model="gpt-4o-mini",
|
83 |
messages=[{"role": "user", "content": fmt_prompt}]
|
84 |
)
|
85 |
revised = fm_resp.choices[0].message.content
|
|
|
93 |
+ revised
|
94 |
)
|
95 |
cm_resp = openai.chat.completions.create(
|
96 |
+
model="gpt-4o-mini",
|
97 |
messages=[{"role": "user", "content": corr_prompt}]
|
98 |
)
|
99 |
corrected = cm_resp.choices[0].message.content
|
|
|
126 |
)
|
127 |
|
128 |
rm_resp = openai.chat.completions.create(
|
129 |
+
model="gpt-4o-mini",
|
130 |
messages=[{"role": "user", "content": review_prompt}]
|
131 |
)
|
132 |
review = rm_resp.choices[0].message.content
|
|
|
167 |
""" + revised
|
168 |
)
|
169 |
rr_resp = openai.chat.completions.create(
|
170 |
+
model="gpt-4o-mini",
|
171 |
messages=[{"role": "user", "content": rate_prompt}]
|
172 |
)
|
173 |
rating = rr_resp.choices[0].message.content
|
|
|
181 |
下面是这篇英文习作原文:\n\n""" + revised
|
182 |
)
|
183 |
wm_resp = openai.chat.completions.create(
|
184 |
+
model="gpt-4o-mini",
|
185 |
messages=[{"role": "user", "content": rewrite_prompt}]
|
186 |
)
|
187 |
perfect = wm_resp.choices[0].message.content
|