ayushsinha commited on
Commit
0021c19
Β·
verified Β·
1 Parent(s): e0cd83c

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +37 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ def stockmarket_qa(question):
5
+ model_name = "AventIQ-AI/t5-stockmarket-qa-chatbot"
6
+ print("Loading model...")
7
+ generator = pipeline("text2text-generation", model=model_name, device=0) # Use GPU if available
8
+
9
+ # Correcting the input format based on the model's README
10
+ instruction = "question: " # If required by the model
11
+ input_text = f"{instruction}{question}"
12
+
13
+ print(f"Processing input: {input_text}")
14
+ response = generator(input_text, max_new_tokens=200)[0]['generated_text']
15
+
16
+ print(f"Response: {response}")
17
+ return response
18
+
19
+ iface = gr.Interface(
20
+ fn=stockmarket_qa,
21
+ inputs=gr.Textbox(label="πŸ“ˆ Ask a Stock Market Question", placeholder="Enter your query about the stock market...", lines=3),
22
+ outputs=gr.Textbox(label="πŸ’‘ Expert Answer", interactive=True),
23
+ title="πŸ“Š AI-Powered Stock Market Q&A Chatbot",
24
+ description="πŸ€– Enter a stock market-related question, and the AI chatbot will generate a detailed response based on financial knowledge.",
25
+ theme="compact",
26
+ allow_flagging="never",
27
+ examples=[
28
+ ["What are the best stocks to invest in right now?"],
29
+ ["How does inflation affect stock prices?"],
30
+ ["What is technical analysis in stock trading?"],
31
+ ["Explain the difference between a bull and bear market."],
32
+ ["How do interest rates impact the stock market?"]
33
+ ],
34
+ )
35
+
36
+ if __name__ == "__main__":
37
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch
2
+ transformers
3
+ gradio
4
+ sentencepiece