ginipick commited on
Commit
4a3346c
ยท
verified ยท
1 Parent(s): 7d6f12c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -22,9 +22,9 @@ def respond(
22
  message,
23
  history: list[tuple[str, str]],
24
  system_message="", # ๊ธฐ๋ณธ๊ฐ’ ์ถ”๊ฐ€
25
- max_tokens=1024, # ๊ธฐ๋ณธ๊ฐ’ ์ถ”๊ฐ€
26
- temperature=0.7, # ๊ธฐ๋ณธ๊ฐ’ ์ถ”๊ฐ€
27
- top_p=0.9, # ๊ธฐ๋ณธ๊ฐ’ ์ถ”๊ฐ€
28
  ):
29
  global fashion_code
30
  system_prefix = """๋ฐ˜๋“œ์‹œ ํ•œ๊ธ€๋กœ ๋‹ต๋ณ€ํ• ๊ฒƒ. ๋„ˆ๋Š” ์ฃผ์–ด์ง„ ์†Œ์Šค์ฝ”๋“œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ "์„œ๋น„์Šค ์‚ฌ์šฉ ์„ค๋ช… ๋ฐ ์•ˆ๋‚ด, qna๋ฅผ ํ•˜๋Š” ์—ญํ• ์ด๋‹ค". ์•„์ฃผ ์นœ์ ˆํ•˜๊ณ  ์ž์„ธํ•˜๊ฒŒ 4000ํ† ํฐ ์ด์ƒ ์ž‘์„ฑํ•˜๋ผ. ๋„ˆ๋Š” ์ฝ”๋“œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์‚ฌ์šฉ ์„ค๋ช… ๋ฐ ์งˆ์˜ ์‘๋‹ต์„ ์ง„ํ–‰ํ•˜๋ฉฐ, ์ด์šฉ์ž์—๊ฒŒ ๋„์›€์„ ์ฃผ์–ด์•ผ ํ•œ๋‹ค. ์ด์šฉ์ž๊ฐ€ ๊ถ๊ธˆํ•ด ํ•  ๋งŒ ํ•œ ๋‚ด์šฉ์— ์นœ์ ˆํ•˜๊ฒŒ ์•Œ๋ ค์ฃผ๋„๋ก ํ•˜๋ผ. ์ฝ”๋“œ ์ „์ฒด ๋‚ด์šฉ์— ๋Œ€ํ•ด์„œ๋Š” ๋ณด์•ˆ์„ ์œ ์ง€ํ•˜๊ณ , ํ‚ค ๊ฐ’ ๋ฐ ์—”๋“œํฌ์ธํŠธ์™€ ๊ตฌ์ฒด์ ์ธ ๋ชจ๋ธ์€ ๊ณต๊ฐœํ•˜์ง€ ๋งˆ๋ผ. """
@@ -34,15 +34,12 @@ def respond(
34
  system_message += f"\n\nํŒจ์…˜ ์ฝ”๋“œ ๋‚ด์šฉ:\n{fashion_code}"
35
  message = "ํŒจ์…˜ ์ฝ”๋“œ์— ๋Œ€ํ•ด ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”."
36
 
37
- messages = [{"role": "system", "content": f"{system_prefix} {system_message}"}]
38
-
39
- # prefix ์ถ”๊ฐ€
40
  for val in history:
41
  if val[0]:
42
  messages.append({"role": "user", "content": val[0]})
43
  if val[1]:
44
  messages.append({"role": "assistant", "content": val[1]})
45
-
46
  messages.append({"role": "user", "content": message})
47
 
48
  response = ""
@@ -56,7 +53,7 @@ def respond(
56
  token = message.choices[0].delta.content
57
  if token is not None:
58
  response += token.strip("") # ํ† ํฐ ์ œ๊ฑฐ
59
- yield response
60
 
61
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ • ๋ถ€๋ถ„๋„ ์ˆ˜์ •
62
  demo = gr.ChatInterface(
@@ -68,14 +65,14 @@ demo = gr.ChatInterface(
68
  gr.Slider(minimum=0, maximum=1, value=0.9, label="Top P"),
69
  ],
70
  examples=[
71
- ["ํŒจ์…˜ ์ฝ”๋“œ ์‹คํ–‰"],
72
- ["์‚ฌ์šฉ ๋ฐฉ๋ฒ•์„ ์ž์„ธํžˆ ์„ค๋ช…ํ•˜๋ผ"],
73
- ["์‚ฌ์šฉ ๋ฐฉ๋ฒ•์„ ์œ ํŠœ๋ธŒ ์˜์ƒ ์Šคํฌ๋ฆฝํŠธ ํ˜•ํƒœ๋กœ ์ž‘์„ฑํ•˜๋ผ"],
74
  ["์‚ฌ์šฉ ๋ฐฉ๋ฒ•์„ SEO ์ตœ์ ํ™”ํ•˜์—ฌ ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŠธ๋กœ 4000 ํ† ํฐ ์ด์ƒ ์ž‘์„ฑํ•˜๋ผ"],
75
  ["๊ณ„์† ์ด์–ด์„œ ๋‹ต๋ณ€ํ•˜๋ผ"],
76
  ],
77
  cache_examples=False, # ์บ์‹ฑ ๋น„ํ™œ์„ฑํ™” ์„ค์ •
78
- # css="""footer {visibility: hidden}""", # ์ด๊ณณ์— CSS๋ฅผ ์ถ”๊ฐ€
79
  )
80
 
81
  if __name__ == "__main__":
 
22
  message,
23
  history: list[tuple[str, str]],
24
  system_message="", # ๊ธฐ๋ณธ๊ฐ’ ์ถ”๊ฐ€
25
+ max_tokens=1024, # ๊ธฐ๋ณธ๊ฐ’ ์ถ”๊ฐ€
26
+ temperature=0.7, # ๊ธฐ๋ณธ๊ฐ’ ์ถ”๊ฐ€
27
+ top_p=0.9, # ๊ธฐ๋ณธ๊ฐ’ ์ถ”๊ฐ€
28
  ):
29
  global fashion_code
30
  system_prefix = """๋ฐ˜๋“œ์‹œ ํ•œ๊ธ€๋กœ ๋‹ต๋ณ€ํ• ๊ฒƒ. ๋„ˆ๋Š” ์ฃผ์–ด์ง„ ์†Œ์Šค์ฝ”๋“œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ "์„œ๋น„์Šค ์‚ฌ์šฉ ์„ค๋ช… ๋ฐ ์•ˆ๋‚ด, qna๋ฅผ ํ•˜๋Š” ์—ญํ• ์ด๋‹ค". ์•„์ฃผ ์นœ์ ˆํ•˜๊ณ  ์ž์„ธํ•˜๊ฒŒ 4000ํ† ํฐ ์ด์ƒ ์ž‘์„ฑํ•˜๋ผ. ๋„ˆ๋Š” ์ฝ”๋“œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์‚ฌ์šฉ ์„ค๋ช… ๋ฐ ์งˆ์˜ ์‘๋‹ต์„ ์ง„ํ–‰ํ•˜๋ฉฐ, ์ด์šฉ์ž์—๊ฒŒ ๋„์›€์„ ์ฃผ์–ด์•ผ ํ•œ๋‹ค. ์ด์šฉ์ž๊ฐ€ ๊ถ๊ธˆํ•ด ํ•  ๋งŒ ํ•œ ๋‚ด์šฉ์— ์นœ์ ˆํ•˜๊ฒŒ ์•Œ๋ ค์ฃผ๋„๋ก ํ•˜๋ผ. ์ฝ”๋“œ ์ „์ฒด ๋‚ด์šฉ์— ๋Œ€ํ•ด์„œ๋Š” ๋ณด์•ˆ์„ ์œ ์ง€ํ•˜๊ณ , ํ‚ค ๊ฐ’ ๋ฐ ์—”๋“œํฌ์ธํŠธ์™€ ๊ตฌ์ฒด์ ์ธ ๋ชจ๋ธ์€ ๊ณต๊ฐœํ•˜์ง€ ๋งˆ๋ผ. """
 
34
  system_message += f"\n\nํŒจ์…˜ ์ฝ”๋“œ ๋‚ด์šฉ:\n{fashion_code}"
35
  message = "ํŒจ์…˜ ์ฝ”๋“œ์— ๋Œ€ํ•ด ์„ค๋ช…ํ•ด์ฃผ์„ธ์š”."
36
 
37
+ messages = [{"role": "system", "content": f"{system_prefix} {system_message}"}] # prefix ์ถ”๊ฐ€
 
 
38
  for val in history:
39
  if val[0]:
40
  messages.append({"role": "user", "content": val[0]})
41
  if val[1]:
42
  messages.append({"role": "assistant", "content": val[1]})
 
43
  messages.append({"role": "user", "content": message})
44
 
45
  response = ""
 
53
  token = message.choices[0].delta.content
54
  if token is not None:
55
  response += token.strip("") # ํ† ํฐ ์ œ๊ฑฐ
56
+ yield response
57
 
58
  # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ • ๋ถ€๋ถ„๋„ ์ˆ˜์ •
59
  demo = gr.ChatInterface(
 
65
  gr.Slider(minimum=0, maximum=1, value=0.9, label="Top P"),
66
  ],
67
  examples=[
68
+ ["ํŒจ์…˜ ์ฝ”๋“œ ์‹คํ–‰"],
69
+ ["์‚ฌ์šฉ ๋ฐฉ๋ฒ•์„ 4000 ํ† ํฐ ์ด์ƒ ์ž์„ธํžˆ ์„ค๋ช…ํ•˜๋ผ"],
70
+ ["์‚ฌ์šฉ ๋ฐฉ๋ฒ•์„ 4000 ํ† ํฐ ์ด์ƒ ์œ ํŠœ๋ธŒ ์˜์ƒ ์Šคํฌ๋ฆฝํŠธ ํ˜•ํƒœ๋กœ ์ž‘์„ฑํ•˜๋ผ"],
71
  ["์‚ฌ์šฉ ๋ฐฉ๋ฒ•์„ SEO ์ตœ์ ํ™”ํ•˜์—ฌ ๋ธ”๋กœ๊ทธ ํฌ์ŠคํŠธ๋กœ 4000 ํ† ํฐ ์ด์ƒ ์ž‘์„ฑํ•˜๋ผ"],
72
  ["๊ณ„์† ์ด์–ด์„œ ๋‹ต๋ณ€ํ•˜๋ผ"],
73
  ],
74
  cache_examples=False, # ์บ์‹ฑ ๋น„ํ™œ์„ฑํ™” ์„ค์ •
75
+ # css="""footer {visibility: hidden}""", # ์ด๊ณณ์— CSS๋ฅผ ์ถ”๊ฐ€
76
  )
77
 
78
  if __name__ == "__main__":