-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Removed deprecated folders * Renamed to Lettuce to be clear * Update .gitignore Removed references to deprecated folders. Updated references to Carrot-Assistant * renamed doc files folder * Black formatting * removed cl args from pipeline * eot_token from model * More opt removal Removed opt from more parts of the llm pipelines * removed opt from database query * Update pipeline_routes.py removed opt from vector_llm_pipeline * Update pipeline_routes.py updated imports * docstrings * corrected tests tests to match no opt * tests * cli for rag/llm/vector search * cli with omop query * Update test_db.py * Started new docs * set paths for gh actions build * Working quickstart * Modifying auto-generated docs * evaluation docs * finish basic docs * switch to gh actions for doc deployment * Update _meta.js * Update deploy.docs.yml now deploys on pushes to main
- Loading branch information
Showing
152 changed files
with
11,279 additions
and
11,615 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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: Deploy Documentation Site to GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
paths: | ||
- "website/**" | ||
|
||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Detect package manager | ||
id: detect-package-manager | ||
run: | | ||
if [ -f "website/yarn.lock" ]; then | ||
echo "manager=yarn" >> $GITHUB_OUTPUT | ||
echo "command=install" >> $GITHUB_OUTPUT | ||
echo "runner=yarn" >> $GITHUB_OUTPUT | ||
exit 0 | ||
elif [ -f "website/package.json" ]; then | ||
echo "manager=npm" >> $GITHUB_OUTPUT | ||
echo "command=ci" >> $GITHUB_OUTPUT | ||
echo "runner=npx --no-install" >> $GITHUB_OUTPUT | ||
exit 0 | ||
else | ||
echo "Unable to determine package manager" | ||
exit 1 | ||
fi | ||
- name: Setup Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "20" | ||
|
||
- name: Setup Pages | ||
uses: actions/configure-pages@v5 | ||
|
||
- name: Restore cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
.next/cache | ||
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} | ||
restore-keys: | | ||
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}- | ||
- name: Install dependencies | ||
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }} | ||
working-directory: website | ||
|
||
- name: Build with Next.js | ||
run: ${{ steps.detect-package-manager.outputs.runner }} next build | ||
working-directory: website | ||
|
||
- name: Copy built files to docs | ||
run: | | ||
rm -rf docs/* | ||
cp -r website/out docs/ | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: docs | ||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
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,87 @@ | ||
import time | ||
|
||
from components.embeddings import Embeddings, EmbeddingModelName | ||
from components.pipeline import llm_pipeline | ||
from components.result import LettuceResult | ||
from options.base_options import BaseOptions | ||
from options.pipeline_options import LLMModel | ||
import omop.OMOP_match | ||
from utils.logging_utils import logger | ||
|
||
|
||
def main(): | ||
opt = BaseOptions() | ||
opt.initialize() | ||
args = opt.parse() | ||
|
||
results = [LettuceResult(name) for name in args.informal_names] | ||
|
||
if args.vector_search & args.use_llm: | ||
start = time.time() | ||
pl = llm_pipeline( | ||
LLMModel[args.llm_model], | ||
args.temperature, | ||
logger=logger, | ||
embeddings_path="concept_embeddings.qdrant", | ||
embed_vocab=["RxNorm"], | ||
embedding_model=EmbeddingModelName.BGESMALL, | ||
).get_rag_assistant() | ||
pl.warm_up() | ||
logger.info(f"Pipeline warmup in {time.time() - start} seconds") | ||
|
||
run_start = time.time() | ||
|
||
for query in results: | ||
rag = pl.run( | ||
{ | ||
"query_embedder": {"text": query.search_term}, | ||
"prompt": {"informal_name": query.search_term}, | ||
}, | ||
include_outputs_from={"retriever", "llm"}, | ||
) | ||
query.add_vector_search_results( | ||
[ | ||
{"content": doc.content, "score": doc.score} | ||
for doc in rag["retriever"]["documents"] | ||
] | ||
) | ||
if "llm" in rag.keys(): | ||
query.add_llm_answer(rag["llm"]["replies"][0].strip()) | ||
logger.info(f"Total RAG inference time: {time.time()-run_start}") | ||
elif args.vector_search: | ||
embeddings = Embeddings( | ||
embeddings_path="concept_embeddings.qdrant", | ||
force_rebuild=False, | ||
embed_vocab=["RxNorm"], | ||
model_name=EmbeddingModelName.BGESMALL, | ||
search_kwargs={}, | ||
) | ||
embed_results = embeddings.search(args.informal_names) | ||
for query, result in zip(results, embed_results): | ||
query.add_vector_search_results(result) | ||
elif args.use_llm: | ||
run_start = time.time() | ||
pipeline = llm_pipeline( | ||
llm_model=LLMModel[args.llm_model], | ||
temperature=args.temperature, | ||
logger=logger, | ||
).get_simple_assistant() | ||
pipeline.warm_up() | ||
|
||
for query in results: | ||
res = pipeline.run({"prompt": {"informal_name": query.search_term}}) | ||
query.add_llm_answer(res["llm"]["replies"][0].strip()) | ||
|
||
db_queries = [query.get_query() for query in results] | ||
|
||
db_results = omop.OMOP_match.run( | ||
search_term=db_queries, | ||
logger=logger, | ||
vocabulary_id=args.vocabulary_id, | ||
search_threshold=args.search_threshold, | ||
) | ||
|
||
for query, result in zip(results, db_results): | ||
query.add_matches(result, args.search_threshold) | ||
|
||
print([result.to_dict() for result in results]) |
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
Oops, something went wrong.