mayooear / gpt4-pdf-chatbot-langchain

GPT4 & LangChain Chatbot for large PDF docs
https://www.youtube.com/watch?v=ih9PBGVVOO4
14.92k stars 3.02k forks source link

use http proxy error #45

Closed glide-the closed 1 year ago

glide-the commented 1 year ago

project in the

import fetchAdapter from "../util/axios-fetch-adapter.js";

const clientConfig = new Configuration({
              ...this.clientConfig,
              baseOptions: { adapter: fetchAdapter },
          });

im edit this code

··· const clientConfig = new Configuration({ ...this.clientConfig, // baseOptions: { adapter: fetchAdapter }, }); const tunnelProxy = tunnel.httpsOverHttp({ proxy: { host: '127.0.0.1', port: 7890 }, }); // use custom axios instance const customAxios = axios.create({ proxy: false, httpsAgent: tunnelProxy, });

        this.batchClient = new OpenAIApi(clientConfig,BASE_PATH,customAxios);

···

Commented on this line

// baseOptions: { adapter: fetchAdapter },

scripts/ingest-data.ts by with http proxy run but utils/makechain.ts is error Because this conversation uses langchain/llms module ,in the module request code

 /** @ignore */
    async completionWithRetry(request) {
        if (!request.stream && !this.batchClient) {
            const clientConfig = new Configuration({
                ...this.clientConfig,
                baseOptions: { adapter: fetchAdapter },
            });
            this.batchClient = new OpenAIApi(clientConfig);
        }
        if (request.stream && !this.streamingClient) {
            const clientConfig = new Configuration(this.clientConfig);
            this.streamingClient = new OpenAIApi(clientConfig);
        }
        const client = !request.stream ? this.batchClient : this.streamingClient;
        const makeCompletionRequest = async () => client.createChatCompletion(request, request.stream ? { responseType: "stream" } : undefined);
        return backOff(makeCompletionRequest, {
            startingDelay: 4,
            maxDelay: 10,
            numOfAttempts: this.maxRetries,
            // TODO(sean) pass custom retry function to check error types.
        });
    }

at if (request.stream && !this.streamingClient) the line ,stream server error

I haven't found the proxy configuration for the fetchAdapter adapter from many places. Can I replace it with another adapter? im not open vpn .

mayooear commented 1 year ago

Have your tried tunnel? I think you may have to modify the completionWithRetry method to use a customAxios using tunnel proxy.

cndinx commented 1 year ago

image I commented out this section of code and now it's working.

glide-the commented 1 year ago

Have your tried tunnel? I think you may have to modify the completionWithRetry method to use a customAxios using tunnel proxy.

I did modify the module directly