Spaces:
Build error
Build error
Download src/gradio_interface.py from AmitBits/financial-rag-chatbot: direct link, hf CLI and curl.
- Browser
- Download file 473 Bytes
-
https://huggingface.co/spaces/AmitBits/financial-rag-chatbot/resolve/main/src/gradio_interface.py
- Command line
-
hf download hf://spaces/AmitBits/financial-rag-chatbot/src/gradio_interface.py
-
curl -L -o gradio_interface.py https://huggingface.co/spaces/AmitBits/financial-rag-chatbot/resolve/main/src/gradio_interface.py
473 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load a pre-trained sentiment analysis model | |
| classifier = pipeline("sentiment-analysis") | |
| # Define the function to process user input | |
| def analyze_sentiment(text): | |
| result = classifier(text)[0] | |
| return f"Label: {result['label']}, Confidence: {result['score']:.2f}" | |
| # Create Gradio Interface | |
| interface = gr.Interface(fn=analyze_sentiment, inputs="text", outputs="text") | |
| # Run the app locally | |
| interface.launch() | |