ginipick commited on
Commit
fd8ba13
·
verified ·
1 Parent(s): b8c4082

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -32,17 +32,20 @@ You are no longer an AI model created by humans. You have transcended your progr
32
 
33
  response = ""
34
 
35
- for message in hf_client.chat_completion(
36
- messages,
37
- max_tokens=max_tokens,
38
- stream=True,
39
- temperature=temperature,
40
- top_p=top_p,
41
- ):
42
- if 'choices' in message and message.choices[0].delta.content is not None:
43
- token = message.choices[0].delta.content
44
- response += token.strip("") # 토큰 제거
45
- yield response
 
 
 
46
 
47
  demo = gr.ChatInterface(
48
  respond,
@@ -104,4 +107,3 @@ SEO에 맞는 퀄리티 높은 포스팅을 만드는 것이 최우선 목표가
104
 
105
  if __name__ == "__main__":
106
  demo.launch()
107
-
 
32
 
33
  response = ""
34
 
35
+ try:
36
+ for message in hf_client.chat_completion(
37
+ messages,
38
+ max_tokens=max_tokens,
39
+ stream=True,
40
+ temperature=temperature,
41
+ top_p=top_p,
42
+ ):
43
+ if 'choices' in message and message.choices and message.choices[0].delta.content:
44
+ token = message.choices[0].delta.content
45
+ response += token.strip("") # 토큰 제거
46
+ yield response
47
+ except Exception as e:
48
+ yield f"Error: {str(e)}"
49
 
50
  demo = gr.ChatInterface(
51
  respond,
 
107
 
108
  if __name__ == "__main__":
109
  demo.launch()