ldhldh commited on
Commit
663d215
β€’
1 Parent(s): 7c1c950

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
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
- from petals import AutoDistributedModelForCausalLM
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
- #model = None
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=[