You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am a fan of Autogen.
The fundamental question here is... can I write Autogen output back to my local drive? Either via in built functions or my own functions.
I tried with my own function. I can read but I can't write.... Any help would be greatly appreciated.
This is my code:
My functions:
def prq_read(filename: str) -> pd.DataFrame:
"""
Reads a Parquet file from the specified directory and returns a pandas DataFrame.
Args:
filename (str): The name of the Parquet file.
Returns:
pd.DataFrame: The data read from the Parquet file.
"""
parquet_file = f"C:/parquet/{filename}"
dataframe = pd.read_parquet(parquet_file)
return dataframe
#return f"{dataframe} {message}"
def prq_save(dataframe):
"""
Writes a pandas DataFrame to a Parquet file.
Args:
dataframe (pd.DataFrame): The DataFrame to be written.
Returns:
str: The name of the output Parquet file.
"""
table = pa.Table.from_pandas(dataframe)
pq.write_table(table, 'c:/parquet/result.parquet')
return dataframe
llm_config:
llm_config = {
"config_list": config_list,
"seed": 42,
"functions":[
{
"name": "prq_read",
"description": "Reads a Parquet file from the specified directory and returns a pandas DataFrame.",
"parameters": {
"type": "object",
"properties": {
"filename":{
"type": "string",
"description": "Reads a Parquet file from the specified directory and returns a pandas DataFrame."
}
},
"required":["filename"]
}
},
{
"name": "prq_save",
"description": "Read pandas dataframe and convert it to parquet file and save the parquet file.",
"parameters": {
"type": "object",
"properties": {
"dataframe":{
"type": "string",
"description": "Read pandas dataframe and convert it to parquet file and save the parquet file in the specified directory"
}
},
"required":["dataframe"]
}
}
]
}
coder = autogen.AssistantAgent(
name="chatbot",
system_message="For coding tasks, only use the functions you have been provided with. Reply TERMINATE when the task is done.",
llm_config=llm_config,
)
coder.register_function(
function_map={
"prq_read": prq_read,
"prq_save": prq_save,
}
)
My call:
message = """
1) Read murali.parquet file and convert it to pandas dataframe.
2) Display top 3 rows.
3) convert the pandas dataframe to parquet format and save as murali2.parquet in 'c:/parquet'.
4) Execute the above process and TERMINANTE.
"""
with Cache.disk() as cache:
await user_proxy.a_initiate_chat( # noqa: F704
manager,
message=message)
Error I am getting at prq_save function (or this function helps in writing the data back to my C drive)
--------------------------------------------------------------------------------
>>>>>>>> EXECUTING FUNCTION prq_save...
chatbot (to chat_manager):
***** Response from calling function "prq_save" *****
Error: 'str' object has no attribute 'columns'
*****************************************************
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am a fan of Autogen.
The fundamental question here is... can I write Autogen output back to my local drive? Either via in built functions or my own functions.
I tried with my own function. I can read but I can't write.... Any help would be greatly appreciated.
This is my code:
My functions:
llm_config:
My call:
Error I am getting at prq_save function (or this function helps in writing the data back to my C drive)
Beta Was this translation helpful? Give feedback.
All reactions