Spaces:
Sleeping
Sleeping
muzammil-eds
commited on
Commit
•
8ac9221
1
Parent(s):
2721254
Update app.py
Browse files
app.py
CHANGED
@@ -1,40 +1,49 @@
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import yfinance as yf
|
3 |
import pandas as pd
|
4 |
-
from langchain.agents
|
5 |
import re
|
6 |
import sqlite3
|
|
|
7 |
from htmlTemplates import css, user_template, bot_template
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
def create_users_db():
|
40 |
with sqlite3.connect('MASTER.db') as conn:
|
@@ -197,10 +206,13 @@ def main():
|
|
197 |
if st.button("Execute") and query:
|
198 |
with st.spinner('Generating response...'):
|
199 |
try:
|
200 |
-
|
|
|
|
|
201 |
llm,
|
202 |
-
|
203 |
-
verbose=True
|
|
|
204 |
)
|
205 |
|
206 |
answer = agent.run(chat_prompt)
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
import streamlit as st
|
4 |
import yfinance as yf
|
5 |
import pandas as pd
|
6 |
+
from langchain.agents import create_csv_agent, AgentType
|
7 |
import re
|
8 |
import sqlite3
|
9 |
+
from langchain.chat_models import ChatOpenAI
|
10 |
from htmlTemplates import css, user_template, bot_template
|
11 |
+
import openai
|
12 |
+
|
13 |
+
# openai.api_key = os.environ("OPENAI_API_KEY") # vLLM server is not authenticated
|
14 |
+
os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY
|
15 |
+
|
16 |
+
|
17 |
+
llm = ChatOpenAI(
|
18 |
+
model='gpt-3.5-turbo',
|
19 |
+
max_tokens=500,
|
20 |
+
temperature=0.7,
|
21 |
+
)
|
22 |
+
|
23 |
+
|
24 |
+
#
|
25 |
+
# class FinLLM(LLM):
|
26 |
+
#
|
27 |
+
# @property
|
28 |
+
# def _llm_type(self) -> str:
|
29 |
+
# return "custom"
|
30 |
+
#
|
31 |
+
# def _call(self, prompt: str, stop: Optional[List[str]] = None) -> str:
|
32 |
+
# out = g4f.ChatCompletion.create(
|
33 |
+
# model="gpt-3.5-turbo",
|
34 |
+
# messages=[{"role": "user", "content": prompt}],
|
35 |
+
# temperature=0.5, # You can adjust parameters as needed
|
36 |
+
# max_tokens=350 # Adjust the token limit as needed
|
37 |
+
# ) #
|
38 |
+
# if stop:
|
39 |
+
# stop_indexes = (out.find(s) for s in stop if s in out)
|
40 |
+
# min_stop = min(stop_indexes, default=-1)
|
41 |
+
# if min_stop > -1:
|
42 |
+
# out = out[:min_stop]
|
43 |
+
# return out
|
44 |
+
#
|
45 |
+
#
|
46 |
+
# llm = FinLLM()
|
47 |
|
48 |
def create_users_db():
|
49 |
with sqlite3.connect('MASTER.db') as conn:
|
|
|
206 |
if st.button("Execute") and query:
|
207 |
with st.spinner('Generating response...'):
|
208 |
try:
|
209 |
+
DF = pd.DataFrame(df)
|
210 |
+
DF.to_csv('data.csv')
|
211 |
+
agent = create_csv_agent(
|
212 |
llm,
|
213 |
+
'data.csv',
|
214 |
+
verbose=True,
|
215 |
+
agent_type=AgentType.OPENAI_FUNCTIONS,
|
216 |
)
|
217 |
|
218 |
answer = agent.run(chat_prompt)
|