Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use fuzzy matching when searching dbgpts #2110

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

jiaoqiyuan
Copy link
Contributor

@jiaoqiyuan jiaoqiyuan commented Oct 31, 2024

Description

When I search for keywords in the DBGPTS community, I would prefer to use fuzzy matching to find relevant content. But now, I can only perform an exact match for the entire keyword.

How Has This Been Tested?

  • make fmt
  • make mypy
  • make test

Snapshots:

It's better to match '%flow%' for all dbgpts, rather than only the dbgpt named 'flow'.
image

Checklist:

  • My code follows the style guidelines of this project
  • I have already rebased the commits and make the commit message conform to the project standard.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • Any dependent changes have been merged and published in downstream modules

@Aries-ckt
Copy link
Collaborator

Thank you for your contribution. _base_dao is the base class for data operations and is not suitable for making changes to the core interface. Therefore, you need to extend it in the dao in the dbgpts serve layer.
You need to extend it in ServeDao class. DB-GPT/dbgpt/serve/dbgpts/hub/models/models.py

class ServeDao(BaseDao[ServeEntity, ServeRequest, ServerResponse]):
    """The DAO class for Dbgpts"""

    def __init__(self, serve_config: ServeConfig):
        super().__init__()
        self._serve_config = serve_config

    def from_request(self, request: Union[ServeRequest, Dict[str, Any]]) -> ServeEntity:
        """Convert the request to an entity

        Args:
            request (Union[ServeRequest, Dict[str, Any]]): The request

        Returns:
            T: The entity
        """
        request_dict = (
            request.to_dict() if isinstance(request, ServeRequest) else request
        )
        entity = ServeEntity(**request_dict)
        return entity

    def to_request(self, entity: ServeEntity) -> ServeRequest:
        """Convert the entity to a request

        Args:
            entity (T): The entity

        Returns:
            REQ: The request
        """

        return ServeRequest(
            id=entity.id,
            name=entity.name,
            description=entity.description,
            author=entity.author,
            email=entity.email,
            type=entity.type,
            version=entity.version,
            storage_channel=entity.storage_channel,
            storage_url=entity.storage_url,
            download_param=entity.download_param,
            installed=entity.installed,
        )

    def to_response(self, entity: ServeEntity) -> ServerResponse:
        """Convert the entity to a response

        Args:
            entity (T): The entity

        Returns:
            RES: The response
        """
        gmt_created_str = entity.gmt_created.strftime("%Y-%m-%d %H:%M:%S")
        gmt_modified_str = entity.gmt_modified.strftime("%Y-%m-%d %H:%M:%S")
        request = self.to_request(entity)

        return ServerResponse(
            **request.to_dict(),
            gmt_created=gmt_created_str,
            gmt_modified=gmt_modified_str,
        )

@jiaoqiyuan
Copy link
Contributor Author

That's right, I've already implemented this in ServeDao.

Copy link
Collaborator

@Aries-ckt Aries-ckt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@csunny csunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution,r+

@csunny csunny merged commit b4ce217 into eosphoros-ai:main Nov 5, 2024
2 checks passed
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.

3 participants