Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,20 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
4 |
+
# Load the model and tokenizer
|
5 |
+
model_name = "OrionStarAI/Orion-14B-App-Demo-EN"
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
8 |
|
9 |
+
# Define the chat function
|
10 |
+
def chat(input_text):
|
11 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
12 |
+
outputs = model.generate(**inputs, max_length=150)
|
13 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
14 |
+
return response
|
15 |
|
16 |
+
# Create the Gradio interface
|
17 |
+
iface = gr.Interface(fn=chat, inputs="text", outputs="text", title="ChatGPT-like Model")
|
18 |
+
|
19 |
+
# Launch the interface
|
20 |
+
iface.launch()
|