acecalisto3 commited on
Commit
da91794
·
verified ·
1 Parent(s): f9720b9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -43
app.py CHANGED
@@ -12,49 +12,7 @@ import atexit
12
  import subprocess
13
  from urllib.parse import urlparse, quote
14
  import webbrowser
15
- import spaces
16
-
17
- device = "cuda"
18
-
19
- @spaces.GPU()
20
- def stream_chat(
21
- message: str,
22
- history: list,
23
- system_prompt: str,
24
- temperature: float = 0.5,
25
- max_new_tokens: int = 16000,
26
- top_p: float = 1.0,
27
- top_k: int = 15,
28
- penalty: float = 0.9,
29
- ):
30
- print(f'message: {message}')
31
- print(f'history: {history}')
32
-
33
- conversation = [
34
- {"role": "system", "content": system_prompt}
35
- ]
36
- for prompt, answer in history:
37
- conversation.extend([
38
- {"role": "user", "content": prompt},
39
- {"role": "assistant", "content": answer},
40
- ])
41
-
42
- conversation.append({"role": "user", "content": message})
43
-
44
- input_ids = tokenizer.apply_chat_template(conversation, add_generation_prompt=True, return_tensors="pt").to(model.device)
45
-
46
- streamer = TextIteratorStreamer(tokenizer, timeout=60.0, skip_prompt=True, skip_special_tokens=True)
47
-
48
- generate_kwargs = dict(
49
- input_ids=input_ids,
50
- max_new_tokens = max_new_tokens,
51
- do_sample = False if temperature == 0 else True,
52
- top_p = top_p,
53
- top_k = top_k,
54
- temperature = temperature,
55
- eos_token_id=[128001,128008,128009],
56
- streamer=streamer,
57
- )
58
  # Constants
59
  INPUT_DIRECTORY = 'input'
60
  OUTPUT_DIRECTORY = 'output'
@@ -163,6 +121,7 @@ class GitHubBot:
163
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
164
  resolution_file = f"{RESOLUTIONS_DIRECTORY}/resolution_{issue_number}_{timestamp}.md"
165
 
 
166
  with open(resolution_file, "w") as f:
167
  f.write(f"# Resolution for Issue #{issue_number}\n\n{resolution}")
168
 
 
12
  import subprocess
13
  from urllib.parse import urlparse, quote
14
  import webbrowser
15
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  # Constants
17
  INPUT_DIRECTORY = 'input'
18
  OUTPUT_DIRECTORY = 'output'
 
121
  timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
122
  resolution_file = f"{RESOLUTIONS_DIRECTORY}/resolution_{issue_number}_{timestamp}.md"
123
 
124
+ ```python
125
  with open(resolution_file, "w") as f:
126
  f.write(f"# Resolution for Issue #{issue_number}\n\n{resolution}")
127