dolphinium
feat: Integrate dynamic field suggestions from external API into analysis plan generation and UI
f74c067
import requests | |
import json | |
import yaml | |
def get_search_list_params(query, k=20): | |
""" | |
Returns tuple: (search_fields, search_name) | |
""" | |
url = "https://aitest.ebalina.com/stream" | |
response = requests.post(url, | |
headers={'Content-Type': 'application/json'}, | |
json={"query": query, "k": k}, | |
stream=True) | |
for line in response.iter_lines(): | |
if line and line.startswith(b'data: '): | |
try: | |
data = json.loads(line[6:]) | |
if data.get('log_title') == 'Search List Result': | |
yaml_data = yaml.safe_load(data['content']) | |
# As requested, ignoring 'search_name' and only returning fields | |
return yaml_data.get('search_fields', []), yaml_data.get('search_name', '') | |
except: | |
continue | |
# Return empty list if no valid data is found | |
return [], "" |