The Excel API exposed to Python is the same as the one you might have used in VBA. In general, if you can figure out how to do what you want in VBA then you can translate it to Python. The follow page from the PyXLL docs should help further:
https://www.pyxll.com/docs/userguide/vba.html.
To get a range relative to the current function you can use the Application.Caller property:
https://learn.microsoft.com/en-us/office/vba/api/Excel.Application.Caller
Once you have the calling range you can use the Offset property to get adjacent cells:
https://learn.microsoft.com/en-us/office/vba/api/Excel.Range.Offset
For example,
from pyxll import xl_app
xl = xl_app()
caller = xl.Caller
specific_range = caller.GetOffset(1, 2)
You can construct a Range from the top left and bottom right cells, eg
xl = xl_app()
top_left = xl.Caller
bottom_right = caller.GetOffset(1, 2)
specific_range = xl.Range(top_left, bottom_right)
Another thing to look at is the "automation_example" function included in the "automation.py" examples in the PYXLL download. This example uses a similar but slightly different way to get a range below the calling cell, and uses PyXLL's async_call function to schedule a function to write to that range after Excel has finished its calculations.
You can instead pass the range into your function. That is a more usual way of passing data like this into a function. The following docs should help
The advantage of doing it this way is that you don't need to get the range in code, you can just pass it in to the function, and each time a value changes in that range then your function would be called.
For example, you could do
from pyxll import xl_app
@xl_func("var[][]: str")
def test(values):
return str(values)
# In Excel...
# A1: =test(A2:B6)
# E1: =test(E2:F6)