import os import sys from aimodel import aimodel, aimodel_wrapper from article_list import article, article_list from fetch_exper_data import download_xml, read_xml_from_file, xml_dict_to_article_list def main(): url_root = os.getenv("RSSHUB_ROOT") assert url_root is not None api_key = os.getenv("GEMINI_API_KEY") assert api_key is not None model = aimodel(api_key) wrapper = aimodel_wrapper(model) url = url_root + "/yicai/brief" filename = "exper/raw/yicai.brief.xml" download_xml(url=url, path=filename) xml_dict = read_xml_from_file(filename) article_list = xml_dict_to_article_list( xml_dict, ["rss", "channel", "item"], ["title", "description"] ) for i in range(0, len(article_list.list)): article_list.list[i].replace_keywords( wrapper.content_to_5_keywords(article_list.list[i].get_content(), "ZH") ) print(str(article_list)) if __name__ == "__main__": main()