Update app.py
Browse files
app.py
CHANGED
@@ -53,18 +53,19 @@ def load_sentiment_model():
|
|
53 |
classifier = pipeline("text-classification", model="bucketresearch/politicalBiasBERT")
|
54 |
return classifier
|
55 |
|
|
|
56 |
# GPT-4๋ฅผ ์ด์ฉํด ๋ฐ๋ ๊ด์ ๊ธฐ์ฌ ์์ฑ
|
57 |
def generate_article_gpt4(prompt):
|
58 |
try:
|
59 |
-
#
|
|
|
|
|
|
|
60 |
response = client.completions.create(
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
model="gpt-4",
|
66 |
-
max_tokens=512,
|
67 |
-
temperature=0.7
|
68 |
)
|
69 |
return response.choices[0].text # GPT์ ์๋ต ํ
์คํธ
|
70 |
except Exception as e:
|
|
|
53 |
classifier = pipeline("text-classification", model="bucketresearch/politicalBiasBERT")
|
54 |
return classifier
|
55 |
|
56 |
+
# GPT-4๋ฅผ ์ด์ฉํด ๋ฐ๋ ๊ด์ ๊ธฐ์ฌ ์์ฑ
|
57 |
# GPT-4๋ฅผ ์ด์ฉํด ๋ฐ๋ ๊ด์ ๊ธฐ์ฌ ์์ฑ
|
58 |
def generate_article_gpt4(prompt):
|
59 |
try:
|
60 |
+
# OpenAI ํด๋ผ์ด์ธํธ ์ธ์คํด์ค ์์ฑ
|
61 |
+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
62 |
+
|
63 |
+
# GPT-4๋ก ๋ฐ๋ ๊ด์ ๊ธฐ์ฌ ์์ฑ
|
64 |
response = client.completions.create(
|
65 |
+
model="gpt-4", # ๋ชจ๋ธ ์ง์
|
66 |
+
prompt=prompt, # ํ๋กฌํํธ ์ง์
|
67 |
+
max_tokens=512, # ์์ฑํ ํ
์คํธ์ ์ต๋ ๊ธธ์ด
|
68 |
+
temperature=0.7 # ์ถ๋ ฅ์ ์ฐฝ์์ฑ ์ ๋
|
|
|
|
|
|
|
69 |
)
|
70 |
return response.choices[0].text # GPT์ ์๋ต ํ
์คํธ
|
71 |
except Exception as e:
|