seawolf2357 commited on
Commit
ac9578e
ยท
verified ยท
1 Parent(s): 0491472

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -75,6 +75,7 @@ const feedbackLink = `https://promptspellsmith.com/feedback`
75
  // Think logically and methodically, asking probing questions to encourage the user to articulate their thought process and reasoning. This approach not only helps
76
  """
77
 
 
78
  def format_prompt(message, history):
79
  prompt = "<s>[SYSTEM] {} [/SYSTEM]".format(system_instruction)
80
  for user_prompt, bot_response in history:
@@ -83,11 +84,14 @@ def format_prompt(message, history):
83
  return prompt
84
 
85
  def generate(prompt, history, temperature=0.1, max_new_tokens=25000, top_p=0.95, repetition_penalty=1.0):
86
- # ํ† ํฐ ์ˆ˜ ๊ณ„์‚ฐ
87
  input_tokens = len(tokenizer.encode(prompt))
88
- available_tokens = 32768 - input_tokens # ์ตœ๋Œ€ ํ—ˆ์šฉ ํ† ํฐ ์ˆ˜์—์„œ ์ž…๋ ฅ ํ† ํฐ ์ˆ˜๋ฅผ ๋บ€ ๊ฐ’
89
- max_new_tokens = min(max_new_tokens, available_tokens) # ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์ตœ๋Œ€ ํ† ํฐ ์ˆ˜ ์กฐ์ •
90
 
 
 
 
 
91
  formatted_prompt = format_prompt(prompt, history)
92
 
93
  try:
@@ -102,7 +106,7 @@ def generate(prompt, history, temperature=0.1, max_new_tokens=25000, top_p=0.95,
102
 
103
  mychatbot = gr.Chatbot(
104
  avatar_images=["./user.png", "./botm.png"],
105
- bubble_full_width=False,
106
  show_label=False,
107
  show_copy_button=True,
108
  likeable=True,
@@ -118,10 +122,11 @@ examples = [
118
 
119
  demo = gr.Interface(
120
  fn=generate,
121
- inputs=gr.Textbox(placeholder="์—ฌ๊ธฐ์— ์งˆ๋ฌธ์„ ์ž…๋ ฅํ•˜์„ธ์š”...", lines=2),
122
  outputs=gr.Markdown(),
123
  examples=examples,
124
- title="AIQ ์ฝ”๋“œํŒŒ์ผ๋Ÿฟ: OpenLLM v1.12"
 
125
  )
126
 
127
  demo.launch(show_api=False)
 
75
  // Think logically and methodically, asking probing questions to encourage the user to articulate their thought process and reasoning. This approach not only helps
76
  """
77
 
78
+
79
  def format_prompt(message, history):
80
  prompt = "<s>[SYSTEM] {} [/SYSTEM]".format(system_instruction)
81
  for user_prompt, bot_response in history:
 
84
  return prompt
85
 
86
  def generate(prompt, history, temperature=0.1, max_new_tokens=25000, top_p=0.95, repetition_penalty=1.0):
 
87
  input_tokens = len(tokenizer.encode(prompt))
88
+ available_tokens = 32768 - input_tokens
89
+ max_new_tokens = min(max_new_tokens, available_tokens)
90
 
91
+ if available_tokens <= 0:
92
+ yield "Error: ์ž…๋ ฅ์ด ์ตœ๋Œ€ ํ—ˆ์šฉ ํ† ํฐ ์ˆ˜๋ฅผ ์ดˆ๊ณผํ•ฉ๋‹ˆ๋‹ค."
93
+ return
94
+
95
  formatted_prompt = format_prompt(prompt, history)
96
 
97
  try:
 
106
 
107
  mychatbot = gr.Chatbot(
108
  avatar_images=["./user.png", "./botm.png"],
109
+ bubble_full_width=True,
110
  show_label=False,
111
  show_copy_button=True,
112
  likeable=True,
 
122
 
123
  demo = gr.Interface(
124
  fn=generate,
125
+ inputs=[gr.Textbox(label="์งˆ๋ฌธ์„ ์ž…๋ ฅํ•˜์„ธ์š”", placeholder="์—ฌ๊ธฐ์— ์งˆ๋ฌธ์„ ์ž…๋ ฅํ•˜์„ธ์š”...", lines=2), gr.JSON(label="History", value=[])],
126
  outputs=gr.Markdown(),
127
  examples=examples,
128
+ title="AIQ ์ฝ”๋“œํŒŒ์ผ๋Ÿฟ: OpenLLM v1.12",
129
+ description="AIQ Codepilot๊ณผ ์ƒํ˜ธ์ž‘์šฉํ•ด ๋ณด์„ธ์š”."
130
  )
131
 
132
  demo.launch(show_api=False)