Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Ability to change the Specific Passes in jaclang using Plugin Interface #546

Open
chandralegend opened this issue Jul 30, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@chandralegend
Copy link
Contributor

chandralegend commented Jul 30, 2024

Is your feature request related to a problem? Please describe.

Currently MTLLM is running as a separate repo but the with_llm feature in jaclang only works with mtllm installed. and there is no purpose for that if mttlm is not installed. At the same time developers has to make PRs to the jaclang repo to get language level changes that required to add new functionalities to the mtllm repo. This is counter-productive.

Describe the solution you'd like

Currently we can override add new methods to stuff in plugin folder using pluggy. What if we add the same ability to all the Passes in jaclang. How it will look in the plugin repo will look like this for mtllm

# mtllm/pass.py
from jaclang.compiler.passes.main.pyast_gen_pass import hookmethod

class PyastGenPass:
     @hookmethod
     def needs_mtllm(self) -> None:
        """Add the MTLLM Classes necessary"
        pass

     @hookmethod
     def exit_ability(self, node: ast.Ability) -> None:
        """Sub objects.

        name_ref: NameType,
        is_func: bool,
        is_async: bool,
        is_static: bool,
        is_abstract: bool,
        access: Optional[SubTag[Token]],
        signature: Optional[FuncSignature | ExprType | EventSignature],
        body: Optional[SubNodeList[CodeBlockStmt] | AbilityDef | FuncCall],
        doc: Optional[String],
        decorators: Optional[SubNodeList[ExprType]],
        """
        func_type = ast3.AsyncFunctionDef if node.is_async else ast3.FunctionDef
        body = (
            self.gen_llm_body(node)
            if isinstance(node.body, ast.FuncCall)
        
        blah blah
# pyproject.toml
[tool.poetry.plugins."jac"]
mtllm = "mtllm.plugin:JacFeature"
pyast_gen_pass = "mtllm.pass.PyastGenPass"

Describe alternatives you've considered

Another option is to have the mtllm inside jaclang. this is not productive as it defeats the purpose of giving developers the ability to create plugins.

@chandralegend chandralegend added the enhancement New feature or request label Jul 30, 2024
@marsninja
Copy link
Contributor

Whats the use case for this, I'm thinking a pattern of having the body of the function make a call into the plugin interface might might make more sense.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants