Skip to content

Commit

Permalink
fix: example of yahoo finance
Browse files Browse the repository at this point in the history
  • Loading branch information
ArslanSaleem committed Sep 19, 2023
1 parent 21a42f2 commit 3cdc6cb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
16 changes: 9 additions & 7 deletions examples/from_snowflake.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
"""Example of using PandasAI with a Snowflake"""

from pandasai import SmartDatalake
from pandasai import SmartDataframe
from pandasai.llm import OpenAI
from pandasai.connectors import SnowFlakeConnector


snowflake_connector = SnowFlakeConnector(config={
"account": "ehxzojy-ue47135",
snowflake_connector = SnowFlakeConnector(
config={
"account": "ehxzojy-ue47135",
"database": "SNOWFLAKE_SAMPLE_DATA",
"username": "test",
"password": "*****",
"table": "lineitem",
"warehouse" : "COMPUTE_WH",
"warehouse": "COMPUTE_WH",
"dbSchema": "tpch_sf1",
"where": [
# this is optional and filters the data to
# reduce the size of the dataframe
["l_quantity", ">","49"]
["l_quantity", ">", "49"]
],
})
}
)

OPEN_AI_API = "Your-API-Key"
llm = OpenAI(api_token=OPEN_AI_API)
df = SmartDatalake([snowflake_connector], config={"llm": llm})
df = SmartDataframe(snowflake_connector, config={"llm": llm})

response = df.chat("Count line status is F")
print(response)
14 changes: 14 additions & 0 deletions examples/from_yahoo_finance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from pandasai.connectors.yahoo_finance import YahooFinanceConnector
from pandasai import SmartDataframe
from pandasai.llm import OpenAI


yahoo_connector = YahooFinanceConnector("MSFT")


OPEN_AI_API = "OPEN_API_KEY"
llm = OpenAI(api_token=OPEN_AI_API)
df = SmartDataframe(yahoo_connector, config={"llm": llm})

response = df.chat("closing price yesterday")
print(response)
1 change: 0 additions & 1 deletion pandasai/connectors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def _load_connector_config(self, config: Union[BaseConnectorConfig, dict]):
"""
pass

@abstractmethod
def _init_connection(self, config: BaseConnectorConfig):
"""
make connection to database
Expand Down

0 comments on commit 3cdc6cb

Please sign in to comment.