Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,15 +9,17 @@ from transformers import pipeline
|
|
9 |
|
10 |
|
11 |
# Load Two Models
|
12 |
-
light_chat_model = pipeline(
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
advanced_summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
14 |
|
15 |
-
def answer_investing_question(question
|
16 |
-
|
17 |
-
response = light_chat_model(question)[0]['generated_text']
|
18 |
-
else:
|
19 |
-
prompt = f"Explain in detail: {question}"
|
20 |
-
response = advanced_summarizer(prompt, max_length=250, min_length=100, do_sample=False)[0]['summary_text']
|
21 |
return response.strip()
|
22 |
|
23 |
|
@@ -200,12 +202,12 @@ with gr.Blocks(theme="soft") as iface:
|
|
200 |
output_sector = gr.Dataframe()
|
201 |
with gr.Tab("Historical Price Chart"):
|
202 |
output_chart = gr.Plot()
|
203 |
-
with gr.
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
|
210 |
|
211 |
submit_btn = gr.Button("Run Analysis")
|
|
|
9 |
|
10 |
|
11 |
# Load Two Models
|
12 |
+
light_chat_model = pipeline(
|
13 |
+
"text-generation",
|
14 |
+
model="mistralai/Mistral-7B-Instruct-v0.2",
|
15 |
+
revision="refs/pr/23", # Use latest stable revision if needed
|
16 |
+
use_auth_token="your_huggingface_access_token",
|
17 |
+
max_length=256
|
18 |
+
)
|
19 |
advanced_summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
20 |
|
21 |
+
def answer_investing_question(question):
|
22 |
+
response = light_chat_model(question)[0]['generated_text']
|
|
|
|
|
|
|
|
|
23 |
return response.strip()
|
24 |
|
25 |
|
|
|
202 |
output_sector = gr.Dataframe()
|
203 |
with gr.Tab("Historical Price Chart"):
|
204 |
output_chart = gr.Plot()
|
205 |
+
with gr.Blocks(theme="soft") as iface:
|
206 |
+
with gr.Tab("Ask About Investing"):
|
207 |
+
user_question = gr.Textbox(label="Ask about investing...")
|
208 |
+
answer_box = gr.Textbox(label="Answer")
|
209 |
+
ask_button = gr.Button("Get Answer")
|
210 |
+
ask_button.click(fn=answer_investing_question, inputs=[user_question], outputs=[answer_box])
|
211 |
|
212 |
|
213 |
submit_btn = gr.Button("Run Analysis")
|