Spaces:
Running
Running
Create app.py
#4
by
lilfatcow123
- opened
app.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load FinGPT model from Hugging Face
|
| 5 |
+
model = pipeline("text-generation", model="FinGPT")
|
| 6 |
+
|
| 7 |
+
# Define the chat function
|
| 8 |
+
def chat(input_text):
|
| 9 |
+
response = model(input_text, max_length=50, num_return_sequences=1)
|
| 10 |
+
return response[0]['generated_text']
|
| 11 |
+
|
| 12 |
+
# Create a Gradio interface
|
| 13 |
+
iface = gr.Interface(fn=chat, inputs="text", outputs="text", title="FinGPT Chatbot")
|
| 14 |
+
|
| 15 |
+
iface.launch()
|