I am working with data generation and using Pydantic classes to do so. The data will be used for calling REST APIs, so the model looks like this along with parsing code:
class NEFDataModel(BaseModel):
request: str = Field(description="A question about utilizing the NEF API to perform a specific action.")
api_call: str = Field(description="The full URL (taken from the 'path' field) of the API endpoint being invoked.")
description: str = Field(description="A brief summary of the purpose of the API endpoint.")
method: str = Field(description="The HTTP method used to call the API endpoint.")
operation: str = Field(description="The operationId of the API endpoint.")
parameters: object = Field(description="Any parameters required by the API endpoint, a comma separated dict of key-value pairs.")
nef_output_parser = PydanticOutputParser(pydantic_object=NEFDataModel)
....
output_dict = nef_output_parser.parse(response.content)
However, I am getting the following error on calling nef_output_parser.parse(response.content)
:
NEFDataModel expected dict not list (type=type_error)
If I print the response.content
from the invoked chain (without calling parser on it), it looks like this:
[
{
"request": "How can I obtain an access token for future requests?",
"api_call": "/api/v1/login/access-token",
"description": "OAuth2 compatible token login, get an access token for future requests",
"method": "post",
"operation": "login_access_token_api_v1_login_access_token_post",
"parameters": {
"grant_type": "password",
"username": "your_username",
"password": "your_password",
"scope": "",
"client_id": "your_client_id",
"client_secret": "your_client_secret"
}
},
...
]
I have tried playing with data types but no use. And according to my analysis so far, the parameters
field is causing the issue.