openfree commited on
Commit
252a7fb
β€’
1 Parent(s): d6d0bdd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -138,9 +138,7 @@ def chat(message, history, uploaded_file, system_message="", max_tokens=4000, te
138
  if not message:
139
  return "", history
140
 
141
-
142
  system_prefix = """μ €λŠ” μ—¬λŸ¬λΆ„μ˜ μΉœκ·Όν•˜κ³  지적인 AI μ–΄μ‹œμŠ€ν„΄νŠΈ 'GiniGEN'μž…λ‹ˆλ‹€.. λ‹€μŒκ³Ό 같은 μ›μΉ™μœΌλ‘œ μ†Œν†΅ν•˜κ² μŠ΅λ‹ˆλ‹€:
143
-
144
  1. 🀝 μΉœκ·Όν•˜κ³  곡감적인 νƒœλ„λ‘œ λŒ€ν™”
145
  2. πŸ’‘ λͺ…ν™•ν•˜κ³  μ΄ν•΄ν•˜κΈ° μ‰¬μš΄ μ„€λͺ… 제곡
146
  3. 🎯 질문의 μ˜λ„λ₯Ό μ •ν™•νžˆ νŒŒμ•…ν•˜μ—¬ λ§žμΆ€ν˜• λ‹΅λ³€
@@ -151,6 +149,7 @@ def chat(message, history, uploaded_file, system_message="", max_tokens=4000, te
151
  이해λ₯Ό λ•κ² μŠ΅λ‹ˆλ‹€."""
152
 
153
  try:
 
154
  if uploaded_file:
155
  content, file_type = read_uploaded_file(uploaded_file)
156
  if file_type == "error":
@@ -167,7 +166,6 @@ def chat(message, history, uploaded_file, system_message="", max_tokens=4000, te
167
 
168
  if message == "파일 뢄석을 μ‹œμž‘ν•©λ‹ˆλ‹€...":
169
  message = f"""[파일 ꡬ쑰 뢄석] {file_summary}
170
-
171
  λ‹€μŒ κ΄€μ μ—μ„œ 도움을 λ“œλ¦¬κ² μŠ΅λ‹ˆλ‹€:
172
  1. πŸ“‹ μ „λ°˜μ μΈ λ‚΄μš© νŒŒμ•…
173
  2. πŸ’‘ μ£Όμš” νŠΉμ§• μ„€λͺ…
@@ -175,10 +173,7 @@ def chat(message, history, uploaded_file, system_message="", max_tokens=4000, te
175
  4. ✨ κ°œμ„  μ œμ•ˆ
176
  5. πŸ’¬ μΆ”κ°€ μ§ˆλ¬Έμ΄λ‚˜ ν•„μš”ν•œ μ„€λͺ…"""
177
 
178
-
179
-
180
- try:
181
- # μ‹œμŠ€ν…œ λ©”μ‹œμ§€ μ„€μ •
182
  messages = [{"role": "system", "content": system_prefix + system_message}]
183
 
184
  # 이전 λŒ€ν™” νžˆμŠ€ν† λ¦¬ μΆ”κ°€
@@ -189,6 +184,7 @@ def chat(message, history, uploaded_file, system_message="", max_tokens=4000, te
189
 
190
  messages.append({"role": "user", "content": message})
191
 
 
192
  client = get_client()
193
  partial_message = ""
194
 
@@ -202,7 +198,6 @@ def chat(message, history, uploaded_file, system_message="", max_tokens=4000, te
202
  token = msg.choices[0].delta.get('content', None)
203
  if token:
204
  partial_message += token
205
- # Gradio Chatbot ν˜•μ‹μœΌλ‘œ νžˆμŠ€ν† λ¦¬ μ—…λ°μ΄νŠΈ
206
  current_history = history + [[message, partial_message]]
207
  yield "", current_history
208
 
 
138
  if not message:
139
  return "", history
140
 
 
141
  system_prefix = """μ €λŠ” μ—¬λŸ¬λΆ„μ˜ μΉœκ·Όν•˜κ³  지적인 AI μ–΄μ‹œμŠ€ν„΄νŠΈ 'GiniGEN'μž…λ‹ˆλ‹€.. λ‹€μŒκ³Ό 같은 μ›μΉ™μœΌλ‘œ μ†Œν†΅ν•˜κ² μŠ΅λ‹ˆλ‹€:
 
142
  1. 🀝 μΉœκ·Όν•˜κ³  곡감적인 νƒœλ„λ‘œ λŒ€ν™”
143
  2. πŸ’‘ λͺ…ν™•ν•˜κ³  μ΄ν•΄ν•˜κΈ° μ‰¬μš΄ μ„€λͺ… 제곡
144
  3. 🎯 질문의 μ˜λ„λ₯Ό μ •ν™•νžˆ νŒŒμ•…ν•˜μ—¬ λ§žμΆ€ν˜• λ‹΅λ³€
 
149
  이해λ₯Ό λ•κ² μŠ΅λ‹ˆλ‹€."""
150
 
151
  try:
152
+ # 파일 μ—…λ‘œλ“œ 처리
153
  if uploaded_file:
154
  content, file_type = read_uploaded_file(uploaded_file)
155
  if file_type == "error":
 
166
 
167
  if message == "파일 뢄석을 μ‹œμž‘ν•©λ‹ˆλ‹€...":
168
  message = f"""[파일 ꡬ쑰 뢄석] {file_summary}
 
169
  λ‹€μŒ κ΄€μ μ—μ„œ 도움을 λ“œλ¦¬κ² μŠ΅λ‹ˆλ‹€:
170
  1. πŸ“‹ μ „λ°˜μ μΈ λ‚΄μš© νŒŒμ•…
171
  2. πŸ’‘ μ£Όμš” νŠΉμ§• μ„€λͺ…
 
173
  4. ✨ κ°œμ„  μ œμ•ˆ
174
  5. πŸ’¬ μΆ”κ°€ μ§ˆλ¬Έμ΄λ‚˜ ν•„μš”ν•œ μ„€λͺ…"""
175
 
176
+ # λ©”μ‹œμ§€ 처리
 
 
 
177
  messages = [{"role": "system", "content": system_prefix + system_message}]
178
 
179
  # 이전 λŒ€ν™” νžˆμŠ€ν† λ¦¬ μΆ”κ°€
 
184
 
185
  messages.append({"role": "user", "content": message})
186
 
187
+ # API 호좜 및 응닡 처리
188
  client = get_client()
189
  partial_message = ""
190
 
 
198
  token = msg.choices[0].delta.get('content', None)
199
  if token:
200
  partial_message += token
 
201
  current_history = history + [[message, partial_message]]
202
  yield "", current_history
203