chansung commited on
Commit
179ea72
1 Parent(s): 00fe5d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -23
app.py CHANGED
@@ -109,33 +109,35 @@ async def rollback_last(
109
  res[idx].pingpongs = res[idx].pingpongs[:-1]
110
 
111
  ppm.add_pingpong(
112
- PingPong(last_user_message, "")
113
- )
114
  prompt = build_prompts(ppm, global_context, ctx_num_lconv)
 
115
 
116
  #######
117
- if internet_option:
118
- search_prompt = None
119
- for tmp_prompt, uis in internet_search(ppm, serper_api_key, global_context, ctx_num_lconv):
120
- search_prompt = tmp_prompt
121
- yield prompt, uis, str(res), gr.update(interactive=False), "off"
 
 
 
 
 
 
 
 
122
 
123
- async for result in gen_text(
124
- search_prompt if internet_option else prompt,
125
- hf_model=MODEL_ID, hf_token=TOKEN,
126
- parameters={
127
- 'max_new_tokens': res_mnts,
128
- 'do_sample': res_sample,
129
- 'return_full_text': False,
130
- 'temperature': res_temp,
131
- 'top_k': res_topk,
132
- 'repetition_penalty': res_rpen
133
- }
134
- ):
135
- ppm.append_pong(result)
136
- yield prompt, ppm.build_uis(), str(res), gr.update(interactive=False), "off"
137
-
138
- yield prompt, ppm.build_uis(), str(res), gr.update(interactive=True), "off"
139
 
140
  def reset_chat(idx, ld, state, palm_if):
141
  res = [state["ppmanager_type"].from_json(json.dumps(ppm_str)) for ppm_str in ld]
 
109
  res[idx].pingpongs = res[idx].pingpongs[:-1]
110
 
111
  ppm.add_pingpong(
112
+ PingPong(last_user_message, '')
113
+ )
114
  prompt = build_prompts(ppm, global_context, ctx_num_lconv)
115
+ print(prompt)
116
 
117
  #######
118
+ # if internet_option:
119
+ # search_prompt = None
120
+ # for tmp_prompt, uis in internet_search(ppm, serper_api_key, global_context, ctx_num_lconv):
121
+ # search_prompt = tmp_prompt
122
+ # yield "", prompt, uis, str(res), gr.update(interactive=False), "off"
123
+
124
+ parameters = {
125
+ # 'model': 'models/text-bison-001',
126
+ 'candidate_count': 1,
127
+ 'temperature': res_temp,
128
+ 'top_k': res_topk,
129
+ 'top_p': res_topp,
130
+ }
131
 
132
+ palm_if, response_txt = gen_text(
133
+ prompt,
134
+ parameters=parameters
135
+ )
136
+
137
+ ppm = res[idx]
138
+ ppm.replace_last_pong(response_txt)
139
+
140
+ return "", "", ppm.build_uis(), str(res), gr.update(interactive=True), "off"
 
 
 
 
 
 
 
141
 
142
  def reset_chat(idx, ld, state, palm_if):
143
  res = [state["ppmanager_type"].from_json(json.dumps(ppm_str)) for ppm_str in ld]