seawolf2357 commited on
Commit
58e1790
·
verified ·
1 Parent(s): d924726

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -1
app.py CHANGED
@@ -72,10 +72,30 @@ def generate(prompt, history=[], temperature=0.1, max_new_tokens=10000, top_p=0.
72
  for response in stream:
73
  output_part = response['generated_text'] if 'generated_text' in response else str(response)
74
  output_accumulated += output_part
75
- yield output_accumulated + f"\n\n---\nTotal tokens used: {total_tokens_used}"
76
  except Exception as e:
77
  yield f"Error: {str(e)}\nTotal tokens used: {total_tokens_used}"
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  mychatbot = gr.Chatbot(
80
  avatar_images=["./user.png", "./botm.png"],
81
  bubble_full_width=False,
 
72
  for response in stream:
73
  output_part = response['generated_text'] if 'generated_text' in response else str(response)
74
  output_accumulated += output_part
75
+ yield process_financial_data(output_part) + f"\n\n---\nTotal tokens used: {total_tokens_used}"
76
  except Exception as e:
77
  yield f"Error: {str(e)}\nTotal tokens used: {total_tokens_used}"
78
 
79
+ def process_financial_data(ticker):
80
+ stock = yf.Ticker(ticker)
81
+ real_time_price = stock.history(period="1d") # 실시간 주식 가격
82
+ stock_info = stock.info # 주식 정보
83
+ financial_data = stock.history(period="max") # 주식 데이터 다운로드 및 분석
84
+ financials = stock.financials # 재무제표 다운로드 및 분석
85
+ sector_data = stock.sustainability # 섹터 및 산업 데이터 조회
86
+ news_links = stock.news # 최신 뉴스 조회
87
+
88
+ # 간단한 출력 형식 정리
89
+ return f"""**실시간 주식 가격**: {real_time_price.tail(1)}
90
+ **기본 주식 정보**: {stock_info['longName']} ({stock_info['sector']})
91
+ **재무 데이터 (최근 5일)**: {financial_data.tail(5)}
92
+ **재무제표**: {financials.head()}
93
+ **섹터 및 산업 데이터**: {sector_data}
94
+ **최신 뉴스 링크**: {news_links}
95
+ """
96
+
97
+
98
+
99
  mychatbot = gr.Chatbot(
100
  avatar_images=["./user.png", "./botm.png"],
101
  bubble_full_width=False,