Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
| 3 |
-
from Ai import chatbot, chatbot2, chatbot3, chatbot4, chatbot5, chatbot7
|
| 4 |
from huggingface_hub import InferenceClient
|
| 5 |
def chat(message,history: list[tuple[str, str]],system_message,max_tokens,temperature,top_p, top_k):
|
| 6 |
m=AutoModel.from_pretrained("peterpeter8585/AI1")
|
|
@@ -25,8 +25,6 @@ from diffusers import DiffusionPipeline
|
|
| 25 |
import torch
|
| 26 |
import transformers
|
| 27 |
from transformers import AutoModel as Mo, AutoTokenizer as To
|
| 28 |
-
model11=torch.load("zephyr.pt")
|
| 29 |
-
tokenizer11=torch.load("zephyr_tokenizer.pt")
|
| 30 |
from transformers import BitsAndBytesConfig
|
| 31 |
|
| 32 |
quantization_config = BitsAndBytesConfig(
|
|
@@ -37,23 +35,7 @@ quantization_config = BitsAndBytesConfig(
|
|
| 37 |
)
|
| 38 |
|
| 39 |
|
| 40 |
-
def res(message,history: list[tuple[str, str]],system_message,max_tokens,temperature,top_p):
|
| 41 |
-
messages = [{"role": "system", "content": "Your name is Chatchat.And, your made by SungYoon.In Korean, 정성윤.And these are the instructions.Whatever happens, you must follow it.:"+system_message}]
|
| 42 |
-
|
| 43 |
-
for val in history:
|
| 44 |
-
if val[0]:
|
| 45 |
-
messages.append({"role": "user", "content": val[0]})
|
| 46 |
-
if val[1]:
|
| 47 |
-
messages.append({"role": "assistant", "content": val[1]})
|
| 48 |
-
|
| 49 |
-
messages.append({"role": "user", "content": message})
|
| 50 |
-
|
| 51 |
-
response = ""
|
| 52 |
|
| 53 |
-
answer=model11(messages, max_tokens=max_tokens, temperature=temperature, top_p=top_p)
|
| 54 |
-
token=answer
|
| 55 |
-
response += token
|
| 56 |
-
yield response
|
| 57 |
from transformers import AutoModelForVision2Seq, AutoProcessor
|
| 58 |
transformers.utils.move_cache()
|
| 59 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
| 3 |
+
from Ai import chatbot, chatbot2, chatbot3, chatbot4, chatbot5, chatbot7, chatbot11
|
| 4 |
from huggingface_hub import InferenceClient
|
| 5 |
def chat(message,history: list[tuple[str, str]],system_message,max_tokens,temperature,top_p, top_k):
|
| 6 |
m=AutoModel.from_pretrained("peterpeter8585/AI1")
|
|
|
|
| 25 |
import torch
|
| 26 |
import transformers
|
| 27 |
from transformers import AutoModel as Mo, AutoTokenizer as To
|
|
|
|
|
|
|
| 28 |
from transformers import BitsAndBytesConfig
|
| 29 |
|
| 30 |
quantization_config = BitsAndBytesConfig(
|
|
|
|
| 35 |
)
|
| 36 |
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
from transformers import AutoModelForVision2Seq, AutoProcessor
|
| 40 |
transformers.utils.move_cache()
|
| 41 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|