-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_LLM.py
executable file
·34 lines (32 loc) · 1.24 KB
/
test_LLM.py
1
2
3
4
5
6
7
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
#!/usr/bin/env python3.10
import pandas as pd
from pandasai import SmartDataframe, SmartDatalake
from langchain.chat_models import ChatOpenAI
import logging
logging.basicConfig()
logging.getLogger("pandasai").setLevel(logging.DEBUG)
df = SmartDataframe("battlestats.csv", config={
"name": "battles",
"description": "MAZ battles",
"llm": ChatOpenAI(),
"enable_cache": False,
"custom_whitelisted_dependencies": ["PIL"]
}).drop(columns=["players"])
player_df = SmartDataframe("battlestats_players.csv", config={
"name": "players",
"description": "players who fought in the MAZ battles",
"llm": ChatOpenAI(),
"enable_cache": False,
"custom_whitelisted_dependencies": ["PIL"],
})
player_details_df = SmartDataframe("player_details.csv", config={
"name": "player details",
"description": "Details about players",
"llm": ChatOpenAI(),
"enable_cache": False,
"custom_whitelisted_dependencies": ["PIL"],
})
df = SmartDatalake([df, player_df, player_details_df], config={"llm": ChatOpenAI(), "enable_cache": False, "max_retries": 10})
print(df.chat('Using only the last dataframe, how many players are there in each faction, where status is Active? Give me a table.'))
print(df.last_result)
print(df.last_code_executed)