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

Arbitrary deep prompt_kwargs #229

Open
mrdrprofuroboros opened this issue Oct 15, 2024 · 1 comment
Open

Arbitrary deep prompt_kwargs #229

mrdrprofuroboros opened this issue Oct 15, 2024 · 1 comment

Comments

@mrdrprofuroboros
Copy link

Is your feature request related to a problem? Please describe.
I want to use a dict of Parameters that are inserted into the Prompt at runtime, e.g.

{{ params[used] }}
prompt_kwargs={
    "params": {
        "foo": Parameter(...),
        "bar": Parameter(...),
    },
    "used": "foo",
}

but right now they are not

  1. casted to text during rendering, only the top level params do: https://github.com/SylphAI-Inc/AdalFlow/blob/main/adalflow/adalflow/core/prompt_builder.py#L167
  2. they do not get registered in the component and I have to manually setattr them

Describe the solution you'd like
I want to be able to register some sort of a dict in a component that would register such dynamic parameters and allow to pick them from this dict at Prompt rendering time. Something similar to nn.Embedding in pytorch maybe

Describe alternatives you've considered
Right now I have to

for name, param in self.params.items():
    param.set_peers([self.params[p] for p in self.params if p != name])
    setattr(self, name, param)

and then manually put those that will be used in the Prompt to the top level of the prompt_kwargs so they make it to the graph

Additional context
.

@liyin2015
Copy link
Member

@mrdrprofuroboros You are right! Right now arguments of GradComponents get traced and usually it is the value to be registered as a parameter such as an int or a dict. Generator's prompt_kwargs is already a special case where the value of the key is registered. Right now I dont see real use case where we would want such deep parameter registration.

Would you tell me more about your use case and if it is a must to support recursive parameter? This relates to the prompt_template. And then we can decide if we need to support recursive parameter registration

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

No branches or pull requests

2 participants