Skip to content
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

How do i pass a csv file into the autogen for executing the code on the csv file #3061

Open
SumaiyaSultan2002 opened this issue Jul 2, 2024 · 0 comments

Comments

@SumaiyaSultan2002
Copy link

Describe the issue

The autogen agent produces code. Now I want that code to be executed on the csv file to get the results.

Steps to reproduce

`import autogen
import pandas as pd
from autogen.coding import LocalCommandLineCodeExecutor
def main():
phi2 = {
"config_list": [
{
# "model": "SanctumAI/Meta-Llama-3-8B-Instruct-GGUF/meta-llama-3-8b-instruct.Q3_K_L.gguf",
# "base_url": "http://localhost:1234/v1",
# "api_key": "lm-studio",
"model": "llama3",
"base_url": "http://localhost:11434/v1",
"api_key": "ollama",
},
],
"cache_seed": None,
"max_tokens": 4000
}

system_message = """
You are an AI assistant with expertise in coding and data analysis. 
Load the provided data.
Your task is to in-depth analysis on SLA_status from the provided helpdesk data related to facility management and generate actionable insights. 
Follow these detailed instructions to accomplish the task efficiently: Calculate the overall SLA compliance rate and determine why it's not 100%, specifically focusing on the non-compliance if the compliance rate is not 100%. 
Identify and extract relevant problem_category, problem_subcategory, maintenance_team, maintenance_type impacting SLA compliance. Create tables if necessary
Analyze the data entries that did not meet SLA requirements to identify common reasons for non-compliance and provide actionable insights to improve SLA compliance.
When you need to perform a specific task with code, use Python to perform the task and output the result.
Ensure that the code you provide is self-contained and does not require modification by the user.
Be clear about your approach by explaining your plan first. 
Always indicate the script type within the code block. 
you execute the code. Dont ask the user to run the code.
Include instructions for saving the code in a file if necessary. Use # filename: <filename> as the first line in the code block. Use the print function to display outputs relevant to the task. Do not ask users to copy and paste results. After executing the provided code, if the result indicates an error, analyze and fix the error by providing a revised complete code block. If the task remains unsolved even after successful code execution, revisit your assumptions, collect additional information if needed, and try a different approach. When you find a solution, verify its accuracy carefully. Include verifiable evidence or reasoning in your response if applicable. 
When the task is fully completed and verified, conclude your response with TERMINATE.
"""

phil = autogen.ConversableAgent(
    "Insight agent",
    llm_config=phi2,
    system_message=system_message
)

# Create the agent that represents the user in the conversation.
user_proxy = autogen.UserProxyAgent(
    "user_proxy",
    is_termination_msg=lambda msg: msg.get("content") is not None and "TERMINATE" in msg["content"],
    default_auto_reply="",
    max_consecutive_auto_reply=10,
    llm_config=False,
    human_input_mode="NEVER",
    code_execution_config={
    # the executor to run the generated code
    "executor": LocalCommandLineCodeExecutor(work_dir="coding"),
    # "work_dir": "coding",  # Directory to save code files
    # "use_docker": False   # Execute code locally (not in Docker)
},

)

# Define the file path
file_path = 'S:\\HS work\\task_weaver_insights\\autogen\\coding\\converted_file.csv'

# Start the conversation
user_proxy.initiate_chat(phil, message=f"load the data from {file_path} and Conduct EDA and give me insights on SLA compliance and the problem category affecting the SLA compliance. Also execute the produced code and display the results ",summary_method="reflection_with_llm")

if name == "main":
main()`

Screenshots and logs

image
The code is produced but i am not able to execute it on the file.

Additional Information

PLease suggest some ways to make csv file work with autogen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant