MCPcopy
hub / github.com/stanford-oval/storm / main

Function main

examples/storm_examples/run_storm_wiki_gemini.py:40–136  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

38
39
40def main(args):
41 load_api_key(toml_file_path="secrets.toml")
42 lm_configs = STORMWikiLMConfigs()
43 gemini_kwargs = {
44 "api_key": os.getenv("GOOGLE_API_KEY"),
45 "temperature": 1.0,
46 "top_p": 0.9,
47 }
48
49 # STORM is a LM system so different components can be powered by different models.
50 # For a good balance between cost and quality, you can choose a cheaper/faster model for conv_simulator_lm
51 # which is used to split queries, synthesize answers in the conversation. We recommend using stronger models
52 # for outline_gen_lm which is responsible for organizing the collected information, and article_gen_lm
53 # which is responsible for generating sections with citations.
54 # To check out available Google models, see:
55 # https://ai.google.dev/gemini-api/docs/get-started/tutorial?lang=python#list_models
56 conv_simulator_lm = GoogleModel(
57 model="models/gemini-1.5-flash", max_tokens=500, **gemini_kwargs
58 )
59 question_asker_lm = GoogleModel(
60 model="models/gemini-1.5-flash", max_tokens=500, **gemini_kwargs
61 )
62 outline_gen_lm = GoogleModel(
63 model="models/gemini-1.5-pro-exp-0801", max_tokens=400, **gemini_kwargs
64 )
65 article_gen_lm = GoogleModel(
66 model="models/gemini-1.5-pro-exp-0801", max_tokens=700, **gemini_kwargs
67 )
68 article_polish_lm = GoogleModel(
69 model="models/gemini-1.5-pro-exp-0801", max_tokens=4000, **gemini_kwargs
70 )
71
72 lm_configs.set_conv_simulator_lm(conv_simulator_lm)
73 lm_configs.set_question_asker_lm(question_asker_lm)
74 lm_configs.set_outline_gen_lm(outline_gen_lm)
75 lm_configs.set_article_gen_lm(article_gen_lm)
76 lm_configs.set_article_polish_lm(article_polish_lm)
77
78 engine_args = STORMWikiRunnerArguments(
79 output_dir=args.output_dir,
80 max_conv_turn=args.max_conv_turn,
81 max_perspective=args.max_perspective,
82 search_top_k=args.search_top_k,
83 max_thread_num=args.max_thread_num,
84 )
85
86 # STORM is a knowledge curation system which consumes information from the retrieval module.
87 # Currently, the information source is the Internet and we use search engine API as the retrieval module.
88 match args.retriever:
89 case "bing":
90 rm = BingSearch(
91 bing_search_api=os.getenv("BING_SEARCH_API_KEY"),
92 k=engine_args.search_top_k,
93 )
94 case "you":
95 rm = YouRM(ydc_api_key=os.getenv("YDC_API_KEY"), k=engine_args.search_top_k)
96 case "brave":
97 rm = BraveRM(

Callers 1

Calls 15

set_conv_simulator_lmMethod · 0.95
set_question_asker_lmMethod · 0.95
set_outline_gen_lmMethod · 0.95
set_article_gen_lmMethod · 0.95
set_article_polish_lmMethod · 0.95
runMethod · 0.95
post_runMethod · 0.95
load_api_keyFunction · 0.90
STORMWikiLMConfigsClass · 0.90
GoogleModelClass · 0.90
BingSearchClass · 0.90

Tested by

no test coverage detected