Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 3 |
|
| 4 |
-
# Load
|
| 5 |
-
tokenizer = AutoTokenizer.from_pretrained("aisingapore/sea-lion-7b-instruct")
|
| 6 |
-
model = AutoModelForCausalLM.from_pretrained("aisingapore/sea-lion-7b-instruct")
|
| 7 |
|
| 8 |
def generate_response(prompt):
|
| 9 |
inputs = tokenizer(prompt, return_tensors="pt")
|
|
@@ -12,13 +12,5 @@ def generate_response(prompt):
|
|
| 12 |
|
| 13 |
iface = gr.Interface(fn=generate_response, inputs="text", outputs="text")
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
def api_handler(data):
|
| 17 |
-
return {"response": generate_response(data['input'])}
|
| 18 |
-
|
| 19 |
iface.launch(share=True, inline=True)
|
| 20 |
-
|
| 21 |
-
# Expose a POST API route using Gradio's internal methods
|
| 22 |
-
iface.api_routes = {
|
| 23 |
-
"/generate": {"POST": api_handler}
|
| 24 |
-
}
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 3 |
|
| 4 |
+
# Load the model and tokenizer with `trust_remote_code=True`
|
| 5 |
+
tokenizer = AutoTokenizer.from_pretrained("aisingapore/sea-lion-7b-instruct", trust_remote_code=True)
|
| 6 |
+
model = AutoModelForCausalLM.from_pretrained("aisingapore/sea-lion-7b-instruct", trust_remote_code=True)
|
| 7 |
|
| 8 |
def generate_response(prompt):
|
| 9 |
inputs = tokenizer(prompt, return_tensors="pt")
|
|
|
|
| 12 |
|
| 13 |
iface = gr.Interface(fn=generate_response, inputs="text", outputs="text")
|
| 14 |
|
| 15 |
+
# Launch the interface
|
|
|
|
|
|
|
|
|
|
| 16 |
iface.launch(share=True, inline=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|