Update app.py
Browse files
app.py
CHANGED
|
@@ -41,17 +41,19 @@ def load_sentiment_model():
|
|
| 41 |
# GPT-4๋ฅผ ์ด์ฉํด ๋ฐ๋ ๊ด์ ๊ธฐ์ฌ ์์ฑ
|
| 42 |
def generate_article_gpt4(prompt):
|
| 43 |
try:
|
| 44 |
-
response = openai.
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
| 48 |
temperature=0.7
|
| 49 |
)
|
| 50 |
-
|
|
|
|
| 51 |
except Exception as e:
|
| 52 |
-
|
| 53 |
-
return "GPT-4 ํ
์คํธ ์์ฑ ์คํจ"
|
| 54 |
-
|
| 55 |
|
| 56 |
# ์ ์น ์ฑํฅ ๋ถ์
|
| 57 |
def analyze_article_sentiment(text, classifier):
|
|
|
|
| 41 |
# GPT-4๋ฅผ ์ด์ฉํด ๋ฐ๋ ๊ด์ ๊ธฐ์ฌ ์์ฑ
|
| 42 |
def generate_article_gpt4(prompt):
|
| 43 |
try:
|
| 44 |
+
response = openai.ChatCompletion.create(
|
| 45 |
+
model="gpt-4", # GPT-4 ๋ชจ๋ธ ์ฌ์ฉ
|
| 46 |
+
messages=[
|
| 47 |
+
{"role": "system", "content": "You are a helpful assistant that generates articles."},
|
| 48 |
+
{"role": "user", "content": prompt}
|
| 49 |
+
],
|
| 50 |
+
max_tokens=512,
|
| 51 |
temperature=0.7
|
| 52 |
)
|
| 53 |
+
# ์๋ต์์ ํ
์คํธ๋ง ์ถ์ถ
|
| 54 |
+
return response['choices'][0]['message']['content']
|
| 55 |
except Exception as e:
|
| 56 |
+
return f"Error generating text: {e}"
|
|
|
|
|
|
|
| 57 |
|
| 58 |
# ์ ์น ์ฑํฅ ๋ถ์
|
| 59 |
def analyze_article_sentiment(text, classifier):
|