820nam commited on
Commit
289d3ff
ยท
verified ยท
1 Parent(s): 610774d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
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
- messages=[
62
- {"role": "system", "content": "You are a helpful assistant that generates articles."},
63
- {"role": "user", "content": prompt}
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: