aliceblue11 commited on
Commit
0e830c1
·
verified ·
1 Parent(s): c223f4b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -2
app.py CHANGED
@@ -18,8 +18,10 @@ def call_api(content, system_message, max_tokens, temperature, top_p):
18
  response = client.chat_completion(messages=messages, max_tokens=max_tokens, temperature=temperature, top_p=top_p, seed=random_seed)
19
  return response.choices[0].message.content
20
 
21
- def generate_text(user_message, system_message, max_tokens, temperature, top_p):
22
- return call_api(user_message, system_message, max_tokens, temperature, top_p)
 
 
23
 
24
  # 엑셀 업로드 후 처리 기능 추가
25
  def upload_excel(file):
@@ -106,4 +108,26 @@ with gr.Blocks() as demo:
106
  # 엑셀 파일 업로드 후 긍정리뷰 10개와 부정리뷰 10개를 출력
107
  excel_input.upload(upload_excel, inputs=[excel_input], outputs=[excel_output_positive, excel_output_negative])
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  demo.launch()
 
18
  response = client.chat_completion(messages=messages, max_tokens=max_tokens, temperature=temperature, top_p=top_p, seed=random_seed)
19
  return response.choices[0].message.content
20
 
21
+ # 긍정리뷰와 부정리뷰 분석을 위해 LLM 호출
22
+ def analyze_reviews(reviews, prompt, max_tokens, temperature, top_p):
23
+ reviews_text = "\n".join(reviews)
24
+ return call_api(reviews_text, prompt, max_tokens, temperature, top_p)
25
 
26
  # 엑셀 업로드 후 처리 기능 추가
27
  def upload_excel(file):
 
108
  # 엑셀 파일 업로드 후 긍정리뷰 10개와 부정리뷰 10개를 출력
109
  excel_input.upload(upload_excel, inputs=[excel_input], outputs=[excel_output_positive, excel_output_negative])
110
 
111
+ # 긍정리뷰분석 실행 (LLM 호출)
112
+ def analyze_positive_reviews(positive_reviews, prompt, max_tokens, temperature, top_p):
113
+ reviews = positive_reviews.splitlines()
114
+ return analyze_reviews(reviews, prompt, max_tokens, temperature, top_p)
115
+
116
+ # 부정리뷰분석 실행 (LLM 호출)
117
+ def analyze_negative_reviews(negative_reviews, prompt, max_tokens, temperature, top_p):
118
+ reviews = negative_reviews.splitlines()
119
+ return analyze_reviews(reviews, prompt, max_tokens, temperature, top_p)
120
+
121
+ # LLM 분석 버튼 추가 (긍정리뷰분석)
122
+ analyze_positive_btn = gr.Button("긍정리뷰 분석하기")
123
+ analyze_positive_btn.click(fn=analyze_positive_reviews,
124
+ inputs=[excel_output_positive, system_message, max_tokens, temperature, top_p],
125
+ outputs=[output1])
126
+
127
+ # LLM 분석 버튼 추가 (부정리뷰분석)
128
+ analyze_negative_btn = gr.Button("부정리뷰 분석하기")
129
+ analyze_negative_btn.click(fn=analyze_negative_reviews,
130
+ inputs=[excel_output_negative, input2, max_tokens, temperature, top_p],
131
+ outputs=[output2])
132
+
133
  demo.launch()