File tree Expand file tree Collapse file tree 3 files changed +7
-27
lines changed
examples/costorm_examples Expand file tree Collapse file tree 3 files changed +7
-27
lines changed Original file line number Diff line number Diff line change @@ -255,7 +255,7 @@ python examples/storm_examples/run_storm_wiki_gpt.py \
255255
256256To run Co-STORM with ` gpt` family models with default configurations,
257257
258- 1. Add ` BING_SEARCH_API_KEY=" xxx" ` to ` secrets.toml`
258+ 1. Add ` BING_SEARCH_API_KEY=" xxx" ` and ` ENCODER_API_TYPE= " xxx " ` to ` secrets.toml`
2592592. Run the following command
260260
261261` ` ` bash
Original file line number Diff line number Diff line change @@ -143,6 +143,11 @@ def main(args):
143143 with open (os .path .join (args .output_dir , "report.md" ), "w" ) as f :
144144 f .write (article )
145145
146+ # Save instance dump
147+ instance_copy = costorm_runner .to_dict ()
148+ with open (os .path .join (args .output_dir , "instance_dump.json" ), "w" ) as f :
149+ json .dump (instance_copy , f , indent = 2 )
150+
146151 # Save logging
147152 log_dump = costorm_runner .dump_logging_and_reset ()
148153 with open (os .path .join (args .output_dir , "log.json" ), "w" ) as f :
Original file line number Diff line number Diff line change 77
88
99class EmbeddingModel :
10- def __init__ ():
10+ def __init__ (self ):
1111 pass
1212
1313 def get_embedding (self , text : str ) -> Tuple [np .ndarray , int ]:
1414 raise Exception ("Not implemented" )
1515
1616
17- class OpenAIEmbeddingModel (EmbeddingModel ):
18- def __init__ (self , model : str = "text-embedding-3-small" , api_key : str = None ):
19- if not api_key :
20- self .api_key = os .getenv ("OPENAI_API_KEY" )
21-
22- self .url = "https://api.openai.com/v1/embeddings"
23- self .headers = {
24- "Content-Type" : "application/json" ,
25- "Authorization" : f"Bearer { self .api_key } " ,
26- }
27- self .model = model
28-
29- def get_embedding (self , text : str ) -> Tuple [np .ndarray , int ]:
30- data = {"input" : text , "model" : "text-embedding-3-small" }
31-
32- response = requests .post (self .url , headers = self .headers , json = data )
33- if response .status_code == 200 :
34- data = response .json ()
35- embedding = np .array (data ["data" ][0 ]["embedding" ])
36- token = data ["usage" ]["prompt_tokens" ]
37- return embedding , token
38- else :
39- response .raise_for_status ()
40-
41-
4217class OpenAIEmbeddingModel (EmbeddingModel ):
4318 def __init__ (self , model : str = "text-embedding-3-small" , api_key : str = None ):
4419 if not api_key :
You can’t perform that action at this time.
0 commit comments