820nam commited on
Commit
242b668
ยท
verified ยท
1 Parent(s): 5a80960

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
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.Completion.create(
45
- engine="text-davinci-004", # GPT-4 ์—”์ง„
46
- prompt=prompt,
47
- max_tokens=300,
 
 
 
48
  temperature=0.7
49
  )
50
- return response.choices[0].text.strip()
 
51
  except Exception as e:
52
- st.error(f"Error generating text: {e}")
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):