Spaces:
Running
Running
umuthopeyildirim
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -7,10 +7,34 @@ import gradio as gr
|
|
7 |
from transformers import AutoTokenizer, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
|
8 |
from threading import Thread
|
9 |
import torch
|
|
|
|
|
|
|
|
|
10 |
|
11 |
tokenizer = AutoTokenizer.from_pretrained("umuthopeyildirim/fin-rwkv-1b5")
|
12 |
model = AutoModelForCausalLM.from_pretrained("umuthopeyildirim/fin-rwkv-1b5")
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
class StopOnTokens(StoppingCriteria):
|
16 |
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
|
@@ -68,9 +92,19 @@ def generate_text(prompt, tokenizer, model):
|
|
68 |
return generated_text
|
69 |
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
title = "# Fin-RWKV: Attention Free Financial Expert (WIP)"
|
72 |
description = """Demo for **Fin-RWKV: Attention Free Financial Expert (WIP)**.
|
73 |
-
To download the model, please visit [Fin-RWKV: Attention Free Financial Expert (WIP)](https://huggingface.co/umuthopeyildirim/fin-rwkv-1b5)."""
|
74 |
|
75 |
css = """
|
76 |
#img-display-container {
|
@@ -84,15 +118,18 @@ css = """
|
|
84 |
}
|
85 |
"""
|
86 |
|
|
|
87 |
with gr.Blocks(css=css) as demo:
|
88 |
gr.Markdown(title)
|
89 |
gr.Markdown(description)
|
90 |
with gr.Tab("Chatbot"):
|
91 |
gr.ChatInterface(predict)
|
92 |
-
with gr.Tab("E-Commerce"):
|
93 |
-
|
94 |
with gr.Tab("OpenBB"):
|
95 |
-
gr.
|
|
|
|
|
96 |
|
97 |
if __name__ == '__main__':
|
98 |
-
demo.queue().launch()
|
|
|
7 |
from transformers import AutoTokenizer, AutoModelForCausalLM, StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
|
8 |
from threading import Thread
|
9 |
import torch
|
10 |
+
# from openbb import obb
|
11 |
+
|
12 |
+
# Login to OpenBB
|
13 |
+
# obb.account.login()
|
14 |
|
15 |
tokenizer = AutoTokenizer.from_pretrained("umuthopeyildirim/fin-rwkv-1b5")
|
16 |
model = AutoModelForCausalLM.from_pretrained("umuthopeyildirim/fin-rwkv-1b5")
|
17 |
|
18 |
+
products = [
|
19 |
+
{"name": "Red Bull", "description": "Energy Drink", "symbol": "ALI",
|
20 |
+
"image": "https://i.pinimg.com/originals/f9/68/e3/f968e3a1d474e1c19a91b508231a88c8.png"},
|
21 |
+
{"name": "iPhone 15", "description": "Latest Apple Smartphone", "symbol": "PL",
|
22 |
+
"image": "https://www.apple.com/newsroom/images/2023/09/apple-unveils-iphone-15-pro-and-iphone-15-pro-max/tile/Apple-iPhone-15-Pro-lineup-hero-230912.jpg.news_app_ed.jpg"},
|
23 |
+
{"name": "Pencil", "description": "Wooden Writing Tool", "symbol": "CL",
|
24 |
+
"image": "https://m.media-amazon.com/images/I/41IQfWzTojL._AC_UF1000,1000_QL80_.jpg"},
|
25 |
+
{"name": "LG Monitor", "description": "High-Resolution Computer Monitor", "symbol": "NG",
|
26 |
+
"image": "https://media.us.lg.com/transform/ecomm-PDPGallery-1100x730/a330bb92-bc33-435a-aa1b-07795eedbc10/md08003490-DZ-03"},
|
27 |
+
]
|
28 |
+
examples_openbb = [
|
29 |
+
"user: x,Aluminum Futures\n 2024-01-02T00:00:00,2278.75\n 2024-01-03T00:00:00,2251\n 2024-01-04T00:00:00,2218.25\n 2024-01-05T00:00:00,2203\n 2024-01-08T00:00:00,2168.5\n 2024-01-09T00:00:00,2182.5\n 2024-01-10T00:00:00,2178.5\n 2024-01-11T00:00:00,2179.75\n 2024-01-12T00:00:00,2167.5\n 2024-01-16T00:00:00,2161.75\n 2024-01-17T00:00:00,2148.75\n 2024-01-18T00:00:00,2136.5\n 2024-01-19T00:00:00,2127.5\n 2024-01-22T00:00:00,2127.5\n 2024-01-23T00:00:00,2184.25\n 2024-01-24T00:00:00,2186.25\n 2024-01-25T00:00:00,2194.5\n 2024-01-26T00:00:00,2246.25\n Here is the historical data for Aluminum Futures. Did it appreciated over time or depreciated?\n bot: ",
|
30 |
+
"user: x,Platinum Futures\n 2024-01-02T00:00:00,985.5\n 2024-01-03T00:00:00,974.4000244140624\n 2024-01-04T00:00:00,953.9000244140624\n 2024-01-05T00:00:00,959.2999877929688\n 2024-01-08T00:00:00,946.7000122070312\n 2024-01-09T00:00:00,931\n 2024-01-10T00:00:00,918.7999877929688\n 2024-01-11T00:00:00,909\n 2024-01-12T00:00:00,910.0999755859376\n 2024-01-16T00:00:00,895.0999755859375\n 2024-01-17T00:00:00,882.7999877929688\n 2024-01-18T00:00:00,903.2999877929688\n 2024-01-19T00:00:00,897.2999877929688\n 2024-01-22T00:00:00,894.4000244140625\n 2024-01-23T00:00:00,896.2000122070312\n 2024-01-24T00:00:00,905.5999755859376\n 2024-01-25T00:00:00,887.4000244140625\n 2024-01-26T00:00:00,921.7000122070312\n Here is the historical data for Platinum Futures. Did it appreciated over time or depreciated?\n bot: ",
|
31 |
+
"user: x,Natural Gas Futures\n 2024-01-02T00:00:00,2.568000078201294\n 2024-01-03T00:00:00,2.6679999828338623\n 2024-01-04T00:00:00,2.821000099182129\n 2024-01-05T00:00:00,2.8929998874664307\n 2024-01-08T00:00:00,2.9800000190734863\n 2024-01-09T00:00:00,3.190000057220459\n 2024-01-10T00:00:00,3.0390000343322754\n 2024-01-11T00:00:00,3.0969998836517334\n 2024-01-12T00:00:00,3.312999963760376\n 2024-01-15T00:00:00,3.1059999465942383\n 2024-01-16T00:00:00,2.9000000953674316\n 2024-01-17T00:00:00,2.869999885559082\n 2024-01-18T00:00:00,2.697000026702881\n 2024-01-19T00:00:00,2.5190000534057617\n 2024-01-22T00:00:00,2.4189999103546143\n 2024-01-23T00:00:00,2.450000047683716\n 2024-01-24T00:00:00,2.6410000324249268\n 2024-01-25T00:00:00,2.571000099182129\n 2024-01-26T00:00:00,2.7190001010894775 Here is the historical data for Natural Gas Futures. Did it appreciated over time or depreciated?\n bot: ",
|
32 |
+
"user: x,WTI Crude Oil Futures\n 2024-01-02T00:00:00,70.37999725341797\n 2024-01-03T00:00:00,72.69999694824219\n 2024-01-04T00:00:00,72.19000244140625\n 2024-01-05T00:00:00,73.80999755859375\n 2024-01-08T00:00:00,70.7699966430664\n 2024-01-09T00:00:00,72.23999786376953\n 2024-01-10T00:00:00,71.37000274658203\n 2024-01-11T00:00:00,72.0199966430664\n 2024-01-12T00:00:00,72.68000030517578\n 2024-01-15T00:00:00,72.5\n 2024-01-16T00:00:00,72.4000015258789\n 2024-01-17T00:00:00,72.55999755859375\n 2024-01-18T00:00:00,74.08000183105469\n 2024-01-19T00:00:00,73.41000366210938\n 2024-01-22T00:00:00,75.19000244140625\n 2024-01-23T00:00:00,74.37000274658203\n 2024-01-24T00:00:00,75.08999633789062\n 2024-01-25T00:00:00,77.36000061035156\n 2024-01-26T00:00:00,78.2300033569336 Here is the historical data for WTI Crude Oil Futures. Did it appreciated over time or depreciated?\n bot: ",
|
33 |
+
]
|
34 |
+
|
35 |
+
openbb_inputbox = ""
|
36 |
+
openbb_chatbox = ""
|
37 |
+
|
38 |
|
39 |
class StopOnTokens(StoppingCriteria):
|
40 |
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> bool:
|
|
|
92 |
return generated_text
|
93 |
|
94 |
|
95 |
+
# def fetch_historical_data(symbol):
|
96 |
+
# # Replace with actual OpenBB method to fetch historical data
|
97 |
+
# data = obb.derivatives.futures.historical(
|
98 |
+
# symbol,
|
99 |
+
# start_date="2024-01-01",
|
100 |
+
# interval="1wk",
|
101 |
+
# ).to_df()["close"].rename(symbol)
|
102 |
+
# return data
|
103 |
+
|
104 |
+
|
105 |
title = "# Fin-RWKV: Attention Free Financial Expert (WIP)"
|
106 |
description = """Demo for **Fin-RWKV: Attention Free Financial Expert (WIP)**.
|
107 |
+
To download the model, please visit [Fin-RWKV: Attention Free Financial Expert (WIP)](https://huggingface.co/umuthopeyildirim/fin-rwkv-1b5). [Google Presentation](https://docs.google.com/presentation/d/1vNQ8Y5wwR0WXlO60fsXjkru5R9I0ZgykTmgag0B3Ato/edit?usp=sharing)"""
|
108 |
|
109 |
css = """
|
110 |
#img-display-container {
|
|
|
118 |
}
|
119 |
"""
|
120 |
|
121 |
+
|
122 |
with gr.Blocks(css=css) as demo:
|
123 |
gr.Markdown(title)
|
124 |
gr.Markdown(description)
|
125 |
with gr.Tab("Chatbot"):
|
126 |
gr.ChatInterface(predict)
|
127 |
+
# with gr.Tab("E-Commerce"):
|
128 |
+
# e_commerce_interface()
|
129 |
with gr.Tab("OpenBB"):
|
130 |
+
gr.ChatInterface(predict, examples=[
|
131 |
+
examples_openbb[0], examples_openbb[1], examples_openbb[2], examples_openbb[3]])
|
132 |
+
|
133 |
|
134 |
if __name__ == '__main__':
|
135 |
+
demo.queue().launch(share=False)
|