Raven icon indicating copy to clipboard operation
Raven copied to clipboard

Use Raven AI to create Expense Claim, but attach file is failing.

Open kittiu opened this issue 7 months ago • 5 comments

Image

It seem to me that, sometime it is successful, but sometime it is not. But when it fail, the error is always about file_path.

Image
Traceback (most recent call last): File "apps/raven/raven/ai/handler.py", line 275, in handle_requires_action function_output = attach_file_to_document(doctype, document_id, file_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/raven/raven/ai/functions.py", line 169, in attach_file_to_document file = frappe.get_doc("File", {"file_url": file_path}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/model/utils/__init__.py", line 218, in wrapper return dispatch(args[0])(*args, **kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/model/document.py", line 125, in get_doc_str return controller(doctype, name, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/core/doctype/file/file.py", line 69, in __init__ super().__init__(*args, **kwargs) File "apps/frappe/frappe/model/document.py", line 170, in __init__ self._init_dispatch(args[0], *args[1:], **kwargs) File "apps/frappe/frappe/model/document.py", line 194, in _init_dispatch return self._init_known_doc(arg, name, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/model/document.py", line 187, in _init_known_doc self.load_from_db() File "apps/frappe/frappe/model/document.py", line 258, in load_from_db frappe.throw( File "apps/frappe/frappe/utils/messages.py", line 145, in throw msgprint( File "apps/frappe/frappe/utils/messages.py", line 106, in msgprint _raise_exception() File "apps/frappe/frappe/utils/messages.py", line 57, in _raise_exception raise exc frappe.exceptions.DoesNotExistError: File {'file_url': '/mnt/data/file-4P39zq3zFSHDznAJfsdewW'} not found

Here is when it is passed,

Image

Do you have any clue?

Thanks!

kittiu avatar May 27 '25 11:05 kittiu

Weird that it is using the OpenAI file path instead of the file path we sent it. Let me check this. Which version of Raven are you on?

nikkothari22 avatar May 27 '25 11:05 nikkothari22

I am on Raven: v2.4.0 (develop)

kittiu avatar May 28 '25 16:05 kittiu

@kittiu Can you update to the latest version and see if the agent is now able to attach files? What it was trying to do was use its own URL as the file URL. I have added an explicit instruction now.

nikkothari22 avatar May 30 '25 09:05 nikkothari22

Nop, still the same error after doing this,

Image
Traceback (most recent call last): File "apps/raven/raven/ai/handler.py", line 275, in handle_requires_action function_output = attach_file_to_document(doctype, document_id, file_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/raven/raven/ai/functions.py", line 169, in attach_file_to_document file = frappe.get_doc("File", {"file_url": file_path}) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/model/utils/__init__.py", line 218, in wrapper return dispatch(args[0])(*args, **kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/model/document.py", line 125, in get_doc_str return controller(doctype, name, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/core/doctype/file/file.py", line 69, in __init__ super().__init__(*args, **kwargs) File "apps/frappe/frappe/model/document.py", line 170, in __init__ self._init_dispatch(args[0], *args[1:], **kwargs) File "apps/frappe/frappe/model/document.py", line 194, in _init_dispatch return self._init_known_doc(arg, name, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "apps/frappe/frappe/model/document.py", line 187, in _init_known_doc self.load_from_db() File "apps/frappe/frappe/model/document.py", line 258, in load_from_db frappe.throw( File "apps/frappe/frappe/utils/messages.py", line 145, in throw msgprint( File "apps/frappe/frappe/utils/messages.py", line 106, in msgprint _raise_exception() File "apps/frappe/frappe/utils/messages.py", line 57, in _raise_exception raise exc frappe.exceptions.DoesNotExistError: File {'file_url': '/mnt/data/file-BbJbWU7NhLFem4Y1FP6APg'} not found

I did,

  • pull code to latest dev aa600de (HEAD -> develop, upstream/develop, upstream/HEAD) fix: added explicit instruction to use the file URL to attach to document
  • bench build, bench migrate, bench clear-cache

Thank you.

kittiu avatar May 31 '25 04:05 kittiu