KorWoody commited on
Commit
c03c574
Β·
1 Parent(s): 632039a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -65,6 +65,8 @@ def respond(message, chat_history):
65
  # for i, doc in enumerate(result['source_documents']):
66
  # bot_message += str(i+1) + '. ' + doc.metadata['source'] + ' '
67
 
 
 
68
  # μ±„νŒ… 기둝에 μ‚¬μš©μžμ˜ λ©”μ‹œμ§€μ™€ λ΄‡μ˜ 응닡을 μΆ”κ°€.
69
  chat_history.append((message, bot_message))
70
 
@@ -74,6 +76,21 @@ def respond(message, chat_history):
74
 
75
  return " ", chat_history
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  import gradio as gr
78
 
79
  # 챗봇 μ„€λͺ…
 
65
  # for i, doc in enumerate(result['source_documents']):
66
  # bot_message += str(i+1) + '. ' + doc.metadata['source'] + ' '
67
 
68
+ historySave(message=message, answer=str(result['result']).replace("'",""))
69
+
70
  # μ±„νŒ… 기둝에 μ‚¬μš©μžμ˜ λ©”μ‹œμ§€μ™€ λ΄‡μ˜ 응닡을 μΆ”κ°€.
71
  chat_history.append((message, bot_message))
72
 
 
76
 
77
  return " ", chat_history
78
 
79
+ def historySave(message, answer):
80
+
81
+ conn = pymssql.connect(host=r"(127.0.0.1)", database='Chatbot_Manage', charset='utf8')
82
+ conn.autocommit(True) # μ˜€ν†  컀밋 ν™œμ„±ν™”
83
+ # Connection μœΌλ‘œλΆ€ν„° Cursor 생성
84
+ cursor = conn.cursor()
85
+
86
+ SystemType = "OpenAI(Real LLM)"
87
+
88
+ # SQL문 싀행'
89
+ _sql = "EXEC ChatHistory_InsUpd '" + SystemType + "','" + message + "', '" + answer + "'"
90
+ cursor.execute(_sql)
91
+
92
+ conn.close() ## μ—°κ²° 끊기
93
+
94
  import gradio as gr
95
 
96
  # 챗봇 μ„€λͺ