Disable Gpt4all due to mac not supporting it currently (#233)

This commit is contained in:
Yuhong Sun 2023-07-25 22:19:15 -07:00 committed by GitHub
parent e019db0bc7
commit 273802eff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 10 deletions

View File

@ -35,9 +35,12 @@ BATCH_SIZE_ENCODE_CHUNKS = 8
# Valid list:
# - openai-completion
# - openai-chat-completion
# - gpt4all-completion
# - gpt4all-chat-completion
INTERNAL_MODEL_VERSION = os.environ.get("INTERNAL_MODEL", "openai-chat-completion")
# - gpt4all-completion -> Due to M1 Macs not having compatible gpt4all version, please install dependency yourself
# - gpt4all-chat-completion-> Due to M1 Macs not having compatible gpt4all version, please install dependency yourself
# To use gpt4all, run: pip install --upgrade gpt4all==1.0.5
INTERNAL_MODEL_VERSION = os.environ.get(
"INTERNAL_MODEL_VERSION", "openai-chat-completion"
)
# For GPT4ALL, use "ggml-model-gpt4all-falcon-q4_0.bin" for the below for a tested model
GEN_AI_MODEL_VERSION = os.environ.get("GEN_AI_MODEL_VERSION", "gpt-3.5-turbo")
GEN_AI_MAX_OUTPUT_TOKENS = 512

View File

@ -3,14 +3,16 @@ from typing import Any
from danswer.configs.app_configs import QA_TIMEOUT
from danswer.configs.model_configs import INTERNAL_MODEL_VERSION
from danswer.direct_qa.exceptions import UnknownModelError
from danswer.direct_qa.gpt_4_all import GPT4AllChatCompletionQA
from danswer.direct_qa.gpt_4_all import GPT4AllCompletionQA
from danswer.direct_qa.interfaces import QAModel
from danswer.direct_qa.open_ai import OpenAIChatCompletionQA
from danswer.direct_qa.open_ai import OpenAICompletionQA
from openai.error import AuthenticationError
from openai.error import Timeout
# Imports commented out temporarily due to incompatibility of gpt4all with M1 Mac hardware currently
# from danswer.direct_qa.gpt_4_all import GPT4AllChatCompletionQA
# from danswer.direct_qa.gpt_4_all import GPT4AllCompletionQA
def check_model_api_key_is_valid(model_api_key: str) -> bool:
if not model_api_key:
@ -41,9 +43,10 @@ def get_default_backend_qa_model(
return OpenAICompletionQA(timeout=timeout, api_key=api_key, **kwargs)
elif internal_model == "openai-chat-completion":
return OpenAIChatCompletionQA(timeout=timeout, api_key=api_key, **kwargs)
elif internal_model == "gpt4all-completion":
return GPT4AllCompletionQA(**kwargs)
elif internal_model == "gpt4all-chat-completion":
return GPT4AllChatCompletionQA(**kwargs)
# Note GPT4All is not supported for M1 Mac machines currently, removing until support is added
# elif internal_model == "gpt4all-completion":
# return GPT4AllCompletionQA(**kwargs)
# elif internal_model == "gpt4all-chat-completion":
# return GPT4AllChatCompletionQA(**kwargs)
else:
raise UnknownModelError(internal_model)

View File

@ -10,7 +10,9 @@ filelock==3.12.0
google-api-python-client==2.86.0
google-auth-httplib2==0.1.0
google-auth-oauthlib==1.0.0
gpt4all==1.0.5
# GPT4All library does not support M1 Mac architecture
# will reintroduce this when library version catches up
# gpt4all==1.0.5
httpcore==0.16.3
httpx==0.23.3
httpx-oauth==0.11.2

View File

@ -45,6 +45,8 @@ services:
- vector_db
restart: always
environment:
- INTERNAL_MODEL_VERSION=${INTERNAL_MODEL_VERSION:-openai-chat-completion}
- GEN_AI_MODEL_VERSION=${GEN_AI_MODEL_VERSION:-gpt-3.5-turbo}
- POSTGRES_HOST=relational_db
- QDRANT_HOST=vector_db
- TYPESENSE_HOST=search_engine