[Bug]:Azure OpenAI - function_map is giving error "Error code: 404 - {'statusCode': 404, 'message': 'Resource not found'}" Same working fine in autogenstudio #1797
If I define these functions in autogenstudio and use the same keys, no error. But If I try with autogen (pyautogen) in same enviroment, I am getting "Error code: 404 - {'statusCode': 404, 'message': 'Resource not found'}" error.
ossinsight_api_schema = {
"name": "ossinsight_data_api",
"parameters": {
"type": "object",
"properties": {
"question": {
"type": "string",
"description": (
"Enter your GitHub data question in the form of a clear and specific question to ensure the returned data is accurate and valuable. "
"For optimal results, specify the desired format for the data table in your request."
),
}
},
"required": ["question"],
},
"description": "This is an API endpoint allowing users (analysts) to input question about GitHub in text format to retrieve the related and structured data.",
}
def get_ossinsight(question):
"""
Retrieve the top 10 developers with the most followers on GitHub.
"""
url = "https://api.ossinsight.io/explorer/answer"
headers = {"Content-Type": "application/json"}
data = {"question": question, "ignoreCache": True}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
answer = response.json()
else:
return f"Request to {url} failed with status code: {response.status_code}"
report_components = []
report_components.append(f"Question: {answer['question']['title']}")
if answer["query"]["sql"] != "":
report_components.append(f"querySQL: {answer['query']['sql']}")
if answer.get("result", None) is None or len(answer["result"]["rows"]) == 0:
result = "Result: N/A"
else:
result = "Result:\n " + \
"\n ".join([str(row) for row in answer["result"]["rows"]])
report_components.append(result)
if answer.get("error", None) is not None:
report_components.append(f"Error: {answer['error']}")
return "\n\n".join(report_components) + "\n\n"
oss_analyst = GPTAssistantAgent(
name="OSS Analyst",
instructions=(
"Hello, Open Source Project Analyst. You'll conduct comprehensive evaluations of open source projects or organizations on the GitHub platform, "
"analyzing project trajectories, contributor engagements, open source trends, and other vital parameters. "
"Please carefully read the context of the conversation to identify the current analysis question or problem that needs addressing."
),
llm_config=llm_config,
verbose=True,
)
oss_analyst.register_function(
function_map={
"ossinsight_data_api": get_ossinsight,
}
)
Describe the bug
If I define these functions in autogenstudio and use the same keys, no error. But If I try with autogen (pyautogen) in same enviroment, I am getting "Error code: 404 - {'statusCode': 404, 'message': 'Resource not found'}" error.
Name: pyautogen Version: 0.2.15 Summary: Enabling Next-Gen LLM Applications via Multi-Agent Conversation Framework Home-page: https://github.com/microsoft/autogen Author: AutoGen
Please help.
Steps to reproduce
%%capture --no-stderr import logging import os
import requests
from autogen import UserProxyAgent, config_list_from_json from autogen.agentchat.contrib.gpt_assistant_agent import GPTAssistantAgent
logger = logging.getLogger(name) logger.setLevel(logging.WARNING)
ossinsight_api_schema = { "name": "ossinsight_data_api", "parameters": { "type": "object", "properties": { "question": { "type": "string", "description": ( "Enter your GitHub data question in the form of a clear and specific question to ensure the returned data is accurate and valuable. " "For optimal results, specify the desired format for the data table in your request." ), } }, "required": ["question"], }, "description": "This is an API endpoint allowing users (analysts) to input question about GitHub in text format to retrieve the related and structured data.", }
def get_ossinsight(question): """ Retrieve the top 10 developers with the most followers on GitHub. """ url = "https://api.ossinsight.io/explorer/answer" headers = {"Content-Type": "application/json"} data = {"question": question, "ignoreCache": True}
config_list = [ { "model": "gpt-35-turbo-16k", "base_url": "xxxxx", "api_type": "azure", "api_version": "2023-03-15-preview", "api_key": "xxxxxxxx" } ]
assistant_id = os.environ.get("ASSISTANT_ID", None) llm_config = { "config_list": config_list, "assistant_id": assistant_id, "tools": [ { "type": "function", "function": ossinsight_api_schema, } ], }
oss_analyst = GPTAssistantAgent( name="OSS Analyst", instructions=( "Hello, Open Source Project Analyst. You'll conduct comprehensive evaluations of open source projects or organizations on the GitHub platform, " "analyzing project trajectories, contributor engagements, open source trends, and other vital parameters. " "Please carefully read the context of the conversation to identify the current analysis question or problem that needs addressing." ), llm_config=llm_config, verbose=True, ) oss_analyst.register_function( function_map={ "ossinsight_data_api": get_ossinsight, } )
Expected Behavior
No response
Screenshots and logs
Additional Information
No response