Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,8 +3,9 @@ import gradio as gr
|
|
3 |
import inspect
|
4 |
from gradio import routes
|
5 |
from typing import List, Type
|
6 |
-
|
7 |
from transformers import AutoTokenizer
|
|
|
8 |
import requests, os, re, asyncio, json, time
|
9 |
|
10 |
loop = asyncio.get_event_loop()
|
@@ -38,7 +39,7 @@ model_name = "quantumaikr/llama-2-70b-fb16-korean"
|
|
38 |
#quantumaikr/llama-2-70b-fb16-korean
|
39 |
tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False)
|
40 |
|
41 |
-
|
42 |
model = AutoDistributedModelForCausalLM.from_pretrained(model_name)
|
43 |
|
44 |
history = {
|
@@ -262,12 +263,14 @@ def chat(id, npc, text):
|
|
262 |
[λνκΈ°λ‘]{history[npc][id]}
|
263 |
"""
|
264 |
|
265 |
-
inputs = tokenizer("μ", return_tensors="pt")["input_ids"]
|
266 |
-
outputs = model.generate(inputs, do_sample=True, temperature=0.6, top_p=0.75, max_new_tokens=2)
|
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 |
response = client.chat.completions.create(
|
272 |
model=os.environ['MODEL'],
|
273 |
messages=[
|
|
|
3 |
import inspect
|
4 |
from gradio import routes
|
5 |
from typing import List, Type
|
6 |
+
import torch
|
7 |
from transformers import AutoTokenizer
|
8 |
+
from petals import AutoDistributedModelForCausalLM
|
9 |
import requests, os, re, asyncio, json, time
|
10 |
|
11 |
loop = asyncio.get_event_loop()
|
|
|
39 |
#quantumaikr/llama-2-70b-fb16-korean
|
40 |
tokenizer = AutoTokenizer.from_pretrained(model_name, use_fast=False)
|
41 |
|
42 |
+
model = None
|
43 |
model = AutoDistributedModelForCausalLM.from_pretrained(model_name)
|
44 |
|
45 |
history = {
|
|
|
263 |
[λνκΈ°λ‘]{history[npc][id]}
|
264 |
"""
|
265 |
|
266 |
+
#inputs = tokenizer("μ", return_tensors="pt")["input_ids"]
|
267 |
+
#outputs = model.generate(inputs, do_sample=True, temperature=0.6, top_p=0.75, max_new_tokens=2)
|
268 |
+
#output = tokenizer.decode(outputs[0])[len(prom)+3:-1].split("<")[0].split("###")[0].replace(". ", ".\n")
|
269 |
#output = cleanText(output)
|
270 |
#print(tokenizer.decode(outputs[0]))
|
271 |
#output = f"{npc}μ μλ΅μ
λλ€."
|
272 |
+
|
273 |
+
|
274 |
response = client.chat.completions.create(
|
275 |
model=os.environ['MODEL'],
|
276 |
messages=[
|