pseudotensor commited on
Commit
1e6e9f4
1 Parent(s): 0539589

Update with h2oGPT hash e195e9bfebca2b11ee3334c10df5997816cf7d6f

Browse files
generate.py CHANGED
@@ -276,8 +276,8 @@ def main(
276
 
277
  # allow set token directly
278
  use_auth_token = os.environ.get("HUGGINGFACE_API_TOKEN", use_auth_token)
279
- allow_upload_to_user_data = bool(int(os.environ.get("allow_upload_to_user_data", allow_upload_to_user_data)))
280
- allow_upload_to_my_data = bool(int(os.environ.get("allow_upload_to_my_data", allow_upload_to_my_data)))
281
  height = int(os.environ.get("HEIGHT", height))
282
  h2ocolors = bool(int(os.getenv('h2ocolors', h2ocolors)))
283
 
@@ -322,8 +322,8 @@ def main(
322
  if score_model == 'None' or score_model is None:
323
  score_model = ''
324
  concurrency_count = int(os.getenv('CONCURRENCY_COUNT', concurrency_count))
325
- api_open = bool(int(os.getenv('API_OPEN', api_open)))
326
- allow_api = bool(int(os.getenv('ALLOW_API', allow_api)))
327
 
328
  n_gpus = torch.cuda.device_count() if torch.cuda.is_available else 0
329
  if n_gpus == 0:
 
276
 
277
  # allow set token directly
278
  use_auth_token = os.environ.get("HUGGINGFACE_API_TOKEN", use_auth_token)
279
+ allow_upload_to_user_data = bool(int(os.environ.get("allow_upload_to_user_data", str(int(allow_upload_to_user_data)))))
280
+ allow_upload_to_my_data = bool(int(os.environ.get("allow_upload_to_my_data", str(int(allow_upload_to_my_data)))))
281
  height = int(os.environ.get("HEIGHT", height))
282
  h2ocolors = bool(int(os.getenv('h2ocolors', h2ocolors)))
283
 
 
322
  if score_model == 'None' or score_model is None:
323
  score_model = ''
324
  concurrency_count = int(os.getenv('CONCURRENCY_COUNT', concurrency_count))
325
+ api_open = bool(int(os.getenv('API_OPEN', str(int(api_open)))))
326
+ allow_api = bool(int(os.getenv('ALLOW_API', str(int(allow_api)))))
327
 
328
  n_gpus = torch.cuda.device_count() if torch.cuda.is_available else 0
329
  if n_gpus == 0:
gradio_runner.py CHANGED
@@ -46,6 +46,17 @@ from generate import get_model, languages_covered, evaluate, eval_func_param_nam
46
  from apscheduler.schedulers.background import BackgroundScheduler
47
 
48
 
 
 
 
 
 
 
 
 
 
 
 
49
  def go_gradio(**kwargs):
50
  allow_api = kwargs['allow_api']
51
  is_public = kwargs['is_public']
@@ -770,7 +781,7 @@ def go_gradio(**kwargs):
770
 
771
  def evaluate_gradio(*args1, **kwargs1):
772
  for res_dict in evaluate(*args1, **kwargs1):
773
- yield '<br>' + res_dict['response'].replace("\n", "<br>")
774
 
775
  fun = partial(evaluate_gradio,
776
  **kwargs_evaluate)
@@ -926,8 +937,7 @@ def go_gradio(**kwargs):
926
  # e.g. when user just hits enter in textbox,
927
  # else will have <human>: <bot>: on single line, which seems to be "ok" for LLM but not usual
928
  user_message1 = '\n'
929
- # ensure good visually, else markdown ignores multiple \n
930
- user_message1 = user_message1.replace('\n', '<br>')
931
 
932
  history = args_list[-1]
933
  if undo and history:
@@ -1052,7 +1062,7 @@ def go_gradio(**kwargs):
1052
  output = output_fun['response']
1053
  extra = output_fun['sources'] # FIXME: can show sources in separate text box etc.
1054
  # ensure good visually, else markdown ignores multiple \n
1055
- bot_message = output.replace('\n', '<br>')
1056
  history[-1][1] = bot_message
1057
  yield history, ''
1058
  except StopIteration:
 
46
  from apscheduler.schedulers.background import BackgroundScheduler
47
 
48
 
49
+ def fix_newlines(text):
50
+ # ensure good visually, else markdown ignores multiple \n
51
+ # handle code blocks
52
+ ts = text.split('```')
53
+ for parti, part in enumerate(ts):
54
+ inside = parti % 2 == 1
55
+ if not inside:
56
+ ts[parti] = ts[parti].replace('\n', '<br>')
57
+ return '```'.join(ts)
58
+
59
+
60
  def go_gradio(**kwargs):
61
  allow_api = kwargs['allow_api']
62
  is_public = kwargs['is_public']
 
781
 
782
  def evaluate_gradio(*args1, **kwargs1):
783
  for res_dict in evaluate(*args1, **kwargs1):
784
+ yield '<br>' + fix_newlines(res_dict['response'])
785
 
786
  fun = partial(evaluate_gradio,
787
  **kwargs_evaluate)
 
937
  # e.g. when user just hits enter in textbox,
938
  # else will have <human>: <bot>: on single line, which seems to be "ok" for LLM but not usual
939
  user_message1 = '\n'
940
+ user_message1 = fix_newlines(user_message1)
 
941
 
942
  history = args_list[-1]
943
  if undo and history:
 
1062
  output = output_fun['response']
1063
  extra = output_fun['sources'] # FIXME: can show sources in separate text box etc.
1064
  # ensure good visually, else markdown ignores multiple \n
1065
+ bot_message = fix_newlines(output)
1066
  history[-1][1] = bot_message
1067
  yield history, ''
1068
  except StopIteration:
gradio_ui/__pycache__/css.cpython-310.pyc ADDED
Binary file (1.48 kB). View file
 
gradio_ui/__pycache__/prompt_form.cpython-310.pyc ADDED
Binary file (1.06 kB). View file
 
prompter.py CHANGED
@@ -36,8 +36,12 @@ prompt_type_to_model_name = {
36
  'h2oai/h2ogpt-gm-oasst1-en-2048-open-llama-7b-preview-300bt',
37
  'h2oai/h2ogpt-gm-oasst1-en-2048-open-llama-7b-preview-300bt-v2',
38
  'h2oai/h2ogpt-gm-oasst1-en-2048-open-llama-7b-preview-700bt',
 
39
  'h2oai/h2ogpt-gm-oasst1-multilang-2048-falcon-7b',
40
  'h2oai/h2ogpt-gm-oasst1-multilang-2048-falcon-7b-v2',
 
 
 
41
  ],
42
  'instruct': [],
43
  'instruct_with_end': ['databricks/dolly-v2-12b'],
 
36
  'h2oai/h2ogpt-gm-oasst1-en-2048-open-llama-7b-preview-300bt',
37
  'h2oai/h2ogpt-gm-oasst1-en-2048-open-llama-7b-preview-300bt-v2',
38
  'h2oai/h2ogpt-gm-oasst1-en-2048-open-llama-7b-preview-700bt',
39
+ 'h2oai/h2ogpt-gm-oasst1-en-2048-open-llama-7b',
40
  'h2oai/h2ogpt-gm-oasst1-multilang-2048-falcon-7b',
41
  'h2oai/h2ogpt-gm-oasst1-multilang-2048-falcon-7b-v2',
42
+ 'h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b',
43
+ 'h2oai/h2ogpt-gm-oasst1-en-2048-falcon-7b-v2',
44
+ 'h2oai/h2ogpt-gm-oasst1-en-2048-falcon-40b-v1',
45
  ],
46
  'instruct': [],
47
  'instruct_with_end': ['databricks/dolly-v2-12b'],
requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
  # for generate (gradio server) and finetune
2
  datasets==2.12.0
3
  sentencepiece==0.1.97
4
- gradio==3.31.0
5
  huggingface_hub==0.14.1
6
  appdirs==1.4.4
7
  fire==0.5.0
@@ -35,7 +35,7 @@ tensorboard==2.12.1
35
  neptune==1.1.1
36
 
37
  # for gradio client
38
- gradio_client==0.2.5
39
  beautifulsoup4==4.12.2
40
  markdown==3.4.1
41
 
@@ -101,7 +101,8 @@ tabulate==0.9.0
101
  pip-licenses==4.3.0
102
 
103
  # weaviate vector db
104
- weaviate-client==3.19.2# optional for chat with PDF
 
105
  langchain==0.0.193
106
  pypdf==3.8.1
107
  tiktoken==0.3.3
@@ -145,7 +146,8 @@ tabulate==0.9.0
145
  pip-licenses==4.3.0
146
 
147
  # weaviate vector db
148
- weaviate-client==3.19.2faiss-gpu==1.7.2
 
149
  gpt4all==0.2.3
150
  llama-cpp-python==0.1.55
151
  arxiv==1.4.7
 
1
  # for generate (gradio server) and finetune
2
  datasets==2.12.0
3
  sentencepiece==0.1.97
4
+ gradio==3.34.0
5
  huggingface_hub==0.14.1
6
  appdirs==1.4.4
7
  fire==0.5.0
 
35
  neptune==1.1.1
36
 
37
  # for gradio client
38
+ gradio_client==0.2.6
39
  beautifulsoup4==4.12.2
40
  markdown==3.4.1
41
 
 
101
  pip-licenses==4.3.0
102
 
103
  # weaviate vector db
104
+ weaviate-client==3.19.2
105
+ # optional for chat with PDF
106
  langchain==0.0.193
107
  pypdf==3.8.1
108
  tiktoken==0.3.3
 
146
  pip-licenses==4.3.0
147
 
148
  # weaviate vector db
149
+ weaviate-client==3.19.2
150
+ faiss-gpu==1.7.2
151
  gpt4all==0.2.3
152
  llama-cpp-python==0.1.55
153
  arxiv==1.4.7