Skip to content

Commit

Permalink
Add agent ui, including ui code, readme and launch script.
Browse files Browse the repository at this point in the history
Add AgentQnA ui code, supplemented UI related readme and dockerFile, as well as the corresponding startup scripts.

Signed-off-by: WenjiaoYue <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>
  • Loading branch information
WenjiaoYue authored and WenjiaoYue committed Jan 15, 2025
1 parent fec4c2f commit 9a8608c
Show file tree
Hide file tree
Showing 86 changed files with 714 additions and 366 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-online-doc-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:

- name: Checkout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
shopt -s globstar
no_add="FALSE"
cd ${{github.workspace}}
Dockerfiles=$(realpath $(find ./ -name '*Dockerfile*' ! -path './tests/*'))
Dockerfiles=$(realpath $(find ./ -name '*Dockerfile*' ! -path '*/tests/*'))
if [ -n "$Dockerfiles" ]; then
for dockerfile in $Dockerfiles; do
service=$(echo "$dockerfile" | awk -F '/GenAIExamples/' '{print $2}' | awk -F '/' '{print $2}')
Expand Down
2 changes: 1 addition & 1 deletion AgentQnA/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Overview

This example showcases a hierarchical multi-agent system for question-answering applications. The architecture diagram is shown below. The supervisor agent interfaces with the user and dispatch tasks to the worker agent and other tools to gather information and come up with answers. The worker agent uses the retrieval tool to generate answers to the queries posted by the supervisor agent. Other tools used by the supervisor agent may include APIs to interface knowledge graphs, SQL databases, external knowledge bases, etc.
![Architecture Overview](assets/agent_qna_arch.png)
![Architecture Overview](assets/img/agent_qna_arch.png)

The AgentQnA example is implemented using the component-level microservices defined in [GenAIComps](https://github.com/opea-project/GenAIComps). The flow chart below shows the information flow between different microservices for this example.

Expand Down
File renamed without changes
Binary file added AgentQnA/assets/img/agent_ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AgentQnA/assets/img/agent_ui_result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions AgentQnA/docker_image_build/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ services:
https_proxy: ${https_proxy}
no_proxy: ${no_proxy}
image: ${REGISTRY:-opea}/agent:${TAG:-latest}
agent-ui:
build:
context: ../ui
dockerfile: ./docker/Dockerfile
extends: agent
image: ${REGISTRY:-opea}/agent-ui:${TAG:-latest}
6 changes: 1 addition & 5 deletions AgentQnA/ui/svelte/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],
plugins: ["svelte3", "@typescript-eslint", "neverthrow"],
ignorePatterns: ["*.cjs"],
overrides: [{ files: ["*.svelte"], processor: "svelte3/svelte3" }],
Expand Down
60 changes: 60 additions & 0 deletions AgentQnA/ui/svelte/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# AgentQnA

## 📸 Project Screenshots

![project-screenshot](../../assets/img/agent_ui.png)
![project-screenshot](../../assets/img/agent_ui_result.png)

## 🧐 Features

Here're some of the project's features:

- Create Agent:Provide more precise answers based on user queries, showcase the high-quality output process of complex queries across different dimensions, and consolidate information to present comprehensive answers.

## 🛠️ Get it Running

1. Clone the repo.

2. cd command to the current folder.

```
cd AgentQnA/ui
```

3. Modify the required .env variables.

```
AGENT_URL = ''
```

4. **For Local Development:**

- Install the dependencies:

```
npm install
```

- Start the development server:

```
npm run dev
```

- The application will be available at `http://localhost:3000`.

5. **For Docker Setup:**

- Build the Docker image:

```
docker build -t opea:agent-ui .
```

- Run the Docker container:

```
docker run -d -p 3000:3000 --name agent-ui opea:agent-ui
```

- The application will be available at `http://localhost:3000`.
8 changes: 4 additions & 4 deletions AgentQnA/ui/svelte/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const tailwindcss = require('tailwindcss');
const autoprefixer = require('autoprefixer');
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
]
autoprefixer,
],
};

module.exports = config;
50 changes: 18 additions & 32 deletions AgentQnA/ui/svelte/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (C) 2025 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

// See: https://kit.svelte.dev/docs/types#app
// import { Result} from "neverthrow";

Expand All @@ -21,44 +24,27 @@ interface User {
type AuthResponse = Result<User>;

interface AuthAdapter {
login(props: {
email: string;
password: string;
}): Promise<AuthResponse>;
signup(props: {
email: string;
password: string;
password_confirm: string;
}): Promise<AuthResponse>;
validate_session(props: {
token: string;
}): Promise<AuthResponse>;
logout(props: {
token: string;
email: string;
}): Promise<Result<void>>;
forgotPassword(props: {
email: string;
password: string;
}): Promise<Result<void>>;
login(props: { email: string; password: string }): Promise<AuthResponse>;
signup(props: { email: string; password: string; password_confirm: string }): Promise<AuthResponse>;
validate_session(props: { token: string }): Promise<AuthResponse>;
logout(props: { token: string; email: string }): Promise<Result<void>>;
forgotPassword(props: { email: string; password: string }): Promise<Result<void>>;
}

interface ChatAdapter {
modelList(props: {
}): Promise<Result<void>>;
txt2img(props: {
}): Promise<Result<void>>;
modelList(props: {}): Promise<Result<void>>;
txt2img(props: {}): Promise<Result<void>>;
}

interface ChatMessage {
role: string,
content: string
role: string;
content: string;
}

interface ChatMessageType {
model: string,
knowledge: string,
temperature: string,
max_new_tokens: string,
topk: string,
}
model: string;
knowledge: string;
temperature: string;
max_new_tokens: string;
topk: string;
}
9 changes: 6 additions & 3 deletions AgentQnA/ui/svelte/src/app.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<!DOCTYPE html>
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
Expand Down
5 changes: 5 additions & 0 deletions AgentQnA/ui/svelte/src/lib/assets/Agent/createSub.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
t="1731984271860"
class="w-8 h-8"
Expand Down
7 changes: 6 additions & 1 deletion AgentQnA/ui/svelte/src/lib/assets/Agent/download.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg class="w-3.5 h-3.5 me-2.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
<path d="M14.707 7.793a1 1 0 0 0-1.414 0L11 10.086V1.5a1 1 0 0 0-2 0v8.586L6.707 7.793a1 1 0 1 0-1.414 1.414l4 4a1 1 0 0 0 1.416 0l4-4a1 1 0 0 0-.002-1.414Z"/>
<path d="M18 12h-2.55l-2.975 2.975a3.5 3.5 0 0 1-4.95 0L4.55 12H2a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2Zm-3 5a1 1 0 1 1 0-2 1 1 0 0 1 0 2Z"/>
</svg>
</svg>
7 changes: 6 additions & 1 deletion AgentQnA/ui/svelte/src/lib/assets/Agent/eye.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
class="me-2 h-3 w-3"
aria-hidden="true"
Expand All @@ -8,4 +13,4 @@
<path
d="M10 0C4.612 0 0 5.336 0 7c0 1.742 3.546 7 10 7 6.454 0 10-5.258 10-7 0-1.664-4.612-7-10-7Zm0 10a3 3 0 1 1 0-6 3 3 0 0 1 0 6Z"
/>
</svg>
</svg>
5 changes: 5 additions & 0 deletions AgentQnA/ui/svelte/src/lib/assets/Agent/newAI.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<!-- <svg class="h-11 w-11 flex-none overflow-visible" fill="none"
><defs
><filter
Expand Down
7 changes: 6 additions & 1 deletion AgentQnA/ui/svelte/src/lib/assets/Agent/resource.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg class="h-5 w-5 flex-shrink-0 text-[#1d4dd5]" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" data-slot="icon">
<path fill-rule="evenodd" d="M15.621 4.379a3 3 0 0 0-4.242 0l-7 7a3 3 0 0 0 4.241 4.243h.001l.497-.5a.75.75 0 0 1 1.064 1.057l-.498.501-.002.002a4.5 4.5 0 0 1-6.364-6.364l7-7a4.5 4.5 0 0 1 6.368 6.36l-3.455 3.553A2.625 2.625 0 1 1 9.52 9.52l3.45-3.451a.75.75 0 1 1 1.061 1.06l-3.45 3.451a1.125 1.125 0 0 0 1.587 1.595l3.454-3.553a3 3 0 0 0 0-4.242Z" clip-rule="evenodd"></path>
</svg>
</svg>
7 changes: 6 additions & 1 deletion AgentQnA/ui/svelte/src/lib/assets/Agent/search.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
class="pointer-events-none absolute left-0 ml-4 hidden h-4 w-4 fill-current text-gray-500 group-hover:text-gray-400 sm:block"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20"
><path
d="M12.9 14.32a8 8 0 1 1 1.41-1.41l5.35 5.33-1.42 1.42-5.33-5.34zM8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12z"
/></svg
>
>
7 changes: 6 additions & 1 deletion AgentQnA/ui/svelte/src/lib/assets/Agent/searchDelete.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
fill="none"
class="relative h-5 w-5"
Expand All @@ -9,4 +14,4 @@
><path
d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"
/></svg
>
>
5 changes: 5 additions & 0 deletions AgentQnA/ui/svelte/src/lib/assets/Agent/searchResult.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
t="1731987484014"
class="w-5 h-5"
Expand Down
5 changes: 5 additions & 0 deletions AgentQnA/ui/svelte/src/lib/assets/Agent/star.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
t="1730766012593"
viewBox="0 0 1024 1024"
Expand Down
5 changes: 5 additions & 0 deletions AgentQnA/ui/svelte/src/lib/assets/Agent/summary.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
t="1731984744752"
class="w-12 h-12"
Expand Down
5 changes: 5 additions & 0 deletions AgentQnA/ui/svelte/src/lib/assets/Agent/taskIcon.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
t="1731987065328"
class="w-5 h-5"
Expand Down
5 changes: 5 additions & 0 deletions AgentQnA/ui/svelte/src/lib/assets/Agent/taskResult.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
t="1731987759041"
class="w-7 h-7"
Expand Down
7 changes: 6 additions & 1 deletion AgentQnA/ui/svelte/src/lib/assets/Agent/time.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg class="w-2.5 h-2.5 text-blue-800 dark:text-blue-300" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
<path d="M20 4a2 2 0 0 0-2-2h-2V1a1 1 0 0 0-2 0v1h-3V1a1 1 0 0 0-2 0v1H6V1a1 1 0 0 0-2 0v1H2a2 2 0 0 0-2 2v2h20V4ZM0 18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8H0v10Zm5-8h10a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z"/>
</svg>
</svg>
5 changes: 5 additions & 0 deletions AgentQnA/ui/svelte/src/lib/assets/Agent/toolIcon.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
t="1731987374334"
class="w-4 h-4"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
t="1699532005309"
class="icon"
Expand All @@ -21,4 +26,3 @@
class=""
/></svg
>

Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
t="1699531880178"
class="icon"
Expand Down
5 changes: 5 additions & 0 deletions AgentQnA/ui/svelte/src/lib/assets/icons/Folder.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
Copyright (C) 2025 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

<svg
t="1697617760586"
class="h-10 w-10"
Expand Down
Loading

0 comments on commit 9a8608c

Please sign in to comment.