admin管理员组文章数量:1125760
I'm using semantic kernel and azure open ai as my search. I have this plugin I created:
class QuerySQLTablesPlugin:
@kernel_function(
description="Get the schema of the table to create the query the user needs")
async def fetch_schema_async(self, table_name: str):
table_name = table_name.split(".")[-1]
return await sync_to_async(self.fetch_schema_sync)(table_name)
@kernel_function(
description="Takes in a query to be executed in the database")
async def execute_query(self, query_to_execute: str):
return await sync_to_async(self.fetch_query_sync)(query_to_execute)
def fetch_schema_sync(self, table_name):
with connections['default'].cursor() as cursor:
cursor.execute(
f"SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '{table_name}'"
)
schema = cursor.fetchall()
print(f"Fetched schema: {schema}")
return schema
def fetch_query_sync(self, query_to_execute: str):
with connections['default'].cursor() as cursor:
cursor.execute(query_to_execute)
result = cursor.fetchall()
results = [dict(row) for row in result]
print(f"Query results: {results}")
return json.dumps(results)
The fetch_schema_async
function gets called successfully, however, for the execute_query
function, it gives me the following error:
QuerySQLTables-execute_query: Function Call arguments are not valid JSON.. Trying tool call again.
Even though, I'm able to see the query_to_execute, it looks like this:
{'name': 'QuerySQLTables-execute_query', 'arguments': '{\n "query_to_execute": "SELECT is_staff FROM dbo.user WHERE username = \'Bob\'"\n }'}}]}, {'role': 'tool', 'content': 'The tool call arguments are malformed. Arguments must be in JSON format. Please try again.', 'tool_call_id': 'call_1BcXUS4WUdozITfhWmY1BuGB'},
Why am I getting this error? The function is not executing at all.
本文标签: pythonSemantic Kernel Plugin Function Arguments must be in JSON formatStack Overflow
版权声明:本文标题:python - Semantic Kernel Plugin Function: Arguments must be in JSON format - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736673815a1947067.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论