anpigon commited on
Commit
639460f
1 Parent(s): 5b1c23e

chore: update gradio version to 3.35.2

Browse files

feat: change title and emoji of the project to reflect the chatbot's name and purpose
refactor: remove unnecessary verbose logging in the respond function of app.py
feat: add initial greeting message to the chatbot in app.py
refactor: change gradio theme to Soft in app.py
refactor: simplify the lambda function in the clear button click event in app.py
feat: update langchain version to 0.0.201 in requirements.txt

Files changed (3) hide show
  1. README.md +3 -3
  2. app.py +9 -21
  3. requirements.txt +2 -2
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: Talktosayno
3
- emoji: 📉
4
  colorFrom: green
5
  colorTo: pink
6
  sdk: gradio
7
- sdk_version: 3.34.0
8
  app_file: app.py
9
  pinned: false
10
  license: openrail
 
1
  ---
2
+ title: 세이노 챗봇
3
+ emoji: 💬
4
  colorFrom: green
5
  colorTo: pink
6
  sdk: gradio
7
+ sdk_version: 3.35.2
8
  app_file: app.py
9
  pinned: false
10
  license: openrail
app.py CHANGED
@@ -42,37 +42,25 @@ chain = RetrievalQAWithSourcesChain.from_chain_type(
42
  return_source_documents=True,
43
  chain_type_kwargs=chain_type_kwargs,
44
  reduce_k_below_max_tokens=True,
45
- verbose=True,
46
  )
47
 
48
 
49
- # 채팅봇의 응답을 처리하는 함수를 정의합니다.
50
  def respond(message, chat_history):
51
  result = chain(message)
52
-
53
  bot_message = result["answer"]
54
-
55
- # 채팅 기록에 사용자의 메시지와 봇의 응답을 추가합니다.
56
  chat_history.append((message, bot_message))
57
-
58
- # 수정된 채팅 기록을 반환합니다.
59
  return "", chat_history
60
 
61
 
62
- # gr.Blocks() 사용하여 인터페이스를 생성합니다.
63
- with gr.Blocks(theme="gstaff/sketch") as demo:
64
  gr.Markdown("# 안녕하세요. 세이노와 대화해보세요.")
65
- chatbot = gr.Chatbot(label="채팅창") # '채팅창'이라는 레이블을 가진 채팅봇 컴포넌트를 생성합니다.
66
- msg = gr.Textbox(label="입력") # '입력'이라는 레이블을 가진 텍스트박스를 생성합니다.
67
- clear = gr.Button("초기화") # '초기화'라는 레이블을 가진 버튼을 생성합니다.
 
68
 
69
- msg.submit(
70
- respond, [msg, chatbot], [msg, chatbot]
71
- ) # 텍스트박스에 메시지를 입력하고 제출하면 respond 함수가 호출되도록 합니다.
72
- clear.click(
73
- lambda: None, None, chatbot, queue=False
74
- ) # '초기화' 버튼을 클릭하면 채팅 기록을 초기화합니다.
75
 
76
- demo.launch(
77
- debug=True
78
- ) # 인터페이스를 실행합니다. 실행하면 사용자는 '입력' 텍스트박스에 메시지를 작성하고 제출할 수 있으며, '초기화' 버튼을 통해 채팅 기록을 초기화 할 수 있습니다.
 
42
  return_source_documents=True,
43
  chain_type_kwargs=chain_type_kwargs,
44
  reduce_k_below_max_tokens=True,
45
+ verbose=False,
46
  )
47
 
48
 
 
49
  def respond(message, chat_history):
50
  result = chain(message)
 
51
  bot_message = result["answer"]
 
 
52
  chat_history.append((message, bot_message))
 
 
53
  return "", chat_history
54
 
55
 
56
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
 
57
  gr.Markdown("# 안녕하세요. 세이노와 대화해보세요.")
58
+ initial_greeting = "안녕하세요!\n저는 세이노처럼 경험과 지식을 갖춘 인공지능 ChatGPT입니다. 세이노는 사업, 경영, 투자에 대한 전문가이며, 많은 사람들이 그의 조언을 참고하고 있습니다. 어떤 도움이 필요하신가요? 세이노와 관련된 질문이 있으시면 편안하게 물어보세요!"
59
+ chatbot = gr.Chatbot(label="채팅창", value=[(None, initial_greeting)])
60
+ msg = gr.Textbox(label="입력")
61
+ clear = gr.Button("초기화")
62
 
63
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
64
+ clear.click(lambda: None, None, chatbot, queue=False)
 
 
 
 
65
 
66
+ demo.launch(debug=False)
 
 
requirements.txt CHANGED
@@ -1,6 +1,6 @@
1
  openai==0.27.8
2
- langchain==0.0.196
3
  pypdf==3.9.1
4
  chromadb==0.3.26
5
  tiktoken==0.4.0
6
- gradio==3.34.0
 
1
  openai==0.27.8
2
+ langchain==0.0.201
3
  pypdf==3.9.1
4
  chromadb==0.3.26
5
  tiktoken==0.4.0
6
+ gradio==3.35.2