Skip to content

Commit

Permalink
Support url searchParams
Browse files Browse the repository at this point in the history
Signed-off-by: Jay Wang <jay@zijie.wang>
  • Loading branch information
xiaohk committed Feb 9, 2024
1 parent 17f3fcf commit 7c58857
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
33 changes: 32 additions & 1 deletion examples/rag-playground/src/components/app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,37 @@ import componentCSS from './app.css?inline';
import logoIcon from '../../images/icon-logo.svg?raw';
import { Dataset } from '../playground/playground';

let defaultDataset = Dataset.arXiv10k;

// Check url query to change the view
if (window.location.search !== '') {
const searchParams = new URLSearchParams(window.location.search);
if (searchParams.has('dataset')) {
const modelName = searchParams.get('dataset')!;

switch (modelName) {
case 'paper': {
defaultDataset = Dataset.arXiv10k;
break;
}

case 'diffusiondb': {
defaultDataset = Dataset.DiffusionDB10k;
break;
}

case 'accident': {
defaultDataset = Dataset.accident3k;
break;
}

default: {
break;
}
}
}
}

/**
* App element.
*
Expand All @@ -24,7 +55,7 @@ export class MememoRagPlayground extends LitElement {
//==========================================================================||
constructor() {
super();
this.curDataset = Dataset.arXiv1k;
this.curDataset = defaultDataset;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class MememoPlayground extends LitElement {
// Class Properties ||
//==========================================================================||
@property()
curDataset: Dataset = Dataset.arXiv10k;
curDataset!: Dataset;

@state()
userQuery = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class MememoQueryBox extends LitElement {
//==========================================================================||
constructor() {
super();
this.userQuery = this.defaultQuery;
this.userQuery = '';
}

firstUpdated() {
Expand Down
2 changes: 1 addition & 1 deletion examples/rag-playground/src/config/userQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const arXivQueries = [
];

const diffusiondbQueries: string[] = [
'A cute brown dog jumping around',
'A cute brown dog jumps around the tree',
'White dog wandering through a dense forest',
'Red apple resting on an aged wooden table',
'Sunny field dotted with vibrant sunflowers',
Expand Down
2 changes: 1 addition & 1 deletion examples/rag-playground/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default defineConfig(({ command, mode }) => {
case 'github': {
// Production: github page (default mode)
return {
base: '/wordflow/',
base: '/mememo/',
build: {
outDir: 'dist',
rollupOptions: {
Expand Down

0 comments on commit 7c58857

Please sign in to comment.