Hugging Face Space 已安裝一些常用的 Python 第三方套件, 例如 Numpy, Pandas, Matplotlib 等等, 通常在 Gradio Playgorund 上可以順利執行的 Web app 發布到 Hugging Face Space 後應該均可順利運行, 如果出現找不到套件或模組的錯誤, 就要到 Hugging Face Space 上手動新增一個專案, 並在 requirement.txt 檔案中指定要安裝之第三方套件, 參考 :
可見傳回值是一個串列, 如果沒有指定 max_results 參數預設是最多傳回 10 筆搜尋結果. 檢視串列元素為字典, 包含 title (網頁標題), href (網址), 與 body (內容) 三個鍵 :
>>> type(results[0])
<class 'dict'>
>>> results[0]
{'title': 'LangChain', 'href': 'https://www.langchain.com/', 'body': '"Working with LangChain and LangSmith on the Elastic AI Assistant had a significant positive impact on the overall pace and quality of the development and shipping experience. We couldn\'t have achieved the product experience delivered to our customers without LangChain, and we couldn\'t have done it at the same pace without LangSmith."'}
{'date': '2025-02-12T01:22:00+00:00', 'title': 'Taiwan environment minister eyes insurance funds to help with green transition', 'body': "Taiwan aims to get more than $1.5 billion in investment from insurance funds to help finance the island's green energy transition as part of its climate change and carbon reduction goals, Environment Minister Peng Chi-ming has said.", 'url': 'https://www.reuters.com/sustainability/sustainable-finance-reporting/taiwan-environment-minister-eyes-insurance-funds-help-with-green-transition-2025-02-12/', 'image': 'https://www.reuters.com/resizer/v2/HAZKYEC4ONNSFIRMNE3YL3X5FE.jpg?auth=63a2bee4ac149ad73c2938a9370ebc61fbe9142fc0b572a4d3fac552c7f9ad93&height=1005&width=1920&quality=80&smart=true', 'source': 'Reuters'}
1. Taiwan environment minister eyes insurance funds to help with green transition:
Taiwan environment minister eyes insurance funds to help with green transition
Taiwan aims to get more than $1.5 billion in investment from insurance funds to help finance the island's green energy transition as part of its climate change and carbon reduction goals, Environment Minister Peng Chi-ming has said.
2. Taiwan looks to buy Alaskan natural gas as it seeks to head off US tariffs:
Taiwan looks to buy Alaskan natural gas as it seeks to head off US tariffs
TAIPEI (Reuters) -Taiwan is interested in natural gas from Alaska and will continue to assess the feasibility of purchases, the economy ministry said on Monday, as the government looks to narrow the trade surplus with the United States and head off tariffs.
3. Taiwan detects 62 Chinese aircraft as US ships transit waters:
Taiwan detects 62 Chinese aircraft as US ships transit waters
Taiwan said Wednesday it detected 62 Chinese military aircraft near the self-ruled island this week, as two US ships sailed through the sensitive Taiwan Strait.
4. Chinese Military Monitored US Ship Crossing Taiwan Strait, State Media Reports:
Chinese Military Monitored US Ship Crossing Taiwan Strait, State Media Reports
(Reuters) - China's military said it organised naval and air forces to monitor the navigation operations of a U.S. destroyer and oceanographic survey ship crossing the Taiwan Strait from February 10-12, according to state broadcaster CCTV on Tuesday.
5. Hope film 'Ne Zha 2' to be screened in Taiwan island as soon as possible: spokesperson:
Hope film 'Ne Zha 2' to be screened in Taiwan island as soon as possible: spokesperson
In response to heated discussions about "Ne Zha 2" on the island of Taiwan, Zhu Fenglian, spokesperson for the State Council Taiwan Affairs Office, expressed the wish on Wednesday's press conference that the film will be screened in the island as soon as possible,
{'content': 'https://www.youtube.com/watch?v=ekr2nIex040', 'description': "ROSÉ & Bruno Mars - APT. Download/stream: https://rosesarerosie.lnk.to/APTID Order APT. single CD: https://rosesarerosie.lnk.to/APT-CDID 'rosie' - the first studio album by ROSÉ - out now download/stream: http://rosesarerosie.lnk.to/rosieID ROSÉ store exclusive 'rosie' vinyl, cd's, and more available now: http://rosesarerosie.lnk.to/storeID ...", 'duration': '2:54', 'embed_html': '<iframe width="1280" height="720" src="https://www.youtube.com/embed/ekr2nIex040?autoplay=1" frameborder="0" allowfullscreen></iframe>', 'embed_url': 'https://www.youtube.com/embed/ekr2nIex040?autoplay=1', 'image_token': '0be8410e804bf8c9e7c153c4f1747a34f92023b265a805e271710c9b129f9e62', 'images': {'large': 'https://tse1.mm.bing.net/th?id=OVP.u9EjUh1N1E2_3aDLeeiQNAHgFo&pid=Api', 'medium': 'https://tse1.mm.bing.net/th?id=OVP.u9EjUh1N1E2_3aDLeeiQNAHgFo&pid=Api', 'motion': 'https://tse2.mm.bing.net/th?id=OM.cEYhVc1Do-7hdA_1731902268&pid=Api', 'small': 'https://tse1.mm.bing.net/th?id=OVP.u9EjUh1N1E2_3aDLeeiQNAHgFo&pid=Api'}, 'provider': 'Bing', 'published': '2024-10-18T04:00:07.0000000', 'publisher': 'YouTube', 'statistics': {'viewCount': 1082191568}, 'title': 'ROSÉ & Bruno Mars - APT. (Official Music Video)', 'uploader': 'ROSÉ'}
1. ROSÉ & Bruno Mars - APT. (Official Music Video):
https://www.youtube.com/watch?v=ekr2nIex040
2. ROSÉ & Bruno Mars - APT. (live from 2024 MAMA AWARDS):
https://www.youtube.com/watch?v=Jn8KvdWagfo
3. ROSÉ - APT. in the Radio 1 Live Lounge:
https://www.youtube.com/watch?v=Lwv254J8Ozk
4. APT Bruno Mars and Rosé | Learn the Viral Dance | Step-by-Step Beginner Tutorial:
https://www.youtube.com/watch?v=XxOAEpW8rPs
5. APT Bruno Mars and Rosé | Learn the Viral Dance | Practice it with Music:
https://www.youtube.com/watch?v=Cysgn9xOt-Q
7. 聊天機器人 :
呼叫 DDGS 物件的 chat() 方法並傳入提示詞會傳回一個回應字串, 例如 :
>>> prompt='Who are you?'
>>> reply=ddgs.chat(prompt)
>>> type(reply)
<class 'str'>
>>> reply
'I am an AI language model created by OpenAI, designed to assist with a wide range of questions and tasks by providing information and generating text based on the input I receive. How can I help you today?'
問它使用甚麼模型只回答 GPT-3 :
>>> prompt='Please tell me your specific model name'
>>> ddgs.chat(prompt)
"I am based on OpenAI's GPT-3 model. If you have any specific questions or need assistance, feel free to ask!"
追問它版本代號是否為 gpt-3.5-turbo, 回答 Yes :
>>> prompt='Are you using gpt-3.5-turbo?'
>>> ddgs.chat(prompt)
'Yes, I am based on the GPT-3.5-turbo model. If you have any questions or need assistance, feel free to ask!'
C:\Users\tony1\AppData\Local\Programs\Thonny\lib\site-packages\duckduckgo_search\duckduckgo_search.py:167: UserWarning: model='gpt-4o' is unavailable. Using 'gpt-4o-mini'
warnings.warn(f"{model=} is unavailable. Using 'gpt-4o-mini'", stacklevel=1)