seawolf2357 commited on
Commit
91be94d
1 Parent(s): a1e4ce1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -6,9 +6,16 @@ import json
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,6 +38,10 @@ 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
  css = """
35
  footer {
36
  visibility: hidden;
@@ -48,4 +59,4 @@ demo = gr.ChatInterface(css=css,
48
  )
49
 
50
  if __name__ == "__main__":
51
- demo.launch()
 
6
  # ACCESS_TOKEN = os.getenv("HF_TOKEN")
7
 
8
  def respond(message, history, max_tokens=512, temperature=0.7, top_p=0.95):
9
+ # 대화 이력을 포함한 프롬프트 구성
10
+ if history:
11
+ prompt = "\n".join([f"User: {msg}" for msg, _ in history] + [f"Assistant: {res}" for _, res in history])
12
+ prompt += f"\nUser: {message}\nAssistant:"
13
+ else:
14
+ prompt = f"User: {message}\nAssistant:"
15
+
16
  data = {
17
  "model": "jinjavis:latest",
18
+ "prompt": prompt,
19
  "max_tokens": max_tokens,
20
  "temperature": temperature,
21
  "top_p": top_p
 
38
  print(f"Failed to decode JSON: {e}")
39
  yield "An error occurred while processing your request."
40
 
41
+ # history 업데이트
42
+ history.append((message, partial_message))
43
+
44
+
45
  css = """
46
  footer {
47
  visibility: hidden;
 
59
  )
60
 
61
  if __name__ == "__main__":
62
+ demo.queue(max_size=4).launch()