Format code (#20)

* rename func

Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com>

* update version

Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com>

* format code

Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com>

---------

Signed-off-by: Sun, Xuehao <xuehao.sun@intel.com>
This commit is contained in:
Sun, Xuehao
2024-03-28 13:22:35 +08:00
committed by GitHub
parent b33fea6aec
commit 8e4fefab9d
102 changed files with 24441 additions and 11058 deletions

View File

@@ -1,9 +1,11 @@
Text summarization is an NLP task that creates a concise and informative summary of a longer text. LLMs can be used to create summaries of news articles, research papers, technical documents, and other types of text. Suppose you have a set of documents (PDFs, Notion pages, customer questions, etc.) and you want to summarize the content. In this example use case, we use LangChain to apply some summarization strategies and run LLM inference using Text Generation Inference on Intel Gaudi2.
# Environment Setup
To use [🤗 text-generation-inference](https://github.com/huggingface/text-generation-inference) on Habana Gaudi/Gaudi2, please follow these steps:
## Build TGI Gaudi Docker Image
```bash
bash ./serving/tgi_gaudi/build_docker.sh
```
@@ -11,19 +13,21 @@ bash ./serving/tgi_gaudi/build_docker.sh
## Launch TGI Gaudi Service
### Launch a local server instance on 1 Gaudi card:
```bash
bash ./serving/tgi_gaudi/launch_tgi_service.sh
```
For gated models such as `LLAMA-2`, you will have to pass -e HUGGING_FACE_HUB_TOKEN=\<token\> to the docker run command above with a valid Hugging Face Hub read token.
Please follow this link [huggingface token](https://huggingface.co/docs/hub/security-tokens) to get the access token ans export `HUGGINGFACEHUB_API_TOKEN` environment with the token.
Please follow this link [huggingface token](https://huggingface.co/docs/hub/security-tokens) to get the access token and export `HUGGINGFACEHUB_API_TOKEN` environment with the token.
```bash
export HUGGINGFACEHUB_API_TOKEN=<token>
```
### Launch a local server instance on 8 Gaudi cards:
```bash
bash ./serving/tgi_gaudi/launch_tgi_service.sh 8
```
@@ -31,11 +35,13 @@ bash ./serving/tgi_gaudi/launch_tgi_service.sh 8
### Customize TGI Gaudi Service
The ./serving/tgi_gaudi/launch_tgi_service.sh script accepts three parameters:
- num_cards: The number of Gaudi cards to be utilized, ranging from 1 to 8. The default is set to 1.
- port_number: The port number assigned to the TGI Gaudi endpoint, with the default being 8080.
- model_name: The model name utilized for LLM, with the default set to "Intel/neural-chat-7b-v3-3".
You have the flexibility to customize these parameters according to your specific needs. Additionally, you can set the TGI Gaudi endpoint by exporting the environment variable `TGI_ENDPOINT`:
```bash
export TGI_ENDPOINT="http://xxx.xxx.xxx.xxx:8080"
```
@@ -50,16 +56,16 @@ bash ./build_docker.sh
cd ../../
```
### Lanuch Document Summary Docker
### Launch Document Summary Docker
```bash
docker run -it --net=host --ipc=host -e http_proxy=${http_proxy} -e https_proxy=${https_proxy} -v /var/run/docker.sock:/var/run/docker.sock intel/gen-ai-examples:document-summarize bash
```
# Start Document Summary Server
## Start the Backend Service
Make sure TGI-Gaudi service is running. Launch the backend service:
```bash
@@ -69,7 +75,8 @@ nohup python app/server.py &
## Start the Frontend Service
Navigate to the "ui" folder and execute the following commands to start the fronend GUI:
Navigate to the "ui" folder and execute the following commands to start the frontend GUI:
```bash
cd ui
sudo apt-get install npm && \
@@ -89,11 +96,13 @@ sudo yum install -y nodejs
Update the `BASIC_URL` environment variable in the `.env` file by replacing the IP address '127.0.0.1' with the actual IP address.
Run the following command to install the required dependencies:
```bash
npm install
```
Start the development server by executing the following command:
```bash
nohup npm run dev &
```

View File

@@ -3,9 +3,9 @@ docx2txt
intel-extension-for-pytorch
intel-openmp
jupyter
langchain_benchmarks
langchain-cli
langchain==0.1.12
langchain-cli
langchain_benchmarks
poetry
pyarrow
pydantic==1.10.13

View File

@@ -11,7 +11,7 @@ pip install -U langchain-cli
## Adding packages
```bash
# adding packages from
# adding packages from
# https://github.com/langchain-ai/langchain/tree/master/templates
langchain app add $PROJECT_NAME
@@ -31,10 +31,10 @@ langchain app remove my/custom/path/rag
```
## Setup LangSmith (Optional)
LangSmith will help us trace, monitor and debug LangChain applications.
LangSmith is currently in private beta, you can sign up [here](https://smith.langchain.com/).
If you don't have access, you can skip this section
LangSmith will help us trace, monitor and debug LangChain applications.
LangSmith is currently in private beta, you can sign up [here](https://smith.langchain.com/).
If you don't have access, you can skip this section
```shell
export LANGCHAIN_TRACING_V2=true

View File

@@ -16,18 +16,16 @@
# limitations under the License.
import os
from fastapi import FastAPI, APIRouter, Request, UploadFile, File
from fastapi import APIRouter, FastAPI, File, Request, UploadFile
from fastapi.responses import RedirectResponse, StreamingResponse
from langchain_community.llms import HuggingFaceEndpoint
from langchain.chains.summarize import load_summarize_chain
from langchain.docstore.document import Document
from langchain.prompts import PromptTemplate
from langchain.text_splitter import CharacterTextSplitter
from langchain_community.llms import HuggingFaceEndpoint
from starlette.middleware.cors import CORSMiddleware
from utils import (
read_text_from_file,
get_current_beijing_time
)
from utils import get_current_beijing_time, read_text_from_file
prompt_template = """Write a concise summary of the following:
{text}
@@ -50,11 +48,9 @@ refine_prompt = PromptTemplate.from_template(refine_template)
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"])
CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"]
)
class DocSummaryAPIRouter(APIRouter):
@@ -62,8 +58,10 @@ class DocSummaryAPIRouter(APIRouter):
super().__init__()
self.upload_dir = upload_dir
self.entrypoint = entrypoint
print(f"[rag - router] Initializing API Router, params:\n \
upload_dir={upload_dir}, entrypoint={entrypoint}")
print(
f"[rag - router] Initializing API Router, params:\n \
upload_dir={upload_dir}, entrypoint={entrypoint}"
)
# Define LLM
self.llm = HuggingFaceEndpoint(
@@ -93,11 +91,12 @@ upload_dir = os.getenv("RAG_UPLOAD_DIR", "./upload_dir")
tgi_endpoint = os.getenv("TGI_ENDPOINT", "http://localhost:8080")
router = DocSummaryAPIRouter(upload_dir, tgi_endpoint)
@router.post("/v1/text_summarize")
async def text_summarize(request: Request):
params = await request.json()
print(f"[docsum - text_summarize] POST request: /v1/text_summarize, params:{params}")
text = params['text']
text = params["text"]
# Split text
text_splitter = CharacterTextSplitter()
@@ -107,12 +106,13 @@ async def text_summarize(request: Request):
async def stream_generator():
from langserve.serialization import WellKnownLCSerializer
_serializer = WellKnownLCSerializer()
async for chunk in router.llm_chain.astream_log(docs):
data = _serializer.dumps({"ops": chunk.ops}).decode("utf-8")
print(f"[docsum - text_summarize] data: {data}")
yield f"data: {data}\n\n"
yield f"data: [DONE]\n\n"
yield "data: [DONE]\n\n"
return StreamingResponse(stream_generator(), media_type="text/event-stream")
@@ -121,17 +121,18 @@ async def text_summarize(request: Request):
async def file_summarize(request: Request):
params = await request.json()
print(f"[docsum - file_summarize] POST request: /v1/file_summarize, params:{params}")
doc_id = params['doc_id']
doc_id = params["doc_id"]
text = router.doc_sotre[doc_id]
async def stream_generator():
from langserve.serialization import WellKnownLCSerializer
_serializer = WellKnownLCSerializer()
async for chunk in router.llm_chain.astream_log(text):
data = _serializer.dumps({"ops": chunk.ops}).decode("utf-8")
print(f"[docsum - file_summarize] data: {data}")
yield f"data: {data}\n\n"
yield f"data: [DONE]\n\n"
yield "data: [DONE]\n\n"
return StreamingResponse(stream_generator(), media_type="text/event-stream")
@@ -139,31 +140,33 @@ async def file_summarize(request: Request):
@router.post("/v1/doc_upload")
async def doc_upload(file: UploadFile = File(...)):
filename = file.filename
if '/' in filename:
filename = filename.split('/')[-1]
if "/" in filename:
filename = filename.split("/")[-1]
print(f"[docsum - upload] POST request: /v1/doc_upload, filename:{filename}")
# save file to local path
cur_time = get_current_beijing_time()
save_file_name = '/tmp/' + cur_time + '-' + filename
with open(save_file_name, 'wb') as fout:
save_file_name = "/tmp/" + cur_time + "-" + filename
with open(save_file_name, "wb") as fout:
content = await file.read()
fout.write(content)
print(f"[rag - create] file saved to local path: {save_file_name}")
doc_id, text = read_text_from_file(file, save_file_name)
router.doc_sotre[doc_id] = text
print(f"[docsum - upload] doc created successfully")
print("[docsum - upload] doc created successfully")
return {"document_id": doc_id}
app.include_router(router)
@app.get("/")
async def redirect_root_to_docs():
return RedirectResponse("/docs")
if __name__ == "__main__":
import uvicorn

View File

@@ -15,21 +15,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from bs4 import BeautifulSoup
import docx2txt
from langchain.document_loaders import PyPDFLoader
from langchain.docstore.document import Document
from langchain.text_splitter import CharacterTextSplitter
import re
import requests
import uuid
from datetime import timedelta, timezone, datetime
from datetime import datetime, timedelta, timezone
import docx2txt
import requests
from bs4 import BeautifulSoup
from langchain.docstore.document import Document
from langchain.document_loaders import PyPDFLoader
from langchain.text_splitter import CharacterTextSplitter
def get_current_beijing_time():
SHA_TZ = timezone(
timedelta(hours=8),
name='Asia/Shanghai'
)
SHA_TZ = timezone(timedelta(hours=8), name="Asia/Shanghai")
utc_now = datetime.utcnow().replace(tzinfo=timezone.utc)
beijing_time = utc_now.astimezone(SHA_TZ).strftime("%Y-%m-%d-%H:%M:%S")
return beijing_time
@@ -37,12 +36,12 @@ def get_current_beijing_time():
emoji_pattern = re.compile(
"["
u"\U0001F600-\U0001F64F" # emoticons
u"\U0001F300-\U0001F5FF" # symbols & pictographs
u"\U0001F680-\U0001F6FF" # transport & map symbols
u"\U0001F1E0-\U0001F1FF" # flags (iOS)
u"\U00002702-\U000027B0"
u"\U000024C2-\U0001F251"
"\U0001F600-\U0001F64F" # emoticons
"\U0001F300-\U0001F5FF" # symbols & pictographs
"\U0001F680-\U0001F6FF" # transport & map symbols
"\U0001F1E0-\U0001F1FF" # flags (iOS)
"\U00002702-\U000027B0"
"\U000024C2-\U0001F251"
"]+",
flags=re.UNICODE,
)
@@ -55,7 +54,7 @@ def clean_text(x):
x = re.sub(r"#\S+", " ", x) # hastags
x = re.sub(r"\s{2,}", " ", x) # over spaces
x = emoji_pattern.sub(r"", x) # emojis
x = re.sub("[^.,!?A-Za-z0-9]+", " ", x) # special charachters except .,!?
x = re.sub("[^.,!?A-Za-z0-9]+", " ", x) # special characters except .,!?
return x
@@ -97,7 +96,7 @@ def read_pdf(file):
def read_text_from_file(file, save_file_name):
# read text file
if file.headers["content-type"] == "text/plain":
if file.headers["content-type"] == "text/plain":
file.file.seek(0)
content = file.file.read().decode("utf-8")
# Split text
@@ -110,10 +109,7 @@ def read_text_from_file(file, save_file_name):
file_content = read_pdf(save_file_name)
# read docx file
elif (
file.headers["content-type"]
== "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
):
elif file.headers["content-type"] == "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
file_content = docx2txt.process(file)
doc_id = f"doc_{str(uuid.uuid1())[:8]}"

View File

@@ -7,7 +7,6 @@
![project-screenshot](https://imgur.com/KOSeGa8.png)
![project-screenshot](https://imgur.com/AWuBhjQ.png)
<h2>🧐 Features</h2>
Here're some of the project's features:
@@ -23,9 +22,9 @@ Here're some of the project's features:
2. cd command to the current folder.
3. Modify the required .env variables.
```
BASIC_URL = ''
```
```
BASIC_URL = ''
```
4. Execute `npm install` to install the corresponding dependencies.
5. Execute `npm run dev` in both enviroments
5. Execute `npm run dev` in both environments

View File

@@ -10180,4 +10180,3 @@
}
}
}

View File

@@ -1,3 +1,17 @@
// 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");

View File

@@ -1,3 +1,17 @@
// 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
// for information about these interfaces
declare global {

View File

@@ -1,12 +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, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div>%sveltekit.body%</div>
</body>
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div>%sveltekit.body%</div>
</body>
</html>

View File

@@ -1 +1,17 @@
<!--
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.
-->
<svg aria-hidden="true" class="mb-3 w-10 h-10 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" /></svg>

Before

Width:  |  Height:  |  Size: 319 B

After

Width:  |  Height:  |  Size: 910 B

View File

@@ -1,3 +1,19 @@
<!--
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.
-->
<svg
aria-hidden="true"
class="intel-brand-logo"
@@ -30,4 +46,4 @@ viewBox="0 0 103 42"
transform="translate(95.036 34)"
></path>
</g>
</svg>
</svg>

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -1,3 +1,19 @@
<!--
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.
-->
<div
class="mb-6 flex items-center justify-center self-center bg-black text-sm text-gray-500"
/>

View File

@@ -1,3 +1,19 @@
<!--
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.
-->
<svg
aria-hidden="true"
class="w-5 h-5 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -1,3 +1,19 @@
<!--
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.
-->
<svg
class="w-4 h-4"
aria-hidden="true"
@@ -11,4 +27,4 @@ viewBox="0 0 20 20"
<path
d="M8.139 10.411 5.289 13.3A1 1 0 0 0 5 14v2a1 1 0 0 0 1 1h2a1 1 0 0 0 .7-.288l2.886-2.851-3.447-3.45ZM14 8a2.463 2.463 0 0 0-3.484 0l-.971.983 3.468 3.468.987-.971A2.463 2.463 0 0 0 14 8Z"
/>
</svg>
</svg>

Before

Width:  |  Height:  |  Size: 529 B

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -1,3 +1,19 @@
<!--
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.
-->
<script lang="ts">
import { Button, Helper, Input, Label, Modal } from "flowbite-svelte";
import { ExclamationCircleOutline } from "flowbite-svelte-icons";

View File

@@ -1,3 +1,19 @@
<!--
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.
-->
<script lang="ts">
import { Dropzone } from "flowbite-svelte";
import ImgLogo from "./assets/imgLogo.svelte";

View File

@@ -1,3 +1,19 @@
<!--
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.
-->
<script>
import IntelLogo from "./assets/intelLogo.svelte";

View File

@@ -1 +1,15 @@
// 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.
// Reexport your entry components here

View File

@@ -1,3 +1,17 @@
// 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.
import { SSE } from "sse.js";
import { env } from "$env/dynamic/public";

View File

@@ -1,3 +1,17 @@
// 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.
import { writable } from 'svelte/store';
export let kb_id = writable("");

View File

@@ -1,3 +1,17 @@
// 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.
export function scrollToBottom(scrollToDiv: HTMLElement) {
if (scrollToDiv) {
setTimeout(
@@ -10,5 +24,3 @@ export function scrollToBottom(scrollToDiv: HTMLElement) {
);
}
}

View File

@@ -1,3 +1,19 @@
<!--
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.
-->
<script lang="ts">
import LoadingAnimation from "./assets/loadingAnimation.svelte";
import SummaryLogo from "./assets/summaryLogo.svelte";

View File

@@ -1,3 +1,19 @@
<!--
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.
-->
<script>
import "../app.pcss";
import Notifications from "svelte-notifications";
@@ -7,4 +23,3 @@
<Notifications>
<slot />
</Notifications>

View File

@@ -1,3 +1,19 @@
<!--
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.
-->
<script lang="ts">
import Header from "$lib/header.svelte";
import Doc from "$lib/doc.svelte";
@@ -12,9 +28,9 @@
onMount(() => {
scrollToDiv = document
.querySelector("#editor")!
.querySelector("#editor")!
console.log('scrollToDiv', scrollToDiv);
})
const callTextStream = async (
@@ -35,7 +51,7 @@
if (log.op === "add") {
if (
log.path.endsWith("/streamed_output/-") && typeof log.value === "string"
) {
) {
messages += log.value;
scrollToBottom(scrollToDiv)
}

View File

@@ -1,3 +1,17 @@
// 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.
import adapter from "@sveltejs/adapter-auto";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
@@ -13,8 +27,8 @@ const config = {
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter(),
env: {
publicPrefix: ''
}
publicPrefix: "",
},
},
};

View File

@@ -1,29 +1,43 @@
// 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 config = {
content: ['./src/**/*.{html,js,svelte,ts}', './node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}'],
content: ["./src/**/*.{html,js,svelte,ts}", "./node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}"],
plugins: [require('flowbite/plugin')],
plugins: [require("flowbite/plugin")],
darkMode: 'class',
darkMode: "class",
theme: {
extend: {
colors: {
// flowbite-svelte
primary: {
50: '#f2f8ff',
100: '#eef5ff',
200: '#deecff',
300: '#cce2ff',
400: '#add0ff',
500: '#5da2fe',
600: '#2f81ef',
700: '#2780eb',
800: '#226fcc',
900: '#1b5aa5'
}
}
}
}
50: "#f2f8ff",
100: "#eef5ff",
200: "#deecff",
300: "#cce2ff",
400: "#add0ff",
500: "#5da2fe",
600: "#2f81ef",
700: "#2780eb",
800: "#226fcc",
900: "#1b5aa5",
},
},
},
},
};
module.exports = config;
module.exports = config;

View File

@@ -1,15 +1,15 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
}

View File

@@ -1,3 +1,17 @@
// 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.
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';