fix(core): support fetch option#721
Open
taiichiro-nagase wants to merge 2 commits intolangfuse:mainfrom
Open
Conversation
|
@taiichiro-nagase is attempting to deploy a commit to the langfuse Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Greptile found no issues!From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section. This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR". |
676f530 to
dc634d2
Compare
Author
|
@hassiebp |
|
Any updates? @hassiebp. We are looking for a fix for the same issue with custom fetch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Self-hosted developers need to customize HTTP request behavior for testing, proxying, logging, or using custom fetch implementations (e.g., in specific environments or with custom headers/interceptors). Currently, there's no way to inject a custom fetch function into the Langfuse client.
Changes
Added support for custom fetch functions throughout the Langfuse SDK:
Example usage:
Release info Sub-libraries affected
Bump level
Libraries affected
Changelog notes
Disclaimer: Experimental PR review
Greptile Summary
This PR adds support for custom
fetchfunctions throughout the Langfuse SDK, enabling users to inject custom HTTP request behavior for testing, proxying, logging, or using alternative fetch implementations.Key changes:
fetch?: typeof fetchoption toLangfuseClientParamsinterface with clear documentation and example usageLangfuseClient→LangfuseAPIClient→ all 26 resource clients →core.fetcherFetcher.ts: uses custom fetch if provided, otherwise falls back togetFetchFn()Implementation quality:
typeof fetch(noanycasts)Confidence Score: 5/5
typeof fetch. All 26 resource clients were updated uniformly with the same pattern, showing thorough and systematic implementation. The fallback logic is simple and correct.Important Files Changed
Sequence Diagram
sequenceDiagram participant User participant LangfuseClient participant LangfuseAPIClient participant ResourceClient participant Fetcher participant CustomFetch User->>LangfuseClient: new LangfuseClient({fetch: customFetch}) LangfuseClient->>LangfuseAPIClient: new LangfuseAPIClient({fetch: customFetch}) LangfuseAPIClient->>LangfuseAPIClient: Store fetch in _options User->>LangfuseClient: api.prompts.list() LangfuseClient->>ResourceClient: prompts.list() ResourceClient->>Fetcher: core.fetcher({fetch: this._options.fetch}) alt Custom fetch provided Fetcher->>CustomFetch: Use args.fetch CustomFetch-->>Fetcher: Response else No custom fetch Fetcher->>Fetcher: Use getFetchFn() (default) Fetcher-->>Fetcher: Response end Fetcher-->>ResourceClient: API Response ResourceClient-->>LangfuseClient: Data LangfuseClient-->>User: Result