Skip to content

Conversation

benhaotang
Copy link

@benhaotang benhaotang commented Feb 4, 2025

rewrite this part to

   if response:
        cleaned = response.strip()
        if cleaned == "<done>":
            return "<done>"
        # First, try to directly evaluate the cleaned string
        try:
            new_queries = ast.literal_eval(cleaned)
            if isinstance(new_queries, list):
                return new_queries
        except Exception as e:
            # Direct evaluation failed; try to extract the list part from the string.
            match = re.search(r'(\[.*\])', cleaned, re.DOTALL)
            if match:
                list_str = match.group(1)
                try:
                    new_queries = ast.literal_eval(list_str)
                    if isinstance(new_queries, list):
                        return new_queries
                except Exception as e_inner:
                    print("Error parsing extracted list:", e_inner, "\nExtracted text:", list_str)
                    return []
            print("Error parsing new search queries:", e, "\nResponse:", response)
            return []
    return []

so that is llms return:

  • '<done>': still finish
  • only list: still search
  • list with explanations: remove explanations then search

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant