Open YogeshNat opened 1 month ago
Hey @YogeshNat! Looks like there is an error with the tool definition. Could you please share how your tool is defined?
Here is an example of a custom tool: https://docs.phidata.com/tools/functions
Hello @ysolanky
This is how I defined the function. This is just extracting a value from a PDF.
def extract_total_from_pdf(pdf_path): try: with open(pdf_path, 'rb') as file: pdf_reader = PyPDF2.PdfReader(file)
full_text = ""
for page in pdf_reader.pages:
text = page.extract_text()
if text:
full_text += text
# Regex pattern to match "Total <number>", allowing for variations in spaces
match = re.search(r'Total\s+(\d+)', full_text, re.IGNORECASE)
if match:
total = int(match.group(1))
return total
else:
return None
except FileNotFoundError:
print(f"The specified PDF file was not found: {pdf_path}")
return None
except Exception as e:
print(f"An error occurred while processing {pdf_path}: {e}")
return None
Could you please check this out.
@YogeshNat Looks like the tool that you're providing the Assistant is send_mail()
with total_amount as a parameter but the tool that you shared above is called extract_total_from_pdf
. Can you please share the tool that you are providing the Assistant that is resulting in the error? Let me know if I'm missing something
Hi @ysolanky
I have just declared the function as total amount. So those parameters are correct.
Thanks
Hello, I am trying to create an assistant with a tool/function which I created. I am posting my assistant code and error over here. Please help me out. Assistant code Mail_agent = Assistant( llm=OpenAIChat(model="gpt-3.5-turbo", api_key= api_key),
Error: openai.BadRequestError: Error code: 400 - {'error': {'message': "Missing required parameter: 'tools[0].type'.", 'type': 'invalid_request_error', 'param': 'tools[0].type', 'code': 'missing_required_parameter'}}
As far as I surfed,The openAI is pretty confused with tools I have used and tools of openAI. Please clarify this. Thanks