-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add per workflow local embedding mode (#55)
* add local embeddings in workflow for MER * Add inline local embedding for QTD
- Loading branch information
Showing
12 changed files
with
65 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright (c) 2024 Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT license. See LICENSE file in the project. | ||
# | ||
import streamlit as st | ||
|
||
from app.util.openai_wrapper import UIOpenAIConfiguration | ||
from toolkit.AI.base_embedder import BaseEmbedder | ||
from toolkit.AI.local_embedder import LocalEmbedder | ||
from toolkit.AI.openai_embedder import OpenAIEmbedder | ||
from toolkit.query_text_data import config | ||
|
||
|
||
def embedder(local_embedding: bool | None = False) -> BaseEmbedder: | ||
try: | ||
ai_configuration = UIOpenAIConfiguration().get_configuration() | ||
if local_embedding: | ||
return LocalEmbedder( | ||
db_name=config.cache_name, | ||
max_tokens=ai_configuration.max_tokens, | ||
) | ||
return OpenAIEmbedder( | ||
configuration=ai_configuration, | ||
db_name=config.cache_name, | ||
) | ||
except Exception as e: | ||
st.error(f"Error creating connection: {e}") | ||
st.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.