Skip to content

LLM Based SQL Template Matcher #4

Description

@anisbhsl

Description

Implement a LLMBasedSQLTemplateMatcher class that takes in a user query text and provides top_k matching templates by substituting the entities.

class LLMBasedSQLTemplateMatcher(SQLTemplateMatcher):
    """
    LLMBasedSQLTemplateMatcher uses LLM to find the best matching template.
    Given a query, it will extract the key entities and use LLM to find best SQL template
    and generates a subsituted SQL query.

    Args:
        templates: A list of SQL templates.
        ddl_schema: The DDL schema for available tables.
        similarity_threshold: The similarity threshold to be used for fuzzy matching.
    """
    def __init__(self, templates: List[SQLTemplate],
                 ddl_schema: Optional[str] = None,
                 similarity_threshold: float = 0.4,
                 debug: bool = False) -> None:
        super().__init__(debug = debug)

        self.templates = templates
        self.ddl_schema = ddl_schema
        self.similarity_threshold = similarity_threshold

    def match(self, query: str, top_k = 1, **kwargs) -> List[str]:
        pass
        

Activity

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions