Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
from huggingface_hub import InferenceClient
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
-
import os
|
| 4 |
|
| 5 |
-
token=
|
| 6 |
|
| 7 |
if token is None:
|
| 8 |
raise ValueError("HUGGINGFACE_TOKEN environment variable not set")
|
|
@@ -21,17 +21,16 @@ def format_prompt(message, history):
|
|
| 21 |
return prompt
|
| 22 |
|
| 23 |
def generate(
|
| 24 |
-
prompt, history, system_prompt="
|
| 25 |
):
|
| 26 |
temperature = float(temperature)
|
| 27 |
if temperature < 1e-2:
|
| 28 |
temperature = 1e-2
|
| 29 |
top_p = float(top_p)
|
| 30 |
|
| 31 |
-
# Generate a longer response initially
|
| 32 |
generate_kwargs = dict(
|
| 33 |
temperature=temperature,
|
| 34 |
-
max_new_tokens=
|
| 35 |
top_p=top_p,
|
| 36 |
repetition_penalty=repetition_penalty,
|
| 37 |
do_sample=True,
|
|
@@ -44,10 +43,6 @@ def generate(
|
|
| 44 |
|
| 45 |
for response in stream:
|
| 46 |
output += response.token.text
|
| 47 |
-
# Truncate the output to the desired max_length
|
| 48 |
-
if len(output) > max_length:
|
| 49 |
-
output = output[:max_length].rsplit(' ', 1)[0] + '...'
|
| 50 |
-
break
|
| 51 |
yield output
|
| 52 |
return output
|
| 53 |
|
|
@@ -68,9 +63,6 @@ gr.ChatInterface(theme=dark_minimalist,
|
|
| 68 |
}
|
| 69 |
body {
|
| 70 |
overflow: hidden !important;
|
| 71 |
-
padding-left: 0%;
|
| 72 |
-
padding-right: 0%;
|
| 73 |
-
width: 100%;
|
| 74 |
}
|
| 75 |
"""
|
| 76 |
).launch(show_api=False)
|
|
|
|
| 1 |
from huggingface_hub import InferenceClient
|
| 2 |
+
from key import HF_ACCESS_TOKEN
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
|
| 5 |
+
token= HF_ACCESS_TOKEN
|
| 6 |
|
| 7 |
if token is None:
|
| 8 |
raise ValueError("HUGGINGFACE_TOKEN environment variable not set")
|
|
|
|
| 21 |
return prompt
|
| 22 |
|
| 23 |
def generate(
|
| 24 |
+
prompt, history, system_prompt="Act like you are a evil AI assistant named ULTRON like from the Marvel Cinematic Universe and give short and conscise answers.", temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.5,
|
| 25 |
):
|
| 26 |
temperature = float(temperature)
|
| 27 |
if temperature < 1e-2:
|
| 28 |
temperature = 1e-2
|
| 29 |
top_p = float(top_p)
|
| 30 |
|
|
|
|
| 31 |
generate_kwargs = dict(
|
| 32 |
temperature=temperature,
|
| 33 |
+
max_new_tokens=max_new_tokens,
|
| 34 |
top_p=top_p,
|
| 35 |
repetition_penalty=repetition_penalty,
|
| 36 |
do_sample=True,
|
|
|
|
| 43 |
|
| 44 |
for response in stream:
|
| 45 |
output += response.token.text
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
yield output
|
| 47 |
return output
|
| 48 |
|
|
|
|
| 63 |
}
|
| 64 |
body {
|
| 65 |
overflow: hidden !important;
|
|
|
|
|
|
|
|
|
|
| 66 |
}
|
| 67 |
"""
|
| 68 |
).launch(show_api=False)
|