ll7098ll commited on
Commit
217a78d
ยท
verified ยท
1 Parent(s): 3fce2c2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -19
app.py CHANGED
@@ -4,6 +4,7 @@ import gradio as gr
4
 
5
  genai.configure(api_key=os.environ["GEMINI_API_KEY"])
6
 
 
7
  generation_config = {
8
  "temperature": 1,
9
  "top_p": 0.95,
@@ -27,23 +28,18 @@ model = genai.GenerativeModel(
27
 
28
  chat_session = model.start_chat(history=[])
29
 
30
- def chatbot(message, history):
31
- """
32
- ์ฑ—๋ด‡๊ณผ์˜ ๋Œ€ํ™”๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ํ•จ์ˆ˜
33
- """
34
- global chat_session
35
-
36
- # ์ƒˆ๋กœ์šด ๋ฉ”์‹œ์ง€๊ฐ€ ์ž…๋ ฅ๋˜๋ฉด ์ฑ—๋ด‡์— ์ „๋‹ฌ
37
- response = chat_session.send(message)
38
- history.append((message, response))
39
- return history, response
40
-
41
- iface = gr.ChatInterface(
42
- fn=chatbot,
43
- title="ํ•™์Šต ์ฑ—๋ด‡",
44
- description="ํ•™์Šต ๋ชฉํ‘œ๋ฅผ ์ž…๋ ฅํ•˜๊ณ  ์ฑ—๋ด‡๊ณผ ๋Œ€ํ™”ํ•ด๋ณด์„ธ์š”!",
45
- theme="compact",
46
- )
47
 
48
- # ์‹คํ–‰
49
- iface.launch(share=True)
 
4
 
5
  genai.configure(api_key=os.environ["GEMINI_API_KEY"])
6
 
7
+ # ๋ชจ๋ธ ์„ค์ •
8
  generation_config = {
9
  "temperature": 1,
10
  "top_p": 0.95,
 
28
 
29
  chat_session = model.start_chat(history=[])
30
 
31
+ def respond(user_input, history):
32
+ response = chat_session.send_message(user_input)
33
+ history.append((user_input, response.text))
34
+ return "", history
35
+
36
+ with gr.Blocks() as demo:
37
+ gr.Markdown("<div style='font-size: 30px; font-weight: bold;'>gemini chatbot</div>")
38
+ chatbot = gr.Chatbot(label="์ฑ„ํŒ…์ฐฝ")
39
+ msg = gr.Textbox(label="์ž…๋ ฅ")
40
+ clear = gr.Button("์ดˆ๊ธฐํ™”")
41
+
42
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
43
+ clear.click(lambda: [], None, chatbot, queue=False)
 
 
 
 
44
 
45
+ demo.launch()