Skip to content

Commit

Permalink
issue #6: add hit hightlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
k-allagbe committed Nov 30, 2023
1 parent 48e2e4b commit 17d68f5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,8 @@ FINESSE_WEIGHTS=<Finesse-Weights>
# Example: ada
OPENAI_API_ENGINE=<OpenAI-API-Engine>

# Fields to highlight in Azure Cognitive Search responses. Optional.
# FINESSE_BACKEND_HIGHLIGHT_FIELDS=content

# HTML tag used for highlighting in Azure Cognitive Search responses. Optional.
# FINESSE_BACKEND_HIGHLIGHT_TAG=strong
8 changes: 4 additions & 4 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
DEFAULT_SANITIZE_PATTERN = (
"[^\w \d\"#\$%&'\(\)\*\+,-\.\/:;?@\^_`{\|}~]+|\%\w+|;|/|\(|\)"
)

DEFAULT_HIGHLIGHT_FIELDS = "content"
DEFAULT_HIGHLIGHT_TAG = "strong"

@dataclass
class Config:
AZURE_CONFIG = AzureIndexSearchConfig(
endpoint=os.getenv("FINESSE_BACKEND_AZURE_SEARCH_ENDPOINT"),
api_key=os.getenv("FINESSE_BACKEND_AZURE_SEARCH_API_KEY"),
index_name=os.getenv("FINESSE_BACKEND_AZURE_SEARCH_INDEX_NAME"),
client=SearchClient(
os.getenv("FINESSE_BACKEND_AZURE_SEARCH_ENDPOINT"),
os.getenv("FINESSE_BACKEND_AZURE_SEARCH_INDEX_NAME"),
AzureKeyCredential(os.getenv("FINESSE_BACKEND_AZURE_SEARCH_API_KEY")),
),
highlight_fields=os.getenv("FINESSE_BACKEND_HIGHLIGHT_FIELDS", DEFAULT_HIGHLIGHT_FIELDS),
highlight_tag=os.getenv("FINESSE_BACKEND_HIGHLIGHT_TAG", DEFAULT_HIGHLIGHT_TAG),
)
FINESSE_DATA_URL = os.getenv("FINESSE_BACKEND_STATIC_FILE_URL")
DEBUG = (
Expand Down
4 changes: 3 additions & 1 deletion tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

@dataclass
class TestAzureSearchConfig:
client = Mock()
endpoint = "endpoint"
api_key = "api_key"
index_name = "index"
client = Mock()
highlight_fields = "content"
highlight_tag = "strong"


@dataclass
Expand Down

0 comments on commit 17d68f5

Please sign in to comment.