Code: Select all
senior_data_analyst = autogen.AssistantAgent(
name="Senior Data Analyst",
system_message=senior_data_analyst_prompt,
llm_config=llm_config,
code_execution_config=False, # Prevents arbitrary code execution, except code in the function map.
human_input_mode="NEVER", # asks for a human input each time a message is received.
is_termination_msg=is_termination_msg,
function_map=function_map,
)
< /code>
Die Funktionskarte lautet wie folgt: < /p>
function_map = {
"run_sql": db.run_sql,
}
Code: Select all
def run_sql(self, sql) -> str:
print("In run_sql: NO ERRORS IN DB.")
self.cur.execute(sql)
columns = [desc[0] for desc in self.cur.description]
res = self.cur.fetchall()
list_of_dicts = [dict(zip(columns, row)) for row in res]
json_result = json.dumps(list_of_dicts, indent=4, default=self.datetime_handler)
return json_result
< /code>
Ich habe vor ungefähr einer Woche Autogen mit dem Befehl heruntergeladen. Ich bin mir nicht sicher, ob es sich um ein Versionsproblem handelt. < /P>
pip install autogen-agentchat~=0.2
< /code>
Ich habe versucht, meine Eingabeaufforderung zu ändern, habe aber keine Ergebnisse erzielt. Das einzige, was sich ändert, ist die Dummy -Ausgabe. Ich habe sogar versucht, etwas in der Funktion run_sql
Code: Select all
senior_data_analyst_prompt = "Senior_Data_Analyst. You follow approved plan. EXECUTE FUNCTION run_sql, show the FUNCTION EXECUTED, DISPLAY RESULTS ONLY. SEND QUERY AND Generated response to the product manager for final review."
Code: Select all
run_sql_config = {
"use_cache":False, # to run each new session from the beginning.
#"cache_seed": 42, # to get consistent result for same input.
"config_list":config_list,
"temperature": 0,
"timeout": 120,
"functions": [
{
"name":"run_sql",
"description": "Run a SQL query against the Postgres database.",
"parameters":{
"type":"object",
"properties":{
"sql":{
"type":"string",
"description":"The SQL query to RUN."
}
},
"required":["sql"],
},
},
],
}
[*]
Code: Select all
silver_vehicles
Code: Select all
vehicle_type_count
[*]
Code: Select all
vehicle_model_count
Code: Select all
total_vehicle_count
< Br />
Vehicle_Type < /th>
Modell < /th>
Region < /th>
Vehikel_type_Count
vehikel_model_count
Total_Vehicle_Count
Vehikel_type_percentage
vehiumsmodel_percentage th>
< /tr>
< /thead>
Auto < /td>
Toyota corolla < /td>
Auckland < /td>
100 < /td>
50 < /td>
1000 < /td>
10.00
5.00
< /tr>
Auto < /td>
Honda Civic < /td>
Auckland < /td>
100 < /td>
30
1000
10.00
3.00
< Br />
Truck < /td>
Ford Ranger < /td>
Wellington < /td>
50 < /td>
20 < /td>
1000 < /td>
5.00
2.00 < /td>
< /tr>
Truck < /td>
Toyota Hilux < /td>
Wellington < /td>
50 < /td>
15 < /td>
1000 < /td>
5.00 /td>
1.50
< /tr>
Motorrad < /td>
yamaha Fjr < /td>
Christchurch < /td>
20 < /td>
10 < /td>
1000 < /td>
2.00
1.00
< /tr>
Motorcycle < /td>
Honda cbr < /td>
Christchurch < /td>
20 < /td>
5 5 5 5 5 5 < /td>
5 < /td>
1000 < /td>
2.00
0.50
< /tr>
Vielen Dank im Voraus.