Spaces:
Running
on
Zero
Running
on
Zero
import yfinance as yf | |
# μμ μ ν μΉ΄νλ‘κ·Έ | |
product_catalog = { | |
"807ZPKBL9V": "SuperWidget", | |
"1234567890": "MegaGadget" | |
} | |
def get_product_name_by_PID(PID: str) -> str: | |
""" | |
Finds the name of a product by its Product ID | |
""" | |
return product_catalog.get(PID, "Unknown product") | |
def get_stock_price(ticker: str) -> float: | |
""" | |
Retrieves the latest stock price for a given ticker using yfinance. | |
""" | |
stock = yf.Ticker(ticker) | |
data = stock.history(period="1d") | |
if not data.empty: | |
return data['Close'].iloc[-1] | |
return float('nan') | |
# ============================== | |
# (New) YouTube λμμ κ²μ ν¨μ | |
# ============================== | |
def search_youtube(query: str) -> str: | |
""" | |
Searches YouTube for the given query and returns a short list of video titles/links. | |
Actual implementation could use YouTube Data API or 'youtube-search-python'. | |
Here we mock the result for demonstration. | |
""" | |
# μ€μ μμ (youtube-search-python μ¬μ© μ): | |
# from youtubesearchpython import VideosSearch | |
# videosSearch = VideosSearch(query, limit=3) | |
# results = videosSearch.result()['result'] | |
# formatted = [] | |
# for item in results: | |
# title = item['title'] | |
# link = item['link'] | |
# formatted.append(f"{title} - {link}") | |
# return "\n".join(formatted) | |
# -- λ°λͺ¨μ© λλ―Έ κ²°κ³Ό -- | |
return ( | |
"[Demo Video](https://www.youtube.com/watch?v=JzjR5LGOvqg)\n" | |
) |