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

feat: Support langchain transformer on fabric #2036

Merged
merged 6 commits into from
Aug 10, 2023

Conversation

lhrotk
Copy link
Contributor

@lhrotk lhrotk commented Jul 31, 2023

Related Issues/PRs

N/A

What changes are proposed in this pull request?

Make Langchain transformer use fabric internal endpoints by default

How is this patch tested?

Manually tested on fabric

  • I have written tests (not required for typo or doc fix) and confirmed the proposed feature/bug-fix/change works.

Does this PR change any dependencies?

  • No. You can skip this section.
  • Yes. Make sure the dependencies are resolved correctly, and list changes here.

Does this PR add a new feature? If so, have you added samples on website?

  • No. You can skip this section.
  • Yes. Make sure you have added samples following below steps.

@github-actions
Copy link

Hey @lhrotk 👋!
Thank you so much for contributing to our repository 🙌.
Someone from SynapseML Team will be reviewing this pull request soon.

We use semantic commit messages to streamline the release process.
Before your pull request can be merged, you should make sure your first commit and PR title start with a semantic prefix.
This helps us to create release messages and credit you for your hard work!

Examples of commit messages with semantic prefixes:

  • fix: Fix LightGBM crashes with empty partitions
  • feat: Make HTTP on Spark back-offs configurable
  • docs: Update Spark Serving usage
  • build: Add codecov support
  • perf: improve LightGBM memory usage
  • refactor: make python code generation rely on classes
  • style: Remove nulls from CNTKModel
  • test: Add test coverage for CNTKModel

To test your commit locally, please follow our guild on building from source.
Check out the developer guide for additional guidance on testing your change.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary by GPT-4

This code change adds support for running the LangchainTransform on Synapse internal platform. It checks if the code is running on Synapse internal platform and sets the default URL accordingly. If the URL is not set and the code is running on Synapse internal, it initializes a personalized session using OpenAIPrerun. Otherwise, it uses the provided subscription key, URL, and API version to configure OpenAI API.

Here's a summary of the changes:

  1. Import running_on_synapse_internal from synapse.ml.core.platform.
  2. Check if running on Synapse internal platform using running_on_synapse_internal().
  3. If running on Synapse internal platform, set the default URL using get_fabric_env_config().fabric_env_config.ml_workload_endpoint + "cognitive/openai".
  4. In _transform method, check if running on Synapse internal platform and URL is not set.
  5. If true, initialize a personalized session using OpenAIPrerun(api_base=self.getUrl()).init_personalized_session(None).
  6. Else, configure OpenAI API using provided subscription key, URL, and API version.

This change allows LangchainTransform to work seamlessly both on Synapse internal platform and other platforms by automatically configuring the appropriate settings based on the environment it's running in.

Suggestions

The changes in this PR seem to be well-implemented and do not require any suggestions for improvement.

Copy link
Collaborator

@mhamilton723 mhamilton723 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question for ya

Comment on lines 130 to 134
self.useFabricInternalEndpoints = Param(self, "useFabricInternalEndpoints", "use internal openai endpoints when on fabric")
self.running_on_synapse_internal = running_on_synapse_internal()
if running_on_synapse_internal():
from synapse.ml.fabric.service_discovery import get_fabric_env_config
self.fabric_env_config = get_fabric_env_config()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any way to do this more implicitly without an explicit new param that users need to set? Im thinking that if a user doesent set the url and its on fabric it defaults to the fabric one if it can find one, otherwise it will throw an error

Copy link
Contributor Author

@lhrotk lhrotk Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get your point, it is possible to pass only the openai api_base. I will make the change

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THanks boss

mhamilton723
mhamilton723 previously approved these changes Aug 7, 2023
@mhamilton723 mhamilton723 changed the title Support langchain transformer on fabric feat: Support langchain transformer on fabric Aug 7, 2023
@mhamilton723
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@codecov-commenter
Copy link

codecov-commenter commented Aug 7, 2023

Codecov Report

Merging #2036 (1df2201) into master (149c634) will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2036      +/-   ##
==========================================
- Coverage   87.03%   87.02%   -0.01%     
==========================================
  Files         306      306              
  Lines       16063    16063              
  Branches      852      852              
==========================================
- Hits        13980    13979       -1     
- Misses       2083     2084       +1     

see 1 file with indirect coverage changes

@mhamilton723
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mhamilton723 mhamilton723 merged commit 8f794c8 into microsoft:master Aug 10, 2023
68 checks passed
JessicaXYWang pushed a commit to JessicaXYWang/SynapseML that referenced this pull request Sep 14, 2023
* support langchain transformer on fabric

* avoid addtional param

* format code

---------

Co-authored-by: cruise <[email protected]>
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.

4 participants