mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-11-15 09:33:34 +00:00
Add Elasticsearch PORT and SCHEME in API config (#134)
This commit is contained in:
parent
ebb9e99b6c
commit
394ddab734
@ -6,7 +6,7 @@ from elasticsearch import Elasticsearch
|
|||||||
from fastapi import FastAPI, HTTPException
|
from fastapi import FastAPI, HTTPException
|
||||||
from starlette.middleware.cors import CORSMiddleware
|
from starlette.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
from haystack.api.config import DB_HOST, DB_USER, DB_PW, APM_SERVER, APM_SERVICE_NAME
|
from haystack.api.config import DB_HOST, DB_USER, DB_PW, DB_PORT, ES_CONN_SCHEME, APM_SERVER, APM_SERVICE_NAME
|
||||||
from haystack.api.controller.errors.http_error import http_error_handler
|
from haystack.api.controller.errors.http_error import http_error_handler
|
||||||
from haystack.api.controller.router import router as api_router
|
from haystack.api.controller.router import router as api_router
|
||||||
|
|
||||||
@ -15,12 +15,12 @@ logger = logging.getLogger(__name__)
|
|||||||
logging.getLogger("elasticsearch").setLevel(logging.WARNING)
|
logging.getLogger("elasticsearch").setLevel(logging.WARNING)
|
||||||
|
|
||||||
elasticsearch_client = Elasticsearch(
|
elasticsearch_client = Elasticsearch(
|
||||||
hosts=[{"host": DB_HOST}], http_auth=(DB_USER, DB_PW), scheme="http", ca_certs=False, verify_certs=False
|
hosts=[{"host": DB_HOST, "port": DB_PORT}], http_auth=(DB_USER, DB_PW), scheme=ES_CONN_SCHEME, ca_certs=False, verify_certs=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_application() -> FastAPI:
|
def get_application() -> FastAPI:
|
||||||
application = FastAPI(title="Haystack API", debug=True, version="0.1")
|
application = FastAPI(title="Haystack-API", debug=True, version="0.1")
|
||||||
|
|
||||||
application.add_middleware(
|
application.add_middleware(
|
||||||
CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"],
|
CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"],
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
import ast
|
import ast
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
# FastAPI
|
||||||
|
PROJECT_NAME = os.getenv("PROJECT_NAME", "FastAPI")
|
||||||
|
|
||||||
# Resources / Computation
|
# Resources / Computation
|
||||||
USE_GPU = os.getenv("USE_GPU", "True").lower() == "true"
|
USE_GPU = os.getenv("USE_GPU", "True").lower() == "true"
|
||||||
MAX_PROCESSES = int(os.getenv("MAX_PROCESSES", 4))
|
MAX_PROCESSES = int(os.getenv("MAX_PROCESSES", 4))
|
||||||
|
|||||||
@ -8,6 +8,7 @@ from pydantic import BaseModel, Field
|
|||||||
|
|
||||||
from haystack.api.config import (
|
from haystack.api.config import (
|
||||||
DB_HOST,
|
DB_HOST,
|
||||||
|
DB_PORT,
|
||||||
DB_USER,
|
DB_USER,
|
||||||
DB_PW,
|
DB_PW,
|
||||||
DB_INDEX,
|
DB_INDEX,
|
||||||
@ -26,6 +27,7 @@ router = APIRouter()
|
|||||||
|
|
||||||
document_store = ElasticsearchDocumentStore(
|
document_store = ElasticsearchDocumentStore(
|
||||||
host=DB_HOST,
|
host=DB_HOST,
|
||||||
|
port=DB_PORT,
|
||||||
username=DB_USER,
|
username=DB_USER,
|
||||||
password=DB_PW,
|
password=DB_PW,
|
||||||
index=DB_INDEX,
|
index=DB_INDEX,
|
||||||
|
|||||||
@ -8,7 +8,7 @@ from fastapi import HTTPException
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from haystack import Finder
|
from haystack import Finder
|
||||||
from haystack.api.config import DB_HOST, DB_USER, DB_PW, DB_INDEX, ES_CONN_SCHEME, TEXT_FIELD_NAME, SEARCH_FIELD_NAME, \
|
from haystack.api.config import DB_HOST, DB_PORT, DB_USER, DB_PW, DB_INDEX, ES_CONN_SCHEME, TEXT_FIELD_NAME, SEARCH_FIELD_NAME, \
|
||||||
EMBEDDING_DIM, EMBEDDING_FIELD_NAME, EXCLUDE_META_DATA_FIELDS, EMBEDDING_MODEL_PATH, USE_GPU, READER_MODEL_PATH, \
|
EMBEDDING_DIM, EMBEDDING_FIELD_NAME, EXCLUDE_META_DATA_FIELDS, EMBEDDING_MODEL_PATH, USE_GPU, READER_MODEL_PATH, \
|
||||||
BATCHSIZE, CONTEXT_WINDOW_SIZE, TOP_K_PER_CANDIDATE, NO_ANS_BOOST, MAX_PROCESSES, MAX_SEQ_LEN, DOC_STRIDE, \
|
BATCHSIZE, CONTEXT_WINDOW_SIZE, TOP_K_PER_CANDIDATE, NO_ANS_BOOST, MAX_PROCESSES, MAX_SEQ_LEN, DOC_STRIDE, \
|
||||||
DEFAULT_TOP_K_READER, DEFAULT_TOP_K_RETRIEVER, CONCURRENT_REQUEST_PER_WORKER
|
DEFAULT_TOP_K_READER, DEFAULT_TOP_K_RETRIEVER, CONCURRENT_REQUEST_PER_WORKER
|
||||||
@ -23,6 +23,7 @@ router = APIRouter()
|
|||||||
# Init global components: DocumentStore, Retriever, Reader, Finder
|
# Init global components: DocumentStore, Retriever, Reader, Finder
|
||||||
document_store = ElasticsearchDocumentStore(
|
document_store = ElasticsearchDocumentStore(
|
||||||
host=DB_HOST,
|
host=DB_HOST,
|
||||||
|
port=DB_PORT,
|
||||||
username=DB_USER,
|
username=DB_USER,
|
||||||
password=DB_PW,
|
password=DB_PW,
|
||||||
index=DB_INDEX,
|
index=DB_INDEX,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user