seawolf2357 commited on
Commit
589e1a2
·
verified ·
1 Parent(s): 666dba6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -13
app.py CHANGED
@@ -73,27 +73,30 @@ def generate(prompt, history=[], temperature=0.1, max_new_tokens=10000, top_p=0.
73
  except Exception as e:
74
  yield f"Error: {str(e)}\nTotal tokens used: {total_tokens_used}"
75
 
76
- # 기존의 채팅 인터페이스에 티커 입력 기능을 통합
77
  def setup_interface():
78
  with gr.Blocks() as demo:
79
  gr.Markdown("### 글로벌 자산(주식,지수,상품,가상자산,외환 등) 분석 LLM: BloombAI")
80
 
81
  with gr.Row():
82
- ticker_input = gr.Textbox(label="티커 입력", placeholder="예: AAPL", elem_id="ticker_input")
83
- submit_button = gr.Button("조회", elem_id="submit_button")
84
 
85
  chatbot = gr.Chatbot(
86
  avatar_images=["./user.png", "./botm.png"],
87
  bubble_full_width=False,
88
  show_label=False,
89
  show_copy_button=True,
90
- likeable=True,
91
- elem_id="chatbot_area"
92
  )
93
 
94
- # 결과를 채팅 인터페이스에 출력하도록 설정
 
 
 
 
95
  submit_button.click(
96
- fn=lambda x: f"티커 '{x}'의 정보 조회 결과:\n\n{fetch_ticker_info(x)}",
97
  inputs=ticker_input,
98
  outputs=chatbot
99
  )
@@ -105,12 +108,8 @@ def setup_interface():
105
  ["추천 종목 알려줘", []],
106
  ["그 종목 투자 전망 예측해", []]
107
  ]
108
- chatbot.update(
109
- fn=generate,
110
- inputs=[gr.Textbox(label="메시지 입력", elem_id="message_input")],
111
- outputs=chatbot,
112
- examples=examples
113
- )
114
 
115
  return demo
116
 
 
73
  except Exception as e:
74
  yield f"Error: {str(e)}\nTotal tokens used: {total_tokens_used}"
75
 
76
+
77
  def setup_interface():
78
  with gr.Blocks() as demo:
79
  gr.Markdown("### 글로벌 자산(주식,지수,상품,가상자산,외환 등) 분석 LLM: BloombAI")
80
 
81
  with gr.Row():
82
+ ticker_input = gr.Textbox(label="티커 입력", placeholder="예: AAPL")
83
+ submit_button = gr.Button("조회")
84
 
85
  chatbot = gr.Chatbot(
86
  avatar_images=["./user.png", "./botm.png"],
87
  bubble_full_width=False,
88
  show_label=False,
89
  show_copy_button=True,
90
+ likeable=True
 
91
  )
92
 
93
+ # 버튼 클릭 이벤트를 통해 티커 정보를 채팅 창에 직접 출력
94
+ def query_and_show(ticker):
95
+ info = fetch_ticker_info(ticker)
96
+ return [("", f"티커 '{ticker}'의 정보 조회 결과:\n\n{info}")] # 첫번째 항목은 사용자 메시지, 두번째는 봇의 응답
97
+
98
  submit_button.click(
99
+ fn=query_and_show,
100
  inputs=ticker_input,
101
  outputs=chatbot
102
  )
 
108
  ["추천 종목 알려줘", []],
109
  ["그 종목 투자 전망 예측해", []]
110
  ]
111
+
112
+ chatbot.add_message("환영합니다! 어떤 주식 정보가 궁금하신가요?")
 
 
 
 
113
 
114
  return demo
115