Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,19 @@
|
|
1 |
# Import necessary libraries
|
|
|
2 |
from threading import Thread
|
3 |
import argparse
|
4 |
import torch
|
5 |
import gradio as gr
|
6 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, TextIteratorStreamer, AutoModelForCausalLM
|
7 |
from peft import PeftConfig, PeftModel
|
8 |
-
from utils import get_device #
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# Create the parser
|
11 |
parser = argparse.ArgumentParser(description='Check model usage.')
|
@@ -128,7 +136,7 @@ with gr.Blocks(css="""
|
|
128 |
opacity: 1;
|
129 |
}
|
130 |
.gr-textbox {
|
131 |
-
background-color: var(--
|
132 |
color: white;
|
133 |
border: none;
|
134 |
border-radius: 4px;
|
@@ -160,7 +168,7 @@ with gr.Blocks(css="""
|
|
160 |
temperature = gr.Slider(minimum=0.1, maximum=5.0, value=0.8, step=0.1, label="Temperature")
|
161 |
|
162 |
with gr.Column(scale=7):
|
163 |
-
model_output = gr.Chatbot(label="Chatbot Output", height=
|
164 |
|
165 |
def handle_submit(text, top_p, temperature, top_k, max_new_tokens):
|
166 |
response = run_generation(text, top_p, temperature, top_k, max_new_tokens)
|
|
|
1 |
# Import necessary libraries
|
2 |
+
import os
|
3 |
from threading import Thread
|
4 |
import argparse
|
5 |
import torch
|
6 |
import gradio as gr
|
7 |
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, TextIteratorStreamer, AutoModelForCausalLM
|
8 |
from peft import PeftConfig, PeftModel
|
9 |
+
from utils import get_device # Assuming this function exists
|
10 |
+
from huggingface_hub import login
|
11 |
+
|
12 |
+
# Authenticate using Hugging Face API token from environment variable
|
13 |
+
hf_api_token = os.getenv("HF_API_TOKEN")
|
14 |
+
if hf_api_token is None:
|
15 |
+
raise ValueError("Hugging Face API token not found in environment variables. Please set it as a secret in Hugging Face Spaces.")
|
16 |
+
login(token=hf_api_token)
|
17 |
|
18 |
# Create the parser
|
19 |
parser = argparse.ArgumentParser(description='Check model usage.')
|
|
|
136 |
opacity: 1;
|
137 |
}
|
138 |
.gr-textbox {
|
139 |
+
background-color: var(--body-background-fill);
|
140 |
color: white;
|
141 |
border: none;
|
142 |
border-radius: 4px;
|
|
|
168 |
temperature = gr.Slider(minimum=0.1, maximum=5.0, value=0.8, step=0.1, label="Temperature")
|
169 |
|
170 |
with gr.Column(scale=7):
|
171 |
+
model_output = gr.Chatbot(label="Chatbot Output", height=400)
|
172 |
|
173 |
def handle_submit(text, top_p, temperature, top_k, max_new_tokens):
|
174 |
response = run_generation(text, top_p, temperature, top_k, max_new_tokens)
|