seawolf2357 commited on
Commit
82b2c0f
·
verified ·
1 Parent(s): ea1ae77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -5,10 +5,13 @@ import json
5
 
6
  # ACCESS_TOKEN = os.getenv("HF_TOKEN")
7
 
8
- def respond(message, history, max_tokens=512, temperature=0.7, top_p=0.95):
 
 
 
9
  data = {
10
  "model": "jinjavis:latest",
11
- "prompt": message,
12
  "max_tokens": max_tokens,
13
  "temperature": temperature,
14
  "top_p": top_p
@@ -31,10 +34,8 @@ def respond(message, history, max_tokens=512, temperature=0.7, top_p=0.95):
31
  print(f"Failed to decode JSON: {e}")
32
  yield "An error occurred while processing your request."
33
 
34
-
35
-
36
  demo = gr.ChatInterface(
37
- fn=respond,
38
  additional_inputs=[
39
  gr.Slider(minimum=1, maximum=2048, value=512, label="Max Tokens"),
40
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, label="Temperature"),
@@ -44,4 +45,4 @@ demo = gr.ChatInterface(
44
  )
45
 
46
  if __name__ == "__main__":
47
- demo.queue(max_size=10).launch()
 
5
 
6
  # ACCESS_TOKEN = os.getenv("HF_TOKEN")
7
 
8
+ def respond_with_prefix(message, history, max_tokens=512, temperature=0.7, top_p=0.95):
9
+ system_prefix = "SYSTEM: " # 시스템 프리픽스 추가
10
+ modified_message = system_prefix + message # 사용자 메시지에 프리픽스 적용
11
+
12
  data = {
13
  "model": "jinjavis:latest",
14
+ "prompt": modified_message,
15
  "max_tokens": max_tokens,
16
  "temperature": temperature,
17
  "top_p": top_p
 
34
  print(f"Failed to decode JSON: {e}")
35
  yield "An error occurred while processing your request."
36
 
 
 
37
  demo = gr.ChatInterface(
38
+ fn=respond_with_prefix,
39
  additional_inputs=[
40
  gr.Slider(minimum=1, maximum=2048, value=512, label="Max Tokens"),
41
  gr.Slider(minimum=0.1, maximum=4.0, value=0.7, label="Temperature"),
 
45
  )
46
 
47
  if __name__ == "__main__":
48
+ demo.queue(max_size=10).launch()