-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add skill function not work #1079
Comments
@dustreturn can you please confirm if you have used the right API key and passed it properly? Because from the code you shared, it seems that you're not even making an llm call. One of the reasons for the same I think is that your LLM key is not passed / properly configured. |
Hi, I noticed this bug, pre-defined functions is not been concat into generated code and lead to error. You can call the following functions that have been pre-defined for you: def find_closest_company(df, company_name): """ 模糊查询公司名称,根据company_name在df['公司名称']中返回名称最接近的一行数据: df (df.DataFrame): A table contains a column '公司名称' company_name (str): The name of the company that looking for """ def chinese_currency_to_num(currency_str): """ 由于数据表df里的单位都是元,当用户输入的条件为万元、亿元、万亿等中文单位时,用该函数转换为数值。chinese_currency_to_num("38.16亿元")转换为3816000000.0: currency_str: a chinese string format of a number """ def num_to_chinese_currency(num): """ 输出回答前,用于将float或int数字转换为中文货币单位,返回为字符串。num_to_chinese_currency(3816225765.0)转换为"38.16亿元": num: a float or int number """Update this initial code: # TODO: import the required dependencies
import pandas as pd
# Write code here
# Declare result var:
type (possible values "string", "number", "dataframe", "plot"). Examples: { "type": "string", "value": f"The highest salary is {highest_salary}." } or { "type": "number", "value": 125 } or { "type": "dataframe", "value": pd.DataFrame({...}) } or { "type": "plot", "value": "temp_chart.png" } QUERY有哪些一万亿以上市值的公司? Variable At the end, declare "result" variable as a dictionary of type and value. If you are asked to plot a chart, use "matplotlib" for charts, save as png. Generate python code and return full updated code: Generate python code and return full updated code: 2024-04-02 14:44:00 [INFO] Code generated: Assuming dfs[0] is the DataFrame we are working withdf = dfs[0] Filter companies with market value over 1 trillion (一万亿)Note: The market value in the dataframe is assumed to be in 元, so 1万亿 = 1e12元trillion_companies = df[df['市值'] > 1e12] Prepare the resultresult = { Convert the market value to a more readable format using num_to_chinese_currency functionresult['value']['市值'] = result['value']['市值'].apply(num_to_chinese_currency) result 2024-04-02 14:44:00 [INFO] Executing Step 4: CachePopulation
|
System Info
pandasai version: 2.0.23
platform: vscode
🐛 Describe the bug
import os
import pandasai.pandas as pd
from pandasai import Agent
from pandasai.skills import skill
import streamlit as st
employees_data = {
"EmployeeID": [1, 2, 3, 4, 5],
"Name": ["John", "Emma", "Liam", "Olivia", "William"],
"Department": ["HR", "Sales", "IT", "Marketing", "Finance"],
}
salaries_data = {
"EmployeeID": [1, 2, 3, 4, 5],
"Salary": [5000, 6000, 4500, 7000, 5500],
}
employees_df = pd.DataFrame(employees_data)
salaries_df = pd.DataFrame(salaries_data)
Function doc string to give more context to the model for use this skill
@Skill
def plot_salaries(names: list[str], salaries: list[int]):
"""
Displays the bar chart having name on x-axis and salaries on y-axis using streamlit
Args:
names (list[str]): Employees' names
salaries (list[int]): Salaries
"""
import matplotlib.pyplot as plt
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 = Agent([employees_df, salaries_df], memory_size=10)
agent.add_skills(plot_salaries)
Chat with the agent
response = agent.chat("Plot the employee salaries against names")
print(response)
response: Unfortunately, I was not able to get your answers, because of the following error:
'NoneType' object has no attribute 'type'
The text was updated successfully, but these errors were encountered: