Skip to content

Commit

Permalink
add httpx proxy client for embedded model
Browse files Browse the repository at this point in the history
  • Loading branch information
shamspias committed Feb 26, 2024
1 parent 2638a98 commit 0accea1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion backend/app/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import annotations

import os
import httpx
from typing import Any, BinaryIO, List, Optional

from langchain.text_splitter import RecursiveCharacterTextSplitter, TextSplitter
Expand Down Expand Up @@ -106,10 +107,17 @@ def batch(
index_schema = {
"tag": [{"name": "namespace"}],
}

proxy_url = os.getenv("PROXY_URL")
if proxy_url is not None and proxy_url != "":
http_client = httpx.Client(proxies=proxy_url)
else:
http_client = None

vstore = Redis(
redis_url=os.environ["REDIS_URL"],
index_name="opengpts",
embedding=OpenAIEmbeddings(),
embedding=OpenAIEmbeddings(http_client=http_client),
index_schema=index_schema,
)

Expand Down

0 comments on commit 0accea1

Please sign in to comment.