khronoz commited on
Commit
1d4f56e
·
unverified ·
1 Parent(s): f730525

Bugfixes & Improvements (#11)

Browse files

* Fix: Button loading state not reset on 'back'

* Feat: search post processing to filter by average score

* Feat: Updated api status error handling

* Feat: Updated error handling & timeout duration

* Refactored imports & moved global vars to constants.py

* Feat: Updated dockerfile to install llama-cpp-python with openblas support by default

* Add .env file and update gitignore, pipeline name, robots.txt, middleware, layout, page, sitemap, and navlink components

* Fixed Pipeline Name

* Updated Check File Size workflow

* Updated Homepage to add GSC verification metadata tag

* Updated check-file-size.yml action to run on push

* Added Deployment Template & Contributing.md

.github/workflows/check-file-size.yml CHANGED
@@ -1,8 +1,12 @@
1
  name: Check file size
2
 
3
- on: # or directly `on: [push]` to run the action on every push on any branch
 
4
  pull_request:
5
  branches: [main]
 
 
 
6
  # to run this workflow manually from the Actions tab
7
  workflow_dispatch:
8
  # to run this workflow from another workflow
 
1
  name: Check file size
2
 
3
+ on:
4
+ # On pull requests to the main branch
5
  pull_request:
6
  branches: [main]
7
+ # On pushes to the main branch
8
+ push:
9
+ branches: [main]
10
  # to run this workflow manually from the Actions tab
11
  workflow_dispatch:
12
  # to run this workflow from another workflow
CONTRIBUTING.md ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing
2
+
3
+ Thank you for considering contributing to this project! Your time and effort in helping to make this project better is very much appreciated.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Getting Started](#getting-started)
8
+ - [Contributing Guidelines](#contributing-guidelines)
9
+ - [Code of Conduct](#code-of-conduct)
10
+ - [License](#license)
11
+
12
+ ## Getting Started
13
+
14
+ To get started with contributing, please follow these steps:
15
+
16
+ 1. Fork the repository and clone it to your local machine.
17
+ 2. Install any necessary dependencies.
18
+ 3. Create a new branch for your changes.
19
+ 4. Make your desired changes and commit them.
20
+ 5. Push your changes to your forked repository.
21
+ 6. Open a pull request to the main repository.
22
+
23
+ ## Contributing Guidelines
24
+
25
+ Please follow these guidelines when contributing to this project:
26
+
27
+ - Before starting work on a new feature or bug fix, check the existing issues and pull requests to avoid duplication of effort.
28
+ - Make sure your code follows the project's coding style and conventions.
29
+ - Write clear and concise commit messages.
30
+ - Include tests for any new functionality or bug fixes.
31
+ - Document any changes or additions to the project's documentation.
32
+
33
+ ## Code of Conduct
34
+
35
+ We expect all contributors to adhere to our [Code of Conduct](CODE_OF_CONDUCT.md). Please read it carefully before making any contributions.
36
+
37
+ ## License
38
+
39
+ This project is licensed under the [MIT License](LICENSE). By contributing to this project, you agree to abide by the terms of this license.
40
+
41
+ ---
42
+
43
+ We welcome contributions from everyone, regardless of their experience level or background. If you have any questions or need assistance, please don't hesitate to reach out. Happy contributing!
DEPLOYMENT.md ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Smart Retrieval
2
+
3
+ ## Deployment Instructions
4
+
5
+ ### Prerequisites
6
+
7
+ - [List any prerequisites or dependencies required for deployment]
8
+
9
+ ### Deployment Steps
10
+
11
+ 1. [Step 1: Describe the first step to deploy the project]
12
+ 2. [Step 2: Describe the second step to deploy the project]
13
+ 3. [Step 3: Describe the third step to deploy the project]
14
+ - [Sub-step or additional information if necessary]
15
+ 4. [Step 4: Describe the fourth step to deploy the project]
16
+ - [Sub-step or additional information if necessary]
17
+
18
+ ### Configuration
19
+
20
+ - [List any configuration settings or environment variables required for deployment]
21
+
22
+ ### Usage
23
+
24
+ - [Provide instructions on how to use or access the deployed project]
25
+
26
+ ### Troubleshooting
27
+
28
+ - [List common issues or errors that may occur during deployment and how to resolve them]
29
+
30
+ ### Contributing
31
+
32
+ - [Provide information on how others can contribute to the project]
33
+
34
+ ### License
35
+
36
+ - [Specify the project's license]
37
+
38
+ ### Contact
39
+
40
+ - [Provide contact information for support or inquiries]
README.md CHANGED
@@ -41,7 +41,7 @@ pinned: false
41
  - [Getting Started](#getting_started)
42
  - [Deployment](#deployment)
43
  - [Built Using](#built_using)
44
- - [Contributing](../CONTRIBUTING.md)
45
  - [Authors](#authors)
46
  - [Acknowledgments](#acknowledgement)
47
 
@@ -64,7 +64,9 @@ These instructions will get you a copy of the project up and running on your loc
64
 
65
  ## 🚀 Deployment <a name = "deployment"></a>
66
 
67
- How to deploy this on a live system.
 
 
68
 
69
  ## ⛏️ Built Using <a name = "built_using"></a>
70
 
@@ -75,9 +77,15 @@ How to deploy this on a live system.
75
  - [FastAPI](https://fastapi.tiangolo.com/) - Backend API Web Framework
76
  - [LlamaIndex](https://www.llamaindex.ai/) - Data Framework for LLM
77
 
 
 
 
 
 
 
78
  ## ✍️ Authors <a name = "authors"></a>
79
 
80
- - [@xkhronoz](https://github.com/xkhronoz) - Initial work
81
 
82
  See also the list of [contributors](https://github.com/digitalbuiltenvironment/Smart-Retrieval/contributors) who participated in this project.
83
 
 
41
  - [Getting Started](#getting_started)
42
  - [Deployment](#deployment)
43
  - [Built Using](#built_using)
44
+ - [Contributing](#contributing)
45
  - [Authors](#authors)
46
  - [Acknowledgments](#acknowledgement)
47
 
 
64
 
65
  ## 🚀 Deployment <a name = "deployment"></a>
66
 
67
+ Deploy this on a live system.
68
+
69
+ For more information, see the [DEPLOYMENT.md](./DEPLOYMENT.md).
70
 
71
  ## ⛏️ Built Using <a name = "built_using"></a>
72
 
 
77
  - [FastAPI](https://fastapi.tiangolo.com/) - Backend API Web Framework
78
  - [LlamaIndex](https://www.llamaindex.ai/) - Data Framework for LLM
79
 
80
+ ## 📑 Contributing <a name = "contributing"></a>
81
+
82
+ Contributions, issues and feature requests are welcome!
83
+
84
+ Read the [CONTRIBUTING.md](./CONTRIBUTING.md) for details and the process for submitting pull requests.
85
+
86
  ## ✍️ Authors <a name = "authors"></a>
87
 
88
+ - [@xkhronoz](https://github.com/xkhronoz)
89
 
90
  See also the list of [contributors](https://github.com/digitalbuiltenvironment/Smart-Retrieval/contributors) who participated in this project.
91
 
frontend/app/components/header.tsx CHANGED
@@ -6,7 +6,7 @@ import { useTheme } from "next-themes";
6
  import { useEffect, useState } from "react";
7
  import { useMedia } from 'react-use';
8
  import useSWR from 'swr';
9
- import logo from '../../public/smart-retrieval-logo.webp';
10
  import { HeaderNavLink } from './ui/navlink';
11
  import { MobileMenu } from './ui/mobilemenu';
12
 
@@ -44,7 +44,7 @@ export default function Header() {
44
  const { theme, setTheme } = useTheme();
45
  // Use SWR for API status fetching
46
  const healthcheck_api = process.env.NEXT_PUBLIC_HEALTHCHECK_API;
47
- const { data: apiStatus, error: apiError } = useSWR(healthcheck_api, async (url) => {
48
  try {
49
  // Fetch the data
50
  const response = await fetch(url, {
@@ -71,8 +71,6 @@ export default function Header() {
71
  else {
72
  console.error('[Header] Error fetching Backend API Status:', apiError.message);
73
  }
74
- } else {
75
- console.log('[Header] API Status:', apiStatus);
76
  }
77
 
78
  useEffect(() => {
 
6
  import { useEffect, useState } from "react";
7
  import { useMedia } from 'react-use';
8
  import useSWR from 'swr';
9
+ import logo from '@/public/smart-retrieval-logo.webp';
10
  import { HeaderNavLink } from './ui/navlink';
11
  import { MobileMenu } from './ui/mobilemenu';
12
 
 
44
  const { theme, setTheme } = useTheme();
45
  // Use SWR for API status fetching
46
  const healthcheck_api = process.env.NEXT_PUBLIC_HEALTHCHECK_API;
47
+ const { data, error: apiError } = useSWR(healthcheck_api, async (url) => {
48
  try {
49
  // Fetch the data
50
  const response = await fetch(url, {
 
71
  else {
72
  console.error('[Header] Error fetching Backend API Status:', apiError.message);
73
  }
 
 
74
  }
75
 
76
  useEffect(() => {
frontend/app/components/ui/home/client-component.tsx ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use client";
2
+
3
+ import Image from 'next/image';
4
+ import Link from 'next/link';
5
+ import { useState } from 'react';
6
+ import { IconSpinner } from '@/app/components/ui/icons';
7
+ import logo from '@/public/smart-retrieval-logo.webp';
8
+
9
+ export default function Home() {
10
+ const [isLoading, setIsLoading] = useState(false);
11
+
12
+ return (
13
+ <div className="rounded-xl shadow-xl p-4 max-w-5xl w-full">
14
+ <div className="max-w-2xl mx-auto p-4 text-center">
15
+ <div className="flex flex-col items-center mb-4 bg-gradient-to-r from-blue-500 to-indigo-500 text-white p-8 rounded-lg shadow-lg">
16
+ <div className="flex flex-col md:flex-row items-center md:items-start">
17
+ <Image
18
+ src={logo}
19
+ alt="Smart Retrieval Logo"
20
+ width={150}
21
+ height={150}
22
+ priority
23
+ className="rounded-lg mb-4 md:mb-0 md:mr-4"
24
+ />
25
+ <div className='flex flex-col mt-4'>
26
+ <h1 className="text-4xl font-bold mb-2 md:text-5xl">Smart Retrieval</h1>
27
+ <p className="text-lg md:text-xl text-gray-200">
28
+ Your intelligent solution for quick and accurate information retrieval.
29
+ </p>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ <div className="flex flex-col mt-8 text-center items-center max-w-full">
34
+ <p id='get-started-paragraph' className="text-xl text-gray-700 dark:text-gray-200 mb-4">
35
+ Experience the power of Smart Retrieval today!
36
+ </p>
37
+ <Link href="/chat" onClick={() => { setIsLoading(true); }}>
38
+ <div className="flex text-center items-center text-xl bg-blue-500 text-white px-6 py-3 rounded-md font-bold transition duration-300 ease-in-out transform hover:scale-125">
39
+ {isLoading ? (
40
+ <IconSpinner className="mr-2 animate-spin" />
41
+ ) : null}
42
+ Get Started
43
+ </div>
44
+ </Link>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ );
49
+ }
frontend/app/page.tsx CHANGED
@@ -1,49 +1,12 @@
1
- "use client";
 
2
 
3
- import Image from 'next/image';
4
- import Link from 'next/link';
5
- import { useState } from 'react';
6
- import { IconSpinner } from '@/app/components/ui/icons';
7
- import logo from '../public/smart-retrieval-logo.webp';
 
 
8
 
9
- export default function Home() {
10
- const [isLoading, setIsLoading] = useState(false);
11
-
12
- return (
13
- <div className="rounded-xl shadow-xl p-4 max-w-5xl w-full">
14
- <div className="max-w-2xl mx-auto p-4 text-center">
15
- <div className="flex flex-col items-center mb-4 bg-gradient-to-r from-blue-500 to-indigo-500 text-white p-8 rounded-lg shadow-lg">
16
- <div className="flex flex-col md:flex-row items-center md:items-start">
17
- <Image
18
- src={logo}
19
- alt="Smart Retrieval Logo"
20
- width={150}
21
- height={150}
22
- priority
23
- className="rounded-lg mb-4 md:mb-0 md:mr-4"
24
- />
25
- <div className='flex flex-col mt-4'>
26
- <h1 className="text-4xl font-bold mb-2 md:text-5xl">Smart Retrieval</h1>
27
- <p className="text-lg md:text-xl text-gray-200">
28
- Your intelligent solution for quick and accurate information retrieval.
29
- </p>
30
- </div>
31
- </div>
32
- </div>
33
- <div className="flex flex-col mt-8 text-center items-center max-w-full">
34
- <p id='get-started-paragraph' className="text-xl text-gray-700 dark:text-gray-200 mb-4">
35
- Experience the power of Smart Retrieval today!
36
- </p>
37
- <Link href="/chat" onClick={() => { setIsLoading(true); }}>
38
- <div className="flex text-center items-center text-xl bg-blue-500 text-white px-6 py-3 rounded-md font-bold transition duration-300 ease-in-out transform hover:scale-125">
39
- {isLoading ? (
40
- <IconSpinner className="mr-2 animate-spin" />
41
- ) : null}
42
- Get Started
43
- </div>
44
- </Link>
45
- </div>
46
- </div>
47
- </div>
48
- );
49
- }
 
1
+ import Home from '@/app/components/ui/home/client-component';
2
+ import { Metadata } from 'next';
3
 
4
+ export const metadata: Metadata = {
5
+ // Google Search Console HTML Tag Verification
6
+ verification: {
7
+ google: process.env.GSC_TAG_VERIFICATION,
8
+ // Add more verification providers here. Refer: https://nextjs.org/docs/app/api-reference/functions/generate-metadata#verification
9
+ },
10
+ };
11
 
12
+ export default Home;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
frontend/example.env CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  # AUTH URL (set to canonical URL of your app in production e.g. https://www.example.com)
2
  NEXTAUTH_URL=http://localhost:3000
3
 
@@ -23,4 +27,14 @@ SGID_CLIENT_SECRET=sgid-client-secret
23
 
24
  # Chat API Endpoint (where the backend is running)
25
  # (set to canonical URL of your app in production e.g. https://www.example.com)
26
- CHAT_API=http://localhost:8000/api/chat
 
 
 
 
 
 
 
 
 
 
 
1
+ # Google Search Console HTML Tag Verification
2
+ # Select URL prefix property type and copy the string of characters from the HTML tag section
3
+ GSC_TAG_VERIFICATION=string-of-characters-from-Google-Search-Console
4
+
5
  # AUTH URL (set to canonical URL of your app in production e.g. https://www.example.com)
6
  NEXTAUTH_URL=http://localhost:3000
7
 
 
27
 
28
  # Chat API Endpoint (where the backend is running)
29
  # (set to canonical URL of your app in production e.g. https://www.example.com)
30
+ NEXT_PUBLIC_CHAT_API=http://127.0.0.1:8000/api/chat
31
+ # Query API Endpoint (where the backend is running)
32
+ # (set to canonical URL of your app in production e.g. https://www.example.com)
33
+ NEXT_PUBLIC_QUERY_API=http://127.0.0.1:8000/api/query
34
+ # Search API Endpoint (where the backend is running)
35
+ # (set to canonical URL of your app in production e.g. https://www.example.com)
36
+ NEXT_PUBLIC_SEARCH_API=http://127.0.0.1:8000/api/search
37
+ # Healthcheck API Endpoint (where the backend is running)
38
+ # (set to canonical URL of your app in production e.g. https://www.example.com)
39
+ NEXT_PUBLIC_HEALTHCHECK_API=http://127.0.0.1:8000/api/healthcheck
40
+