Skip to content

Conversation

@mkotlarz
Copy link

in langchain.py import Old Fields as Fields

This is a short-term fix until langchain.py can be migrated to the new Pydantic fields

in langchain.py import Old Fields as Fields
@arnavsinghvi11
Copy link
Collaborator

Thanks for the PR @mkotlarz !

From #887 , I'm curious if removing the specified finalized lines would correct the change instead of modifying the import? Ideally, we'd like to keep "new" versions over legacy, and handle code changes accordingly.

@mkotlarz
Copy link
Author

I agree with you, I dont like it either, but short of rewriting langchain pieces, which i may take a stab at later, its the only thing I got to work without the real forensic change. Additionally langchain only supports pydantic 1. I have alot of langchain code, and there is so much synergy between the two platforms, i may build some more bridges. Agent tools is another example.. I honestly didnt want to waste time learning the old DSPY fields code, when this stuff is moving so fast.

@arnavsinghvi11
Copy link
Collaborator

ah this is not rewriting langchain code, but rather the lines in langchain.py that may not be needed given the new dspy.InputField and dspy.OutputField. Does removing those lines resolve the issue?

            v.finalize(k, infer_prefix(k))  # TODO: Generate from the template at dspy.Predict(Template2Signature)

        for k, v in outputs.items():
            output_field_key = k
            v.finalize(k, infer_prefix(k))

If so, it makes sense to remove those than to refactor the imports to old DSPy field types. Let me know if that makes sense!

@mkotlarz
Copy link
Author

No, it didnt work.

File /opt/homebrew/Caskroom/miniforge/base/envs/hugface/lib/python3.12/site-packages/dsp/templates/template_v3.py:37, in Template.init(self, instructions, **kwargs)
30 self.format_handlers: dict[str, Callable] = {
31 "context": passages2text,
32 "passages": passages2text,
33 "answers": format_answers,
34 }
36 for key, value in kwargs.items():
---> 37 if value.prefix:
38 prefix: str = value.prefix
39 else:

AttributeError: 'FieldInfo' object has no attribute 'prefix'

@arnavsinghvi11
Copy link
Collaborator

Thanks for checking @mkotlarz . Could you run ruff check . --fix-only and push again? Should be good to merge after that!

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.

2 participants