Skip to content

Commit

Permalink
Merge branch 'main' into error-state-#484
Browse files Browse the repository at this point in the history
  • Loading branch information
dartpain authored Oct 9, 2023
2 parents 16df8d8 + 64a8857 commit 3e20552
Show file tree
Hide file tree
Showing 16 changed files with 238 additions and 80 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Say goodbye to time-consuming manual searches, and let <strong><a href="https://
### Production Support / Help for companies:

We're eager to provide personalized assistance when deploying your DocsGPT to a live environment.
- [Get Support 👋](https://airtable.com/appdeaL0F1qV8Bl2C/shrrJF1Ll7btCJRbP)
- [Get Support 👋](https://cal.com/arc53/docsgpt-demo-b2b)
- [Send Email ✉️](mailto:[email protected]?subject=DocsGPT%20support%2Fsolutions)

### [🎉 Join the Hacktoberfest with DocsGPT and Earn a Free T-shirt! 🎉](https://github.com/arc53/DocsGPT/blob/main/HACKTOBERFEST.md)
Expand Down Expand Up @@ -54,17 +54,20 @@ If you don't have enough resources to run it, you can use bitsnbytes to quantize


## Useful links
[Live preview](https://docsgpt.arc53.com/)

- 🔍🔥 [Live preview](https://docsgpt.arc53.com/)

[Join our Discord](https://discord.gg/n5BX8dh8rU)
- 💬🎉[Join our Discord](https://discord.gg/n5BX8dh8rU)

[Guides](https://docs.docsgpt.co.uk/)
- 📚😎 [Guides](https://docs.docsgpt.co.uk/)

- 👩‍💻👨‍💻 [Interested in contributing?](https://github.com/arc53/DocsGPT/blob/main/CONTRIBUTING.md)

- 🗂️🚀 [How to use any other documentation](https://docs.docsgpt.co.uk/Guides/How-to-train-on-other-documentation)

[Interested in contributing?](https://github.com/arc53/DocsGPT/blob/main/CONTRIBUTING.md)
- 🏠🔐 [How to host it locally (so all data will stay on-premises)](https://docs.docsgpt.co.uk/Guides/How-to-use-different-LLM)

[How to use any other documentation](https://docs.docsgpt.co.uk/Guides/How-to-train-on-other-documentation)

[How to host it locally (so all data will stay on-premises)](https://docs.docsgpt.co.uk/Guides/How-to-use-different-LLM)


## Project structure
Expand Down
9 changes: 9 additions & 0 deletions application/api/user/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ def get_single_conversation():
conversation = conversations_collection.find_one({"_id": ObjectId(conversation_id)})
return jsonify(conversation['queries'])

@user.route("/api/update_conversation_name", methods=["POST"])
def update_conversation_name():
# update data for a conversation
data = request.get_json()
id = data["id"]
name = data["name"]
conversations_collection.update_one({"_id": ObjectId(id)},{"$set":{"name":name}})
return {"status": "ok"}


@user.route("/api/feedback", methods=["POST"])
def api_feedback():
Expand Down
3 changes: 1 addition & 2 deletions application/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@


def metadata_from_filename(title):
store = title.split('/')
store = store[1] + '/' + store[2]
store = '/'.join(title.split('/')[1:3])
return {'title': title, 'store': store}


Expand Down
6 changes: 3 additions & 3 deletions docs/pages/Developing/API-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fetch("http://localhost:5001/api/task_status?task_id=b2d2a0f4-387c-44fd-a443-e4f

Responses:
There are two types of responses:
1. While task is still running, where "current" will show progress from 0 to 100
1. While task is still running, where "current" will show progress from 0 to 100:
```json
{
"result": {
Expand All @@ -114,7 +114,7 @@ There are two types of responses:
}
```

2. When task is completed
2. When task is completed:
```json
{
"result": {
Expand All @@ -133,7 +133,7 @@ There are two types of responses:
```

### /api/delete_old
Deletes old vectorstores:
Deletes old Vector stores:
```js
// Task status (GET http://127.0.0.1:5000/api/docs_check)
fetch("http://localhost:5001/api/task_status?task_id=b2d2a0f4-387c-44fd-a443-e4fe2e7454d1", {
Expand Down
6 changes: 5 additions & 1 deletion docs/pages/Guides/How-to-use-different-LLM.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ By default, we use OpenAI's models but if you want to change it or even run it l
You don't need to provide keys if you are happy with users providing theirs, so make sure you set `LLM_NAME` and `EMBEDDINGS_NAME`.

Options:
LLM_NAME (openai, manifest, cohere, Arc53/docsgpt-14b, Arc53/docsgpt-7b-falcon)
LLM_NAME (openai, manifest, cohere, Arc53/docsgpt-14b, Arc53/docsgpt-7b-falcon, llama.cpp)
EMBEDDINGS_NAME (openai_text-embedding-ada-002, huggingface_sentence-transformers/all-mpnet-base-v2, huggingface_hkunlp/instructor-large, cohere_medium)

If using Llama, set the `EMBEDDINGS_NAME` to `huggingface_sentence-transformers/all-mpnet-base-v2` and be sure to download [this model](https://d3dg1063dc54p9.cloudfront.net/models/docsgpt-7b-f16.gguf) into the `models/` folder: `https://d3dg1063dc54p9.cloudfront.net/models/docsgpt-7b-f16.gguf`.

Alternatively, if you wish to run Llama locally, you can run `setup.sh` and choose option 1 when prompted. You do not need to manually add the DocsGPT model mentioned above to your `models/` folder if you use `setup.sh`, as the script will manage that step for you.

That's it!

### Hosting everything locally and privately (for using our optimised open-source models)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
If your AI uses external knowledge and is not explicit enough, it is ok, because we try to make docsgpt friendly.
If your AI uses external knowledge and is not explicit enough, it is ok, because we try to make DocsGPT friendly.

But if you want to adjust it, here is a simple way.
But if you want to adjust it, here is a simple way:-

Got to `application/prompts/chat_combine_prompt.txt`
- Got to `application/prompts/chat_combine_prompt.txt`

And change it to
- And change it to


```
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
export default function About() {
return (
<div className="mx-5 grid min-h-screen md:mx-36">
<article className="place-items-left mx-auto my-auto flex w-full max-w-6xl flex-col gap-6 rounded-3xl bg-gray-100 p-6 mt-20 text-jet lg:p-10 xl:p-16">
<article className="place-items-left mx-auto my-auto mt-20 flex w-full max-w-6xl flex-col gap-6 rounded-3xl bg-gray-100 p-6 text-jet lg:p-10 xl:p-16">
<div className="flex items-center">
<p className="mr-2 text-3xl">About DocsGPT</p>
<p className="text-[21px]">🦖</p>
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export default function App() {
<div
className={`transition-all duration-200 ${
!isMobile
? `ml-0 ${
!navOpen ? '-mt-5 md:mx-auto lg:mx-auto' : 'md:ml-72'
}`
? `ml-0 ${!navOpen ? '-mt-5 md:mx-auto lg:mx-auto' : 'md:ml-72'}`
: 'ml-0 md:ml-16'
}`}
>
Expand Down
89 changes: 47 additions & 42 deletions frontend/src/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { useMediaQuery, useOutsideAlerter } from './hooks';
import Upload from './upload/Upload';
import { Doc, getConversations } from './preferences/preferenceApi';
import SelectDocsModal from './preferences/SelectDocsModal';
import ConversationTile from './conversation/ConversationTile';

interface NavigationProps {
navOpen: boolean;
Expand Down Expand Up @@ -68,16 +69,20 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {

useEffect(() => {
if (!conversations) {
getConversations()
.then((fetchedConversations) => {
dispatch(setConversations(fetchedConversations));
})
.catch((error) => {
console.error('Failed to fetch conversations: ', error);
});
fetchConversations();
}
}, [conversations, dispatch]);

async function fetchConversations() {
return await getConversations()
.then((fetchedConversations) => {
dispatch(setConversations(fetchedConversations));
})
.catch((error) => {
console.error('Failed to fetch conversations: ', error);
});
}

const handleDeleteConversation = (id: string) => {
fetch(`${apiHost}/api/delete_conversation?id=${id}`, {
method: 'POST',
Expand All @@ -89,6 +94,7 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
) as HTMLElement;
const parentElement = imageElement.parentNode as HTMLElement;
parentElement.parentNode?.removeChild(parentElement);
fetchConversations();
})
.catch((error) => console.error(error));
};
Expand Down Expand Up @@ -126,6 +132,29 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
);
});
};

async function updateConversationName(updatedConversation: {
name: string;
id: string;
}) {
await fetch(`${apiHost}/api/update_conversation_name`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(updatedConversation),
})
.then((response) => response.json())
.then((data) => {
if (data) {
navigate('/');
fetchConversations();
}
})
.catch((err) => {
console.error(err);
});
}
useOutsideAlerter(
navRef,
() => {
Expand Down Expand Up @@ -210,41 +239,17 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
</NavLink>
<div className="conversations-container max-h-[25rem] overflow-y-auto">
{conversations
? conversations.map((conversation) => {
return (
<div
key={conversation.id}
onClick={() => {
handleConversationClick(conversation.id);
}}
className={`my-auto mx-4 mt-4 flex h-12 cursor-pointer items-center justify-between gap-4 rounded-3xl hover:bg-gray-100 ${
conversationId === conversation.id ? 'bg-gray-100' : ''
}`}
>
<div className="flex gap-4">
<img src={Message} className="ml-2 w-5"></img>
<p className="my-auto text-eerie-black">
{conversation.name.length > 45
? conversation.name.substring(0, 45) + '...'
: conversation.name}
</p>
</div>

{conversationId === conversation.id ? (
<img
src={Exit}
alt="Exit"
className="mr-4 h-3 w-3 cursor-pointer hover:opacity-50"
id={`img-${conversation.id}`}
onClick={(event) => {
event.stopPropagation();
handleDeleteConversation(conversation.id);
}}
/>
) : null}
</div>
);
})
? conversations.map((conversation, index) => (
<ConversationTile
key={index}
conversation={conversation}
selectConversation={(id) => handleConversationClick(id)}
onDeleteConversation={(id) => handleDeleteConversation(id)}
onSave={(conversation) =>
updateConversationName(conversation)
}
/>
))
: null}
</div>

Expand Down
3 changes: 3 additions & 0 deletions frontend/src/assets/checkMark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions frontend/src/assets/checkmark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/src/assets/edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions frontend/src/assets/trash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions frontend/src/conversation/ConversationBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const ConversationBubble = forwardRef<
<div className="flex self-start">
<Avatar className="mt-2 text-2xl" avatar="🦖"></Avatar>
<div
className={`ml-2 mr-5 flex items-center bg-gray-1000 p-3.5 ${
className={`ml-2 mr-5 flex flex-col items-center rounded-3xl bg-gray-1000 p-3.5 ${
type === 'ERROR'
? 'flex-row rounded-full border border-transparent bg-[#FFE7E7] p-2 py-5 text-sm font-normal text-red-3000 dark:border-red-2000 dark:text-white'
: 'flex-col rounded-3xl'
Expand All @@ -84,7 +84,7 @@ const ConversationBubble = forwardRef<
<img src={Alert} alt="alert" className="mr-2 inline" />
)}
<ReactMarkdown
className="whitespace-pre-wrap break-words"
className="max-w-screen-md whitespace-pre-wrap break-words"
components={{
code({ node, inline, className, children, ...props }) {
const match = /language-(\w+)/.exec(className || '');
Expand Down
Loading

0 comments on commit 3e20552

Please sign in to comment.