kh-CHEUNG commited on
Commit
4ceb202
1 Parent(s): 7e06467

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -32
app.py CHANGED
@@ -75,7 +75,7 @@ def respond(
75
  system_message,
76
  max_tokens,
77
  temperature,
78
- top_p
79
  ):
80
 
81
  messages = [{"role": "system", "content": system_message}]
@@ -88,37 +88,6 @@ def respond(
88
 
89
  messages.append({"role": "user", "content": message})
90
 
91
- """
92
- input_ids = tokenizer.apply_chat_template(
93
- messages,
94
- add_generation_prompt=True,
95
- return_tensors="pt"
96
- ).to(model.device)
97
-
98
- streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
99
-
100
- generate_kwargs = dict(
101
- input_ids= input_ids,
102
- streamer=streamer,
103
- max_new_tokens=max_new_tokens,
104
- do_sample=True,
105
- temperature=temperature,
106
- eos_token_id=terminators,
107
- )
108
- # This will enforce greedy generation (do_sample=False) when the temperature is passed 0, avoiding the crash.
109
- if temperature == 0:
110
- generate_kwargs['do_sample'] = False
111
-
112
- t = Thread(target=model.generate, kwargs=generate_kwargs)
113
- t.start()
114
-
115
- outputs = []
116
- for text in streamer:
117
- outputs.append(text)
118
- #print(outputs)
119
- yield "".join(outputs)
120
- """
121
-
122
  response = ""
123
 
124
  for message in client.chat_completion(
 
75
  system_message,
76
  max_tokens,
77
  temperature,
78
+ top_p,
79
  ):
80
 
81
  messages = [{"role": "system", "content": system_message}]
 
88
 
89
  messages.append({"role": "user", "content": message})
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  response = ""
92
 
93
  for message in client.chat_completion(