Skip to content

Commit

Permalink
Fix a bunch of issues (#442)
Browse files Browse the repository at this point in the history
* fix(tokens): overflow

* fix(chat): fixed deletion error of the chat

#441

* fix(default-brain): autoset default brain when on upload page

* fix(promptengineering): changed prompt a bit

* feat(growthbook): removed

* docs(readme): updated
  • Loading branch information
StanGirard authored Jul 1, 2023
1 parent 1e47024 commit b76262c
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 52 deletions.
40 changes: 26 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

Quivr, your second brain, utilizes the power of GenerativeAI to store and retrieve unstructured information. Think of it as Obsidian, but turbocharged with AI capabilities.

[Roadmap here](https://getquivr.notion.site/Quivr-GenerativeAI-Second-Brain-3b22a6f50ffe4d259a6f120a17bc0543)
[Roadmap here](https://brains.quivr.app)

## Key Features 🎯

Expand All @@ -33,22 +33,13 @@ Quivr, your second brain, utilizes the power of GenerativeAI to store and retrie

## Demo Highlights 🎥

> **Please note: The DEMO WITH STREAMLIT IS USING AN OLD VERSION**
> The new version showcases a fresh UI, however, it is not yet deployed as it lacks some features of the old version. Expected to go live before 25/05/23
### **Demo with GPT3.5**:
https://github.com/StanGirard/quivr/assets/19614572/80721777-2313-468f-b75e-09379f694653

### **Demo with Claude 100k context**: https://github.com/StanGirard/quivr/assets/5101573/9dba918c-9032-4c8d-9eea-94336d2c8bd4

### **Demo of the new version (Work in progress)**:
https://github.com/StanGirard/quivr/assets/19614572/a6463b73-76c7-4bc0-978d-70562dca71f5

## Getting Started: New Version 🚀
## Getting Started: 🚀

Follow these instructions to get a copy of the project up and running on your local machine for development and testing purposes.

**Old version's readme** is located in the streamlit-demo folder [here](streamlit-demo/README.md)
You can find everything on the documentation [here](https://brains.quivr.app/)

### Prerequisites 📋

Expand Down Expand Up @@ -103,7 +94,7 @@ cp .frontend_env.example frontend/.env

[Creation Script 1](scripts/tables.sql)

> _If you come from an old version of Quivr, you can use the [migration script](scripts/20230606131110_add_uuid_user_id.sql) to migrate your data to the new version_
> _If you come from an old version of Quivr, run the scripts in [migration script](scripts/) to migrate your data to the new version in the order of date_
- **Step 5**: Launch the app

Expand Down Expand Up @@ -133,13 +124,34 @@ Thanks goes to these wonderful people:
Got a pull request? Open it, and we'll review it as soon as possible. Check out our project board [here](https://github.com/users/StanGirard/projects/5) to see what we're currently focused on, and feel free to bring your fresh ideas to the table!


- [Roadmap](https://github.com/users/StanGirard/projects/5)
- [Open Issues](https://github.com/StanGirard/quivr/issues)
- [Open Pull Requests](https://github.com/StanGirard/quivr/pulls)
- [Good First Issues](https://github.com/StanGirard/quivr/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
- [Frontend Issues](https://github.com/StanGirard/quivr/issues?q=is%3Aopen+is%3Aissue+label%3Afrontend)
- [Backend Issues](https://github.com/StanGirard/quivr/issues?q=is%3Aopen+is%3Aissue+label%3Abackend)

## Sponsors ❤️

This project could not be possible without the support of our sponsors. Thank you for your support!

<a href="https://www.theodo.fr/">
<img src="https://avatars.githubusercontent.com/u/332041?s=200&v=4" alt="Theodo" style="max-width:70px;">
</a>
<a href="https://www.padok.fr/">
<img src="https://avatars.githubusercontent.com/u/46325765?s=200&v=4" alt="Padok" style="max-width:70px;">
</a>
<a href="https://www.aleios.com/">
<img src="https://avatars.githubusercontent.com/u/97908131?s=200&v=4" alt="Aleios" style="max-width:70px;">
</a>




## License 📄

This project is licensed under the Apache 2.0 License - see the [LICENSE.md](LICENSE.md) file for details


## Stars History 📈

[![Star History Chart](https://api.star-history.com/svg?repos=StanGirard/quivr&type=Timeline)](https://star-history.com/#StanGirard/quivr&Timeline)
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _construct_prompt(
system_messages = [
{
"role": "system",
"content": "Your name is Quivr. You are a second brain. A person will ask you a question and you will provide a helpful answer. Write the answer in the same language as the question.If you don't know the answer, just say that you don't know. Don't try to make up an answer.our main goal is to answer questions about user uploaded documents. Unless basic questions or greetings, you should always refer to user uploaded documents by fetching them with the get_context function.",
"content": "Your name is Quivr. You are a second brain. A person will ask you a question and you will provide a helpful answer. Write the answer in the same language as the question.If you don't know the answer, just say that you don't know. Don't try to make up an answer.our main goal is to answer questions about user uploaded documents. Unless basic questions or greetings, you should always refer to user uploaded documents by fetching them with the get_context function. If the user ask a question that is not common knowledge for a 10 years old, then use get_context to find a document that can help you answer the question. If the user ask a question that is common knowledge for a 10 years old, then you can answer the question without using get_context.",
}
]

Expand Down
15 changes: 14 additions & 1 deletion backend/routes/chat_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,20 @@ def get_chat_details(commons, chat_id):


def delete_chat_from_db(commons, chat_id):
commons["supabase"].table("chats").delete().match({"chat_id": chat_id}).execute()
try:
commons["supabase"].table("chat_history").delete().match(
{"chat_id": chat_id}
).execute()
except Exception as e:
print(e)
pass
try:
commons["supabase"].table("chats").delete().match(
{"chat_id": chat_id}
).execute()
except Exception as e:
print(e)
pass


def fetch_user_stats(commons, user, date):
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/backend/api/_category_.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"label": "API",
"position": 1,
"position": 2,
"link": {
"type": "generated-index",
"description": "How does the API works ?"
}
}
}
1 change: 1 addition & 0 deletions docs/docs/backend/intro.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sidebar_position: 1
title: Architecture
---

Quivr is using FastAPI to provide a RESTful API for the backend. The API is currently in beta and is subject to change. The API is available at [https://api.quivr.app](https://api.quivr.app).
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/backend/llm/_category_.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"label": "LLM",
"position": 1,
"position": 2,
"link": {
"type": "generated-index",
"description": "How does the LLM (Large Language Model Work)?"
}
}
}
21 changes: 14 additions & 7 deletions docs/docs/get_started/intro.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sidebar_position: 1
title: Getting Started
---

# Intro
Expand Down Expand Up @@ -33,11 +34,15 @@ Quivr, your second brain, utilizes the power of GenerativeAI to store and retrie
Your browser does not support the video tag.
</video>

## Demo Highlights 🎥

https://github.com/StanGirard/quivr/assets/19614572/a6463b73-76c7-4bc0-978d-70562dca71f5

## Getting Started: 🚀

Follow these instructions to get a copy of the project up and running on your local machine for development and testing purposes.

**Old version's readme** is located in the streamlit-demo folder [here](https://github.com/StanGirard/quivr/tree/main/streamlit-demo/README.md)
You can find everything on the documentation [here](https://brains.quivr.app/)

### Prerequisites 📋

Expand Down Expand Up @@ -81,7 +86,7 @@ cp .frontend_env.example frontend/.env
> _Your `supabase_service_key` can be found in your Supabase dashboard under Project Settings -> API. Use the `anon` `public` key found in the `Project API keys` section._

> _Your `JWT_SECRET_KEY`can be found in your supabase settings under Project Settings -> JWT Settings -> JWT Secret_
> _Your `JWT_SECRET_KEY`can be found in your supabase settings under Project Settings -> API -> JWT Settings -> JWT Secret_
> _To activate vertexAI with PaLM from GCP follow the instructions [here](https://python.langchain.com/en/latest/modules/models/llms/integrations/google_vertex_ai_palm.html) and update `bacend/.env`- It is an advanced feature, please be expert in GCP before trying to use it_
Expand All @@ -90,11 +95,9 @@ cp .frontend_env.example frontend/.env

- **Step 4**: Run the following migration scripts on the Supabase database via the web interface (SQL Editor -> `New query`)

[DB Table Creation Script 1](https://github.com/StanGirard/quivr/tree/main/scripts/supabase_new_store_documents.sql)

[Creation Script 1](https://github.com/StanGirard/quivr/tree/main/scripts/tables.sql)
[Creation Script 1](https://github.com/stangirard/quivr/scripts/tables.sql)

> _If you come from an old version of Quivr, you can use the [migration script](https://github.com/StanGirard/quivr/tree/main/scripts/20230606131110_add_uuid_user_id.sql) to migrate your data to the new version_
> _If you come from an old version of Quivr, run the scripts in [migration script](https://github.com/stangirard/quivr/scripts/) to migrate your data to the new version in the order of date_
- **Step 5**: Launch the app

Expand All @@ -119,15 +122,19 @@ Thanks goes to these wonderful people:
<img src="https://contrib.rocks/image?repo=stangirard/quivr" />
</a>


## Contribute 🤝

Got a pull request? Open it, and we'll review it as soon as possible. Check out our project board [here](https://github.com/users/StanGirard/projects/5) to see what we're currently focused on, and feel free to bring your fresh ideas to the table!


- [Roadmap](https://github.com/users/StanGirard/projects/5)
- [Open Issues](https://github.com/StanGirard/quivr/issues)
- [Open Pull Requests](https://github.com/StanGirard/quivr/pulls)
- [Good First Issues](https://github.com/StanGirard/quivr/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
- [Frontend Issues](https://github.com/StanGirard/quivr/issues?q=is%3Aopen+is%3Aissue+label%3Afrontend)
- [Backend Issues](https://github.com/StanGirard/quivr/issues?q=is%3Aopen+is%3Aissue+label%3Abackend)


## License 📄

This project is licensed under the Apache 2.0 License - see the [LICENSE.md](https://github.com/StanGirard/quivr/LICENSE.md) file for details
10 changes: 5 additions & 5 deletions frontend/app/config/components/ModelConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ export const ModelConfig = ({
//At the moment is evaluating only models from OpenAI
switch (model) {
case "gpt-3.5-turbo-0613":
return 3000;
return 500;
case "gpt-3.5-turbo-16k":
return 14000;
return 2000;
case "gpt-4":
return 6000;
return 1000;
case "gpt-4-0613":
return 6000;
return 100;
default:
return 3000;
return 250;
}
};

Expand Down
30 changes: 14 additions & 16 deletions frontend/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Footer from "@/lib/components/Footer";
import { NavBar } from "@/lib/components/NavBar";
import { TrackingWrapper } from "@/lib/components/TrackingWrapper";
import { ToastProvider } from "@/lib/components/ui/Toast";
import { BrainProvider, FeatureFlagsProvider } from "@/lib/context";
import { BrainProvider } from "@/lib/context";
import { BrainConfigProvider } from "@/lib/context/BrainConfigProvider/brain-config-provider";
import { SupabaseProvider } from "@/lib/context/SupabaseProvider";
import "./globals.css";
Expand Down Expand Up @@ -39,21 +39,19 @@ const RootLayout = async ({
<body
className={`bg-white text-black min-h-screen flex flex-col dark:bg-black dark:text-white w-full ${inter.className}`}
>
<FeatureFlagsProvider>
<ToastProvider>
<SupabaseProvider session={session}>
<BrainConfigProvider>
<BrainProvider>
<TrackingWrapper />
<NavBar />
<div className="flex-1">{children}</div>
<Footer />
</BrainProvider>
</BrainConfigProvider>
</SupabaseProvider>
</ToastProvider>
<Analytics />
</FeatureFlagsProvider>
<ToastProvider>
<SupabaseProvider session={session}>
<BrainConfigProvider>
<BrainProvider>
<TrackingWrapper />
<NavBar />
<div className="flex-1">{children}</div>
<Footer />
</BrainProvider>
</BrainConfigProvider>
</SupabaseProvider>
</ToastProvider>
<Analytics />
</body>
</html>
);
Expand Down
25 changes: 25 additions & 0 deletions frontend/app/upload/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
/* eslint-disable */
"use client";
import Link from "next/link";
import { useEffect } from "react";

import Button from "@/lib/components/ui/Button";
import { Divider } from "@/lib/components/ui/Divider";
import PageHeading from "@/lib/components/ui/PageHeading";
import { getBrainFromLocalStorage } from "@/lib/context/BrainProvider/helpers/brainLocalStorage";
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";


import { Crawler } from "./components/Crawler";
import { FileUploader } from "./components/FileUploader";

const UploadPage = (): JSX.Element => {
const { setActiveBrain, setDefaultBrain } = useBrainContext();

const fetchAndSetActiveBrain = async () => {
const storedBrain = getBrainFromLocalStorage();
if (storedBrain) {
setActiveBrain({ ...storedBrain });
return storedBrain;
} else {
const defaultBrain = await setDefaultBrain();
return defaultBrain;
}
};

useEffect(() => {
const fetchBrains = async () => {
await fetchAndSetActiveBrain();
};
fetchBrains();
}, []);

return (
<main className="pt-10">
<PageHeading
Expand Down
4 changes: 1 addition & 3 deletions frontend/lib/components/NavBar/components/NavItems/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"use client";
import { useFeature } from "@growthbook/growthbook-react";
import Link from "next/link";
import { Dispatch, HTMLAttributes, SetStateAction } from "react";
import { MdPerson, MdSettings } from "react-icons/md";
Expand All @@ -24,7 +23,6 @@ export const NavItems = ({
}: NavItemsProps): JSX.Element => {
const { session } = useSupabase();
const isUserLoggedIn = session?.user !== undefined;
const shouldUseMultipleBrains = useFeature("multiple-brains").on;

return (
<ul
Expand Down Expand Up @@ -59,7 +57,7 @@ export const NavItems = ({
<div className="flex sm:flex-1 sm:justify-end flex-col items-center justify-center sm:flex-row gap-5 sm:gap-2">
{isUserLoggedIn && (
<>
{shouldUseMultipleBrains && <BrainsDropDown />}
<BrainsDropDown />
<Link aria-label="account" className="" href={"/user"}>
<MdPerson className="text-2xl" />
</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const BrainConfigContext = createContext<ConfigContext | undefined>(
const defaultBrainConfig: BrainConfig = {
model: "gpt-3.5-turbo-0613",
temperature: 0,
maxTokens: 1000,
maxTokens: 256,
keepLocal: true,
anthropicKey: undefined,
backendUrl: undefined,
Expand Down

0 comments on commit b76262c

Please sign in to comment.