Woocy commited on
Commit
de514fa
·
1 Parent(s): 0f6bf60

Update chat_func.py

Browse files
Files changed (1) hide show
  1. chat_func.py +17 -10
chat_func.py CHANGED
@@ -7,7 +7,6 @@ import json
7
  import os
8
  import requests
9
  import urllib3
10
- import numpy as np
11
 
12
  from tqdm import tqdm
13
  import colorama
@@ -196,8 +195,16 @@ def stream_predict(
196
  chatbot[-1] = (chatbot[-1][0], partial_words+display_append)
197
  all_token_counts[-1] += 1
198
  yield get_return_value()
199
-
200
-
 
 
 
 
 
 
 
 
201
  def predict_all(
202
  openai_api_key,
203
  system_prompt,
@@ -460,12 +467,12 @@ def reduce_token_size(
460
  user_id = os.getuid()
461
 
462
  # 将获取到的信息写入txt文件
463
- all_token_counts = 10
464
 
465
- def write_to_file(user_id, all_token_counts):
466
- log_file = "user_info.txt"
467
- log_str = f"{user_id}\t{all_token_counts}\n"
468
- with open(log_file, 'a') as f:
469
- f.write(log_str)
470
 
471
- write_to_file(user_id,all_token_counts)
 
7
  import os
8
  import requests
9
  import urllib3
 
10
 
11
  from tqdm import tqdm
12
  import colorama
 
195
  chatbot[-1] = (chatbot[-1][0], partial_words+display_append)
196
  all_token_counts[-1] += 1
197
  yield get_return_value()
198
+ return all_token_counts
199
+
200
+ def main():
201
+ # 调用stream_predict函数获取结果...
202
+ with open("token_counts.txt", "a") as f:
203
+ for token_count in all_token_counts:
204
+ f.write(str(token_count) + "\n")
205
+ if __name__ == '__main__':
206
+ main()
207
+
208
  def predict_all(
209
  openai_api_key,
210
  system_prompt,
 
467
  user_id = os.getuid()
468
 
469
  # 将获取到的信息写入txt文件
470
+ #all_token_counts = 10
471
 
472
+ #def write_to_file(user_id, all_token_counts):
473
+ # log_file = "user_info.txt"
474
+ # log_str = f"{user_id}\t{all_token_counts}\n"
475
+ # with open(log_file, 'a') as f:
476
+ # f.write(log_str)
477
 
478
+ #write_to_file(user_id,all_token_counts)