Skip to content

Commit

Permalink
feat: launch BambooLLM beta
Browse files Browse the repository at this point in the history
  • Loading branch information
gventuri committed Mar 18, 2024
1 parent 7f11f18 commit bad80c3
Show file tree
Hide file tree
Showing 37 changed files with 317 additions and 343 deletions.
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ If you are interested in managed PandasAI Cloud or self-hosted Enterprise Offeri
### Ask questions

```python
import os
import pandas as pd
from pandasai import SmartDataframe

Expand All @@ -55,12 +56,12 @@ sales_by_country = pd.DataFrame({
"sales": [5000, 3200, 2900, 4100, 2300, 2100, 2500, 2600, 4500, 7000]
})

# Instantiate a LLM
from pandasai.llm import OpenAI
llm = OpenAI(api_token="YOUR_API_TOKEN")
# Get your FREE API key signing up at https://pandabi.ai.
# You can also configure it in your .env file.
os.environ["PANDASAI_API_KEY"] = "YOUR_API_KEY"

df = SmartDataframe(sales_by_country, config={"llm": llm})
df.chat('Which are the top 5 countries by sales?')
agent = SmartDataframe(sales_by_country)
agent.chat('Which are the top 5 countries by sales?')
```

```
Expand All @@ -72,7 +73,7 @@ China, United States, Japan, Germany, Australia
Or you can ask more complex questions:

```python
df.chat(
agent.chat(
"What is the total sales for the top 3 countries by sales?"
)
```
Expand All @@ -86,7 +87,7 @@ The total sales for the top 3 countries by sales is 16500.
You can also ask PandasAI to generate charts for you:

```python
df.chat(
agent.chat(
"Plot the histogram of countries showing for each the gdp, using different colors for each bar",
)
```
Expand All @@ -98,9 +99,9 @@ df.chat(
You can also pass in multiple dataframes to PandasAI and ask questions relating them.

```python
import os
import pandas as pd
from pandasai import SmartDatalake
from pandasai.llm import OpenAI
from pandasai import Agent

employees_data = {
'EmployeeID': [1, 2, 3, 4, 5],
Expand All @@ -116,10 +117,12 @@ salaries_data = {
employees_df = pd.DataFrame(employees_data)
salaries_df = pd.DataFrame(salaries_data)

# Get your FREE API key signing up at https://pandabi.ai.
# You can also configure it in your .env file.
os.environ["PANDASAI_API_KEY"] = "YOUR_API_KEY"

llm = OpenAI()
dl = SmartDatalake([employees_df, salaries_df], config={"llm": llm})
dl.chat("Who gets paid the most?")
agent = Agent([employees_df, salaries_df])
agent.chat("Who gets paid the most?")
```

```
Expand Down
28 changes: 16 additions & 12 deletions docs/custom-response.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ You have the option to provide a custom parser, such as `StreamlitResponse`, to

```python

import os
import pandas as pd

from pandasai import SmartDatalake
from pandasai.llm import OpenAI
from pandasai.responses.response_parser import ResponseParser

# This class overrides default behaviour how dataframe is returned
Expand Down Expand Up @@ -41,13 +40,16 @@ salaries_df = pd.DataFrame(
}
)

llm = OpenAI("OPENAI-KEY")
dl = SmartDatalake(
# Get your FREE API key signing up at https://pandabi.ai.
# You can also configure it in your .env file.
os.environ["PANDASAI_API_KEY"] = "YOUR_API_KEY"

agent = SmartDatalake(
[employees_df, salaries_df],
config={"llm": llm, "verbose": True, "response_parser": PandasDataFrame},
)

response = dl.chat("Return a dataframe of name against salaries")
response = agent.chat("Return a dataframe of name against salaries")
# Returns the response as Pandas DataFrame

```
Expand All @@ -56,13 +58,11 @@ response = dl.chat("Return a dataframe of name against salaries")

```python

import os
import pandas as pd

from pandasai import SmartDatalake
from pandasai.llm import OpenAI
from pandasai.responses.streamlit_response import StreamlitResponse


employees_df = pd.DataFrame(
{
"EmployeeID": [1, 2, 3, 4, 5],
Expand All @@ -78,11 +78,15 @@ salaries_df = pd.DataFrame(
}
)

llm = OpenAI()
dl = SmartDatalake(

# Get your FREE API key signing up at https://pandabi.ai.
# You can also configure it in your .env file.
os.environ["PANDASAI_API_KEY"] = "YOUR_API_KEY"

agent = SmartDatalake(
[employees_df, salaries_df],
config={"llm": llm, "verbose": True, "response_parser": StreamlitResponse},
config={"verbose": True, "response_parser": StreamlitResponse},
)

dl.chat("Plot salaries against name")
agent.chat("Plot salaries against name")
```
Loading

0 comments on commit bad80c3

Please sign in to comment.