-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hemslo Wang <[email protected]>
- Loading branch information
Showing
9 changed files
with
112 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
OPENAI_API_KEY= | ||
AUTH_TOKEN= | ||
CHAT_PROVIDER= | ||
EMBEDDING_DIM= | ||
EMBEDDING_PROVIDER= | ||
OLLAMA_CHAT_MODEL= | ||
OLLAMA_EMBEDDING_MODEL= | ||
OLLAMA_URL= | ||
OPENAI_API_KEY= | ||
OPENAI_CHAT_MODEL= | ||
OPENAI_EMBEDDING_MODEL= | ||
REDIS_URL= |
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,29 @@ | ||
from langchain_core.embeddings import Embeddings | ||
|
||
from app import config | ||
|
||
|
||
def _get_embeddings() -> Embeddings: | ||
match config.EMBEDDING_PROVIDER: | ||
case "openai": | ||
from langchain_openai import OpenAIEmbeddings | ||
|
||
return OpenAIEmbeddings( | ||
model=config.OPENAI_EMBEDDING_MODEL, | ||
) | ||
case "ollama": | ||
from langchain_community.embeddings import OllamaEmbeddings | ||
|
||
return OllamaEmbeddings( | ||
model=config.OLLAMA_EMBEDDING_MODEL, | ||
base_url=config.OLLAMA_URL, | ||
) | ||
case _: | ||
raise ValueError(f"Unknown embedding provider: {config.EMBEDDING_PROVIDER}") | ||
|
||
|
||
embeddings = _get_embeddings() | ||
|
||
|
||
def get_embeddings() -> Embeddings: | ||
return embeddings |
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,30 @@ | ||
from langchain_core.language_models import BaseChatModel | ||
|
||
from app import config | ||
|
||
|
||
def _get_llm() -> BaseChatModel: | ||
match config.CHAT_PROVIDER: | ||
case "openai": | ||
from langchain_openai import ChatOpenAI | ||
|
||
return ChatOpenAI( | ||
model=config.OPENAI_CHAT_MODEL, | ||
temperature=0, | ||
) | ||
case "ollama": | ||
from langchain_community.chat_models import ChatOllama | ||
|
||
return ChatOllama( | ||
model=config.OLLAMA_CHAT_MODEL, | ||
base_url=config.OLLAMA_URL, | ||
) | ||
case _: | ||
raise ValueError(f"Unknown chat provider: {config.CHAT_PROVIDER}") | ||
|
||
|
||
llm = _get_llm() | ||
|
||
|
||
def get_llm() -> BaseChatModel: | ||
return llm |
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,12 @@ | ||
services: | ||
redis: | ||
image: redis/redis-stack:6.2.6-v11 | ||
ports: | ||
- "6379:6379" | ||
- "8001:8001" | ||
environment: | ||
REDIS_ARGS: --save 60 1000 --appendonly yes | ||
volumes: | ||
- redis-data:/data | ||
volumes: | ||
redis-data: |
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