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

Undefined output_mapping in DEMOS optimization #247

Open
mrdrprofuroboros opened this issue Oct 29, 2024 · 2 comments
Open

Undefined output_mapping in DEMOS optimization #247

mrdrprofuroboros opened this issue Oct 29, 2024 · 2 comments

Comments

@mrdrprofuroboros
Copy link

Describe the bug

File ~/opt/anaconda3/envs/aimon/lib/python3.11/site-packages/adalflow/core/generator.py:849, in Generator.__call__(self, *args, **kwargs)
    847 if self.training:
    848     log.debug(\"Training mode\")
--> 849     return self.forward(*args, **kwargs)
    850 else:
    851     log.debug(\"Inference mode\")

File ~/opt/anaconda3/envs/aimon/lib/python3.11/site-packages/adalflow/core/generator.py:507, in Generator.forward(self, prompt_kwargs, model_kwargs, id)
    502     if id is None:
    503         raise ValueError(
    504             \"ID is required for tracing. Please pass it to your Geneartor call.\"
    505         )
--> 507     demo = self.create_demo_data_instance(
    508         prompt_kwargs,
    509         output,
    510         id=id,
    511     )
    512     demo_param.add_to_trace(demo, is_teacher=self.teacher_mode)
    513 else:

File ~/opt/anaconda3/envs/aimon/lib/python3.11/site-packages/adalflow/core/generator.py:377, in Generator.create_demo_data_instance(self, input_prompt_kwargs, output, id)
    375 # map the input fields
    376 demo_data = {\"id\": id}
--> 377 demo_data_class_output_mapping, output_fields = self._get_default_mapping(
    378     output
    379 )
    381 for k, v in input_prompt_kwargs.items():
    382     if isinstance(v, Parameter):

File ~/opt/anaconda3/envs/aimon/lib/python3.11/site-packages/adalflow/core/generator.py:215, in Generator._get_default_mapping(output)
    207     del output_mapping[\"raw_response\"]
    208 # elif output.error:
    209 #     output_fields = [\"raw_response\", \"error\"]
    210 #     output_mapping = {
   (...)
    213 #     }
    214 #     output_fields = [\"Answer\"]
--> 215 return output_mapping, output_fields

UnboundLocalError: cannot access local variable 'output_mapping' where it is not associated with a value"

To Reproduce
train openai gpt-4o with ParameterType.DEMOS

Expected behavior
graceful handling of the error

@liyin2015
Copy link
Member

@mrdrprofuroboros it is hard to see the error without the context. Is there any code reference?

@fm1320
Copy link
Collaborator

fm1320 commented Dec 20, 2024

@mrdrprofuroboros Hi, do you have more info on the code and where this happened ?

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

3 participants