Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,12 @@ import httpx
|
|
6 |
import asyncio
|
7 |
import gradio as gr
|
8 |
import os
|
9 |
-
from spaces import GPU
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
global_data = {
|
12 |
'models': {},
|
@@ -51,7 +56,7 @@ class ModelManager:
|
|
51 |
def load_model(self, model_config):
|
52 |
if model_config['name'] not in self.models:
|
53 |
try:
|
54 |
-
self.models[model_config['name']] = Llama.from_pretrained(repo_id=model_config['repo_id'], filename=model_config['filename'])
|
55 |
except Exception as e:
|
56 |
print(f"Error loading model {model_config['name']}: {e}")
|
57 |
|
@@ -83,7 +88,7 @@ def remove_duplicates(text):
|
|
83 |
seen_lines.add(line)
|
84 |
return '\n'.join(unique_lines)
|
85 |
|
86 |
-
@GPU(duration=60)
|
87 |
def generate_model_response(model, inputs):
|
88 |
try:
|
89 |
response = model(inputs)
|
|
|
6 |
import asyncio
|
7 |
import gradio as gr
|
8 |
import os
|
9 |
+
from spaces import GPU
|
10 |
+
from dotenv import load_dotenv
|
11 |
+
|
12 |
+
load_dotenv()
|
13 |
+
|
14 |
+
HUGGINGFACE_TOKEN = os.getenv("HUGGINGFACE_TOKEN")
|
15 |
|
16 |
global_data = {
|
17 |
'models': {},
|
|
|
56 |
def load_model(self, model_config):
|
57 |
if model_config['name'] not in self.models:
|
58 |
try:
|
59 |
+
self.models[model_config['name']] = Llama.from_pretrained(repo_id=model_config['repo_id'], filename=model_config['filename'], use_auth_token=HUGGINGFACE_TOKEN)
|
60 |
except Exception as e:
|
61 |
print(f"Error loading model {model_config['name']}: {e}")
|
62 |
|
|
|
88 |
seen_lines.add(line)
|
89 |
return '\n'.join(unique_lines)
|
90 |
|
91 |
+
@GPU(duration=60)
|
92 |
def generate_model_response(model, inputs):
|
93 |
try:
|
94 |
response = model(inputs)
|