Просмотр исходного кода

Update run_infer.py of gorilla to download my-languages.so (#3286)

* Update run_infer.py of gorilla to download my-languages.so

* add exist check, change file path, lint code

---------

Co-authored-by: Graham Neubig <neubig@gmail.com>
Co-authored-by: yufansong <yufan@risingwave-labs.com>
yueqis 1 год назад
Родитель
Сommit
9757f362bf
1 измененных файлов с 11 добавлено и 0 удалено
  1. 11 0
      evaluation/gorilla/run_infer.py

+ 11 - 0
evaluation/gorilla/run_infer.py

@@ -3,6 +3,7 @@ import json
 import os
 import os
 
 
 import pandas as pd
 import pandas as pd
+import requests
 
 
 from evaluation.gorilla.utils import encode_question, get_data_for_hub
 from evaluation.gorilla.utils import encode_question, get_data_for_hub
 from evaluation.utils.shared import (
 from evaluation.utils.shared import (
@@ -168,6 +169,16 @@ if __name__ == '__main__':
         dataset_df, output_file=output_file, eval_n_limit=args.eval_n_limit
         dataset_df, output_file=output_file, eval_n_limit=args.eval_n_limit
     )
     )
 
 
+    file_path = os.path.join(os.path.dirname(__file__), 'my-languages.so')
+    # Check if the file exists
+    if not os.path.exists(file_path):
+        url = 'https://raw.githubusercontent.com/ShishirPatil/gorilla/main/eval/eval-scripts/codebleu/parser/my-languages.so'
+        response = requests.get(url)
+        with open(file_path, 'wb') as f:
+            f.write(response.content)
+    else:
+        print('File already exists, skipping download.')
+
     asyncio.run(
     asyncio.run(
         run_evaluation(
         run_evaluation(
             dataset=dataset,
             dataset=dataset,