Hello all,
There is one other thread related to this topic but I thought it couldn’t hurt to start another one for some further clarification. There seems to be an issue when with_structured_output(Classification) is called on the llm. For example:
class Classification(BaseModel):
energy: str = Field(..., description="What aspect of energy is this related to?")
energy_related: int = Field(..., description="How related is this to energy on a scale from 1 to 10?")
tag: str = Field(
..., description="Please select a tag from the provided list.",
enum=[
"wells", "pipelines", "infrastructure", "imagery", "weather",
"environmental", "geology", "seismic", "geomatics", "renewables",
"emissions", "basemaps", "bathymetry"
]
)
Might help to see the tagging_function where invoke() is called:
agent_csv_path = os.path.join(inputFolderPath, 'export-1.csv')
agent = create_csv_agent(llm, agent_csv_path, verbose=True)
def tagging_function(description, tags):
if description == "No description":
text = tags
else:
text = description
prompt_input = tagging_prompt.format(input=text)
result = agent.invoke(prompt_input)
return {
'energy': result.energy,
'energy_related': result.energy_related,
'tag': result.tag
}
Any suggestions on how to get around this error 400 issue:
Error code: 400 - {‘error’: {‘message’: “Invalid ‘tools[0].function.description’: string too long. Expected a string with maximum length 1024, but got a string with length 1824 instead.”, ‘type’: ‘invalid_request_error’, ‘param’: ‘tools[0].function.description’, ‘code’: ‘string_above_max_length’}}