Open Akash47007 opened 3 months ago
Hey @Akash47007! 👋 I'm here to help you with any bugs, questions, or contributions you have in mind. Let's tackle this together!
To use the project with MySQL, you can follow the example provided in the examples/from_sql.py
file. Here is the relevant code snippet for connecting to a MySQL database:
import os
from pandasai import Agent
from pandasai.connectors import MySQLConnector
# With a MySQL database
loan_connector = MySQLConnector(
config={
"host": "localhost",
"port": 3306,
"database": "mydb",
"username": "root",
"password": "root",
"table": "loans",
"where": [
# this is optional and filters the data to
# reduce the size of the dataframe
["loan_status", "=", "PAIDOFF"],
],
}
)
# By default, unless you choose a different LLM, it will use BambooLLM.
# You can 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([loan_connector])
response = agent.chat("How many people from the United states?")
print(response)
Replace the placeholder values in the config
dictionary with your actual database credentials and configuration [1].
To continue talking to Dosu, mention @dosu.
I want to use it with llama 3 running in my pc.
And train it also
@dosu
To use the project with Llama 3 running on your PC and train it, follow these steps:
Use the provided code snippet to configure the MySQL connection:
from pandasai.connectors.sql import SQLConnector, SQLConnectorConfig
# Define your ConnectorConfig instance here
config = SQLConnectorConfig(
dialect="mysql",
driver="pymysql",
username="your_username",
password="your_password",
host="your_host",
port=3306, # Default MySQL port
database="your_database",
table="your_table",
where=[["column_name", "=", "value"]],
).dict()
# Create an instance of SQLConnector
sql_connector = SQLConnector(config)
Assuming you have a class Llama3
for the model, you can configure it as follows:
from pandasai.llm.llama3 import Llama3 # Assuming Llama3 is the class for the model
# Initialize the Llama 3 model
llm = Llama3()
Use the train
method to train the model. Here is an example of how to do this:
from pandasai.ee.agents.semantic_agent import SemanticAgent
import pandas as pd
# Sample DataFrame
sample_df = pd.DataFrame({
"order_id": [10248, 10249, 10250],
"customer_id": ["VINET", "TOMSP", "HANAR"],
"employee_id": [5, 6, 4],
"order_date": pd.to_datetime(["1996-07-04", "1996-07-05", "1996-07-08"]),
"required_date": pd.to_datetime(["1996-08-01", "1996-08-16", "1996-08-05"]),
"shipped_date": pd.to_datetime(["1996-07-16", "1996-07-10", "1996-07-12"]),
"ship_via": [3, 1, 2],
"ship_name": ["Vins et alcools Chevalier", "Toms Spezialitäten", "Hanari Carnes"],
"ship_address": ["59 rue de l'Abbaye", "Luisenstr. 48", "Rua do Paço, 67"],
"ship_city": ["Reims", "Münster", "Rio de Janeiro"],
"ship_region": ["CJ", None, "RJ"],
"ship_postal_code": ["51100", "44087", "05454-876"],
"ship_country": ["France", "Germany", "Brazil"],
})
# Initialize the SemanticAgent with the sample DataFrame and Llama 3 model
agent = SemanticAgent(sample_df, {"llm": llm}, vectorstore=MagicMock())
# Train the model
queries = ["query1"]
jsons = ['{"name": "test"}']
agent.train(queries=queries, jsons=jsons)
This example demonstrates how to configure and train the Llama 3 model on your PC while connecting to a MySQL database using the provided code snippet [1].
To continue talking to Dosu, mention @dosu.
Я хочу использовать его с Llama 3, запущенной на моем ПК.
И тренируй его тоже
@dosu
Hi. Maybe helpe - https://www.youtube.com/watch?v=o88et_D8qlg
Hi, @Akash47007! I'm helping the pandas-ai team manage their backlog and am marking this issue as stale.
From what I understand, you were seeking assistance on using the project with MySQL and integrating it with Llama 3. You received a detailed code snippet for connecting to MySQL, along with steps for configuring and training the Llama 3 model. Additionally, another user provided a helpful YouTube link to assist you further.
Could you please let us know if this issue is still relevant to the latest version of the pandas-ai repository? If it is, feel free to comment here to keep it open. Otherwise, you can close the issue yourself, or it will be automatically closed in 7 days. Thank you!
i find no way to use it