|
14 | 14 | import time |
15 | 15 | import requests |
16 | 16 | from concurrent.futures import ThreadPoolExecutor |
| 17 | +import inspect |
17 | 18 |
|
18 | 19 | # Custom JSON encoder to handle NumPy and pandas types |
19 | 20 | class NumpyEncoder(json.JSONEncoder): |
@@ -895,7 +896,6 @@ def term_info_parse_object(results, short_form): |
895 | 896 | synonym["scope"] = syn.synonym.scope if hasattr(syn.synonym, 'scope') else "exact" |
896 | 897 | synonym["type"] = syn.synonym.type if hasattr(syn.synonym, 'type') else "synonym" |
897 | 898 |
|
898 | | - # Enhanced publication handling - handle multiple publications |
899 | 899 | if hasattr(syn, 'pubs') and syn.pubs: |
900 | 900 | pub_refs = [] |
901 | 901 | for pub in syn.pubs: |
@@ -3833,16 +3833,23 @@ def process_query(query): |
3833 | 3833 | function_args = query['takes'].get("default", {}) |
3834 | 3834 | # print(f"Function args: {function_args}") |
3835 | 3835 |
|
| 3836 | + # Check function signature to see if it takes a positional argument for short_form |
| 3837 | + sig = inspect.signature(function) |
| 3838 | + params = list(sig.parameters.keys()) |
| 3839 | + # Skip 'self' if it's a method, and check if first param is not return_dataframe/limit/summary_mode |
| 3840 | + first_param = params[1] if params and params[0] == 'self' else (params[0] if params else None) |
| 3841 | + takes_short_form = first_param and first_param not in ['return_dataframe', 'limit', 'summary_mode'] |
| 3842 | + |
3836 | 3843 | # Modify this line to use the correct arguments and pass the default arguments |
3837 | 3844 | if summary_mode: |
3838 | | - if function_args: |
| 3845 | + if function_args and takes_short_form: |
3839 | 3846 | # Pass the short_form as positional argument |
3840 | 3847 | short_form_value = list(function_args.values())[0] |
3841 | 3848 | result = function(short_form_value, return_dataframe=False, limit=query['preview'], summary_mode=summary_mode) |
3842 | 3849 | else: |
3843 | 3850 | result = function(return_dataframe=False, limit=query['preview'], summary_mode=summary_mode) |
3844 | 3851 | else: |
3845 | | - if function_args: |
| 3852 | + if function_args and takes_short_form: |
3846 | 3853 | short_form_value = list(function_args.values())[0] |
3847 | 3854 | result = function(short_form_value, return_dataframe=False, limit=query['preview']) |
3848 | 3855 | else: |
|
0 commit comments