Added OpenAIAPI as an option for LangEngine.

tyler
xxmistacruzxx 2024-03-07 17:58:50 -05:00
parent 49c8d29a79
commit 23c63ee0db
2 changed files with 17 additions and 7 deletions

View File

@ -1,27 +1,28 @@
# DATABASE CONFIG
# DATABASE OPTIONS
DATABASE_NAME=postgres
DATABASE_HOST=127.0.0.1
DATABASE_USER=postgres
DATABASE_PASSWORD=testpassword
DATABASE_PORT=5432
# GENERAL CONFIG
# ANALYZATION OPTIONS
## GENERAL OPTIONS
ALT_WITH_CONTEXT=1
ALT_WITH_HASH=1
ALT_MULTITHREADED=0
## ALT_VERSION OPTIONS: 1, 2
### ALT_VERSION OPTIONS: 1, 2
ALT_VERSION=2
## DESC_ENGINE OPTIONS: replicateapi, bliplocal, googlevertexapi
DESC_ENGINE=replicateapi
## OCR_ENGINE OPTIONS: tesseract
OCR_ENGINE=tesseract
## LANG_ENGINE OPTIONS: privategpt
LANG_ENGINE=privategpt
## LANG_ENGINE OPTIONS: privategpt, openaiapi
LANG_ENGINE=openaiapi
# DESC_ENGINE CONFIG OPTIONS
## REPLICATEAPI
REPLICATE_KEY=example_key
REPLICATE_KEY=r8_somekey
## BLIPLOCAL
BLIPLOCAL_DIR=/path/to/image-captioning
## GOOGLEVERTEXAPI
@ -29,6 +30,10 @@ VERTEX_PROJECT_ID=example-123456
### VERTEX_LOCATION OPTIONS: https://cloud.google.com/vertex-ai/docs/general/locations
VERTEX_LOCATION=us-central1
VERTEX_GAC_PATH=/path/to/vertex-key.json
## OPENAIAPI
OPENAI_API_KEY=sk-1234567890
### OPENAI_MODEL OPTIONS: https://platform.openai.com/docs/models
OPENAI_MODEL=gpt-3.5-turbo
# OCR_ENGINE CONFIG OPTIONS
## TESSERACT

View File

@ -5,8 +5,9 @@ import bs4
from alttext import alttext
from alttext.descengine.bliplocal import BlipLocal
from alttext.descengine.replicateapi import ReplicateAPI
from alttext.langengine.privategpt import PrivateGPT
from alttext.ocrengine.tesseract import Tesseract
from alttext.langengine.openaiapi import OpenAIAPI
from alttext.langengine.privategpt import PrivateGPT
from django.core.files.storage import default_storage
from .postgres import books, images
@ -37,6 +38,10 @@ def createAnalyzer():
match os.environ["LANG_ENGINE"].lower():
case "privategpt":
langEngine = PrivateGPT(os.environ["PRIVATEGPT_HOST"])
case "openaiapi":
langEngine = OpenAIAPI(
os.environ["OPENAI_API_KEY"], os.environ["OPENAI_MODEL"]
)
case _:
raise ValueError("Invalid language engine")