forked from stanfordnlp/dspy
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
What feature would you like to see?
In the following code, the type checker won't recognize the member weather_function on compiled_agent because it was returned from MIPROv2.compile.
class MyAgent(Module):
def __init__(self):
super().__init__()
self.predict = dspy.ReAct("question -> answer", tools=[self.weather_function])
def weather_function(self):
return random.random()
optimizer = MIPROv2(metric=dspy.evaluate.answer_exact_match, auto="light")
compiled_agent = optimizer.compile(student=MyAgent(), trainset=trainset, teacher=teacher, valset=valset)
print(compiled_agent.weather_function())This can be a small nuisance for certain workflows where you want to extend the functionality of a dspy.Module with certain functions and attributes. And it can be easily fixed using TypeVars.
Just made the PR stanfordnlp#9013 to solve this but realized I should have added an issue first. Also wanted to gauge how important this is to others given its such a small change.
Would you like to contribute?
- Yes, I'd like to help implement this.
- No, I just want to request it.
Additional Context
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request