Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,8 +3,15 @@ import gradio as gr
|
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
BOT_NAME = "Assistant"
|
| 9 |
|
| 10 |
STOP_SEQUENCES = ["\nUser:", " User:", "###", "</s>"]
|
|
@@ -17,16 +24,6 @@ EXAMPLES = [
|
|
| 17 |
["Can you write a short tweet about the release of our latest AI model, LLAMA LLM?"]
|
| 18 |
]
|
| 19 |
|
| 20 |
-
client = InferenceClient(
|
| 21 |
-
API_URL,
|
| 22 |
-
token=HF_TOKEN,
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
-
client2 = InferenceClient(
|
| 26 |
-
API_URL_2,
|
| 27 |
-
token=HF_TOKEN,
|
| 28 |
-
)
|
| 29 |
-
|
| 30 |
def format_prompt(message, history, system_prompt):
|
| 31 |
prompt = ""
|
| 32 |
if system_prompt:
|
|
@@ -59,6 +56,13 @@ def generate(
|
|
| 59 |
seed = seed + 1
|
| 60 |
formatted_prompt = format_prompt(prompt, history, system_prompt)
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
try:
|
| 63 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
| 64 |
output = ""
|
|
|
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
| 6 |
+
|
| 7 |
+
model2api = [
|
| 8 |
+
"tiiuae/falcon-180B-chat"
|
| 9 |
+
"meta-llama/Llama-2-70b-chat-hf",
|
| 10 |
+
"codellama/CodeLlama-34b-Instruct-hf",
|
| 11 |
+
"victor/CodeLlama-34b-Instruct-hf",
|
| 12 |
+
"timdettmers/guanaco-33b-merged",
|
| 13 |
+
]
|
| 14 |
+
|
| 15 |
BOT_NAME = "Assistant"
|
| 16 |
|
| 17 |
STOP_SEQUENCES = ["\nUser:", " User:", "###", "</s>"]
|
|
|
|
| 24 |
["Can you write a short tweet about the release of our latest AI model, LLAMA LLM?"]
|
| 25 |
]
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
def format_prompt(message, history, system_prompt):
|
| 28 |
prompt = ""
|
| 29 |
if system_prompt:
|
|
|
|
| 56 |
seed = seed + 1
|
| 57 |
formatted_prompt = format_prompt(prompt, history, system_prompt)
|
| 58 |
|
| 59 |
+
client = InferenceClient()
|
| 60 |
+
clientList = (client.list_deployed_models('text-generation-inference'))['text-generation']
|
| 61 |
+
for model in model2api:
|
| 62 |
+
if model in clientList:
|
| 63 |
+
client = InferenceClient(model, token=HF_TOKEN)
|
| 64 |
+
print(f"Choosen model: {model}")
|
| 65 |
+
|
| 66 |
try:
|
| 67 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
| 68 |
output = ""
|