Replies: 2 comments 2 replies
-
Based on the context provided, it seems you're trying to route all requests from LangChain JS through a corporate proxy. This can be achieved by using the Here's an example of how you can configure LangChain JS to use a corporate proxy when making requests to AzureOpenAI: const { HttpsProxyAgent } = require('https-proxy-agent');
const { AzureOpenAI } = require('langchain-openai'); // Assuming this is how you import AzureOpenAI
// Configure your corporate proxy settings
const proxyUrl = 'http://your-corporate-proxy:port';
const proxyAgent = new HttpsProxyAgent(proxyUrl);
// Create AzureOpenAI instance with proxy configuration
const azureOpenAI = new AzureOpenAI({
azureOpenAIApiKey: 'your-azure-openai-api-key',
azureOpenAIApiInstanceName: 'your-instance-name',
azureOpenAIApiDeploymentName: 'your-deployment-name',
options: {
httpAgent: proxyAgent, // Use httpAgent or httpsAgent based on your proxy protocol
},
});
// Now you can use azureOpenAI instance to make requests that will be routed through the corporate proxy In this example, the Also, remember to replace placeholders like This solution is based on the structure of the export type OpenAICoreRequestOptions<
Req extends object = Record<string, unknown>
> = {
path?: string;
query?: Req | undefined;
body?: Req | undefined;
headers?: Record<string, string | null | undefined> | undefined;
maxRetries?: number;
stream?: boolean | undefined;
timeout?: number;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
httpAgent?: any;
signal?: AbortSignal | undefined | null;
idempotencyKey?: string;
}; You can find more details about this interface in the LangChain JS codebase. Please try this solution and let me know if it works for you or if you need further assistance. Sources
|
Beta Was this translation helpful? Give feedback.
-
Has anyone found a solution to this? @corrreia |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
none
Description
I'm deploying Langchain behind a corporate proxy and I can't get langchain to send all requests to the proxy. I'm using AzureOpenAI and already tried many of the supposed solutions, none of them worked.
Is there any way to make this the right way?
System Info
RHEL 8
Docker
Node version 20
Beta Was this translation helpful? Give feedback.
All reactions