forked from opea-project/GenAIExamples
-
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.
Add Text2Image UI, UI tests, Readme, and Docker support (opea-project…
…#927) Signed-off-by: Yue, Wenjiao <wenjiao.yue@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c0643b7
commit c6fc92d
Showing
32 changed files
with
1,054 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,26 @@ | ||
# Copyright (C) 2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Use node 20.11.1 as the base image | ||
FROM node:20.11.1 | ||
|
||
# Update package manager and install Git | ||
RUN apt-get update -y && apt-get install -y git | ||
|
||
# Copy the front-end code repository | ||
COPY svelte /home/user/svelte | ||
|
||
# Set the working directory | ||
WORKDIR /home/user/svelte | ||
|
||
# Install front-end dependencies | ||
RUN npm install | ||
|
||
# Build the front-end application | ||
RUN npm run build | ||
|
||
# Expose the port of the front-end application | ||
EXPOSE 5173 | ||
|
||
# Run the front-end application in preview mode | ||
CMD ["npm", "run", "preview", "--", "--port", "5173", "--host", "0.0.0.0"] |
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,10 @@ | ||
[*] | ||
indent_style = tab | ||
|
||
[package.json] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.md] | ||
indent_style = space | ||
indent_size = 2 |
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,2 @@ | ||
BASE_URL = '/v1/text2image' | ||
|
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,13 @@ | ||
.DS_Store | ||
node_modules | ||
/build | ||
/.svelte-kit | ||
/package | ||
.env | ||
.env.* | ||
!.env.example | ||
|
||
# Ignore files for PNPM, NPM and YARN | ||
pnpm-lock.yaml | ||
package-lock.json | ||
yarn.lock |
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,34 @@ | ||
// Copyright (c) 2024 Intel Corporation | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
module.exports = { | ||
root: true, | ||
parser: "@typescript-eslint/parser", | ||
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"], | ||
plugins: ["svelte3", "@typescript-eslint", "neverthrow"], | ||
ignorePatterns: ["*.cjs"], | ||
overrides: [{ files: ["*.svelte"], processor: "svelte3/svelte3" }], | ||
settings: { | ||
"svelte3/typescript": () => require("typescript"), | ||
}, | ||
parserOptions: { | ||
sourceType: "module", | ||
ecmaVersion: 2020, | ||
}, | ||
env: { | ||
browser: true, | ||
es2017: true, | ||
node: true, | ||
}, | ||
}; |
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,13 @@ | ||
.DS_Store | ||
node_modules | ||
/build | ||
/.svelte-kit | ||
/package | ||
.env | ||
.env.* | ||
!.env.example | ||
|
||
# Ignore files for PNPM, NPM and YARN | ||
pnpm-lock.yaml | ||
package-lock.json | ||
yarn.lock |
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 @@ | ||
{"pluginSearchDirs": ["."], "overrides": [{"files": "*.svelte", "options": {"parser": "svelte"}}]} |
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 @@ | ||
# Text2Image Customized UI | ||
|
||
## 📸 Project Screenshots | ||
|
||
![project-screenshot](../../assets/img/text2img_init.png) | ||
![project-screenshot](../../assets/img/text2img_response.png) | ||
|
||
## 🧐 Features | ||
|
||
Here're some of the project's features: | ||
|
||
- Generate Images from Text: Enter the image description and the desired number of images, then wait for them to be generated. | ||
|
||
## 🛠️ Get it Running | ||
|
||
1. Clone the repo. | ||
|
||
2. cd command to the current folder. | ||
|
||
3. Modify the required .env variables. | ||
|
||
``` | ||
BACKEND_BASE_URL = '' | ||
``` | ||
|
||
4. Execute `npm install` to install the corresponding dependencies. | ||
|
||
5. Execute `npm run dev` in both environments |
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,61 @@ | ||
{ | ||
"name": "sveltekit-auth-example", | ||
"version": "0.0.1", | ||
"private": true, | ||
"scripts": { | ||
"dev": "vite dev", | ||
"build": "vite build", | ||
"preview": "vite preview", | ||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", | ||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", | ||
"lint": "prettier --check . && eslint .", | ||
"format": "prettier --write ." | ||
}, | ||
"devDependencies": { | ||
"@fortawesome/free-solid-svg-icons": "6.2.0", | ||
"@playwright/test": "^1.48.0", | ||
"@sveltejs/adapter-auto": "1.0.0-next.75", | ||
"@sveltejs/adapter-static": "^3.0.0", | ||
"@sveltejs/kit": "^2.0.0", | ||
"@tailwindcss/typography": "0.5.7", | ||
"@types/debug": "4.1.7", | ||
"@types/node": "^20.12.13", | ||
"@typescript-eslint/eslint-plugin": "^5.27.0", | ||
"@typescript-eslint/parser": "^5.27.0", | ||
"autoprefixer": "^10.4.7", | ||
"daisyui": "3.5.1", | ||
"date-picker-svelte": "^2.6.0", | ||
"debug": "4.3.4", | ||
"eslint": "^8.16.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-neverthrow": "1.1.4", | ||
"postcss": "^8.4.31", | ||
"postcss-load-config": "^4.0.1", | ||
"postcss-preset-env": "^8.3.2", | ||
"prettier": "^2.8.8", | ||
"prettier-plugin-svelte": "^2.7.0", | ||
"prettier-plugin-tailwindcss": "^0.3.0", | ||
"svelte": "^4.0.0", | ||
"svelte-check": "^3.0.0", | ||
"svelte-fa": "3.0.3", | ||
"svelte-preprocess": "^6.0.2", | ||
"tailwindcss": "^3.1.5", | ||
"tslib": "^2.3.1", | ||
"typescript": "^5.0.0", | ||
"vite": "^5.0.0" | ||
}, | ||
"type": "module", | ||
"dependencies": { | ||
"date-fns": "^2.30.0", | ||
"driver.js": "^1.3.0", | ||
"flowbite-svelte": "^0.38.5", | ||
"flowbite-svelte-icons": "^1.4.0", | ||
"fuse.js": "^6.6.2", | ||
"lodash": "^4.17.21", | ||
"playwright": "^1.44.0", | ||
"ramda": "^0.29.0", | ||
"sse.js": "^0.6.1", | ||
"svelte-notifications": "^0.9.98", | ||
"svrollbar": "^0.12.0" | ||
} | ||
} |
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,54 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { defineConfig, devices } from "@playwright/test"; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// require('dotenv').config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: "./tests", | ||
/* Maximum time one test can run for. */ | ||
timeout: 10 * 60 * 1000, | ||
expect: { | ||
/** | ||
* Maximum time expect() should wait for the condition to be met. | ||
* For example in `await expect(locator).toHaveText();` | ||
*/ | ||
timeout: 5000, | ||
}, | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: [["html", { open: "never" }]], | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ | ||
actionTimeout: 0, | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: "http://localhost:5173", | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: "on-first-retry", | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: "webkit", | ||
use: { ...devices["Desktop Safari"] }, | ||
}, | ||
], | ||
}); |
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 Intel Corporation | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
const tailwindcss = require("tailwindcss"); | ||
const autoprefixer = require("autoprefixer"); | ||
|
||
const config = { | ||
plugins: [ | ||
//Some plugins, like tailwindcss/nesting, need to run before Tailwind, | ||
tailwindcss(), | ||
//But others, like autoprefixer, need to run after, | ||
autoprefixer, | ||
], | ||
}; | ||
|
||
module.exports = config; |
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,16 @@ | ||
// Copyright (c) 2024 Intel Corporation | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// See: https://kit.svelte.dev/docs/types#app | ||
// import { Result} from "neverthrow"; |
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,28 @@ | ||
<!-- | ||
Copyright (c) 2024 Intel Corporation | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="%sveltekit.assets%/favicon.png" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
%sveltekit.head% | ||
</head> | ||
<body> | ||
<div class="h-full w-full">%sveltekit.body%</div> | ||
</body> | ||
</html> |
Oops, something went wrong.