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

Add Proxy Support for Assistant API Calls in Assistance.ts #1343

Open
SaturninS opened this issue Dec 16, 2024 · 0 comments
Open

Add Proxy Support for Assistant API Calls in Assistance.ts #1343

SaturninS opened this issue Dec 16, 2024 · 0 comments

Comments

@SaturninS
Copy link

Describe the problem to be solved

Currently, the Assistance.ts module in app/server/lib handles API calls to external LLM endpoints (e.g., for the Assistant feature). However, these calls do not leverage the existing proxyAgent utility, which limits the flexibility for self-hosted deployments behind proxies.

Describe the solution you would like

Integrate the proxyAgent utility in Assistance.ts to enable proxy support for API calls. This would align the behavior of Assistance.ts with other modules like Requests.ts, Triggers.ts, and WidgetRepository.ts, which already implement proxy support.
Implementation Details
File to update: app/server/lib/Assistance.ts
Import the proxyAgent utility from app/server/lib/ProxyAgent.
Update the fetch implementation in Assistance.ts to include the agent option using proxyAgent.
`import fetch from 'node-fetch';
import { proxyAgent } from './ProxyAgent';

const GRIST_HTTPS_PROXY = process.env.GRIST_HTTPS_PROXY;

export const DEPS = {
fetch: async (url: string, options: any = {}) => {
const agent = GRIST_HTTPS_PROXY ? proxyAgent(new URL(url)) : undefined;
return fetch(url, { ...options, agent });
},
delayTime: 1000,
};
`
The functionality will only activate if the GRIST_HTTPS_PROXY environment variable is set.

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

1 participant