Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
3 |
import torch
|
4 |
import os
|
5 |
from dotenv import load_dotenv
|
|
|
6 |
|
7 |
# Load environment variables from .env file
|
8 |
load_dotenv()
|
@@ -45,7 +46,8 @@ system_instruction = (
|
|
45 |
"The scripts must be functional in a real-world scenario."
|
46 |
)
|
47 |
|
48 |
-
# Define the chat function
|
|
|
49 |
def chat_function(prompt):
|
50 |
# Create the full input prompt including the system instruction
|
51 |
full_prompt = f"{system_instruction}\nUser: {prompt}\nAssistant:"
|
@@ -69,8 +71,8 @@ iface = gr.Interface(
|
|
69 |
fn=chat_function,
|
70 |
inputs="text",
|
71 |
outputs="text",
|
72 |
-
title="Hacker
|
73 |
-
description="A HackingGPT
|
74 |
)
|
75 |
|
76 |
# Launch the interface
|
|
|
3 |
import torch
|
4 |
import os
|
5 |
from dotenv import load_dotenv
|
6 |
+
import spaces # Import the spaces module
|
7 |
|
8 |
# Load environment variables from .env file
|
9 |
load_dotenv()
|
|
|
46 |
"The scripts must be functional in a real-world scenario."
|
47 |
)
|
48 |
|
49 |
+
# Define the chat function and decorate it with @spaces.GPU
|
50 |
+
@spaces.GPU
|
51 |
def chat_function(prompt):
|
52 |
# Create the full input prompt including the system instruction
|
53 |
full_prompt = f"{system_instruction}\nUser: {prompt}\nAssistant:"
|
|
|
71 |
fn=chat_function,
|
72 |
inputs="text",
|
73 |
outputs="text",
|
74 |
+
title="Hacker",
|
75 |
+
description="A HackingGPT",
|
76 |
)
|
77 |
|
78 |
# Launch the interface
|