Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -181,8 +181,6 @@ Slender๋ ๋ง์ ํ์ง ๋ชปํฉ๋๋ค.
|
|
181 |
}
|
182 |
|
183 |
|
184 |
-
from openai import OpenAI
|
185 |
-
client = OpenAI()
|
186 |
def cleanText(readData):
|
187 |
|
188 |
#ํ
์คํธ์ ํฌํจ๋์ด ์๋ ํน์ ๋ฌธ์ ์ ๊ฑฐ
|
@@ -264,25 +262,14 @@ def chat(id, npc, text):
|
|
264 |
|
265 |
"""
|
266 |
|
267 |
-
inputs = tokenizer("
|
268 |
-
outputs = model.generate(inputs, do_sample=True, temperature=0.
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
#output = f"{npc}์ ์๋ต์
๋๋ค."
|
273 |
|
274 |
-
|
275 |
-
response = client.chat.completions.create(
|
276 |
-
model=os.environ['MODEL'],
|
277 |
-
messages=[
|
278 |
-
{"role": "system", "content": prom},
|
279 |
-
{"role": "user", "content": f"{npc}์ ๋๋ต์ ๋ค์ ๋ฌธ์ฅ์ ๋ง์ถฐ ์์ฐ์ค๋ฝ๊ฒ ์์ฑํด์ฃผ์ธ์. ํ ๋ฌธ์ฅ๋ง ์์ฑํ์ธ์.\n\n{id}:" + text+f"\n\n{npc}:"},
|
280 |
-
]
|
281 |
-
)
|
282 |
-
output = response.choices[0].message.content
|
283 |
-
output = output.replace(".",".\n")
|
284 |
-
time.sleep(10)
|
285 |
-
print(output)
|
286 |
history[npc][id] += f"{id}:{text}"
|
287 |
else:
|
288 |
output = "no model, GPU๋ฅผ ๋ ๊ณต์ ํด์ฃผ์ธ์."
|
|
|
181 |
}
|
182 |
|
183 |
|
|
|
|
|
184 |
def cleanText(readData):
|
185 |
|
186 |
#ํ
์คํธ์ ํฌํจ๋์ด ์๋ ํน์ ๋ฌธ์ ์ ๊ฑฐ
|
|
|
262 |
|
263 |
"""
|
264 |
|
265 |
+
inputs = tokenizer(prom+f"{npc}์ ๋๋ต์ ๋ค์ ๋ฌธ์ฅ์ ๋ง์ถฐ ์์ฐ์ค๋ฝ๊ฒ ์์ฑํด์ฃผ์ธ์. ํ ๋ฌธ์ฅ๋ง ์์ฑํ์ธ์.\n\n{id}:" + text+f"\n\n{npc}:"},, return_tensors="pt")["input_ids"]
|
266 |
+
outputs = model.generate(inputs, do_sample=True, temperature=0.8, top_p=0.75, max_new_tokens=200)
|
267 |
+
output = tokenizer.decode(outputs[0])[len(prom)+3:-1].split("<")[0].split("###")[0].replace(". ", ".\n")
|
268 |
+
output = cleanText(output)
|
269 |
+
print(tokenizer.decode(outputs[0]))
|
270 |
#output = f"{npc}์ ์๋ต์
๋๋ค."
|
271 |
|
272 |
+
#print(output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
history[npc][id] += f"{id}:{text}"
|
274 |
else:
|
275 |
output = "no model, GPU๋ฅผ ๋ ๊ณต์ ํด์ฃผ์ธ์."
|