File tree 5 files changed +48
-3
lines changed
5 files changed +48
-3
lines changed Original file line number Diff line number Diff line change 2
2
** /.DS_Store
3
3
4
4
# -=- Eroxl's Device Specific Ignores -=-
5
- ** /Icon ?
5
+ Icon ?
6
+ ! icons
6
7
7
8
# -=- Node Modules -=-
8
9
** /node_modules /**
15
16
** /cypress /videos
16
17
17
18
# -=- Security -=-
18
- /config /.env
19
+ /config /.env
Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import ChromaClient from './clients/ChromaClient';
3
3
4
4
import type { ChatCompletionRequestMessage } from 'openai' ;
5
5
6
+ const RELATIVE_TEXT_COUNT = 3 ;
7
+
6
8
const CONTEXT_PROMPT_TEMPLATE = '### Context: ' ;
7
9
8
10
const QUESTION_PROMPT_TEMPLATE = '### Question: ' ;
@@ -47,7 +49,7 @@ const getChatResponse = async (
47
49
// ~ Query the database for the most similar message
48
50
const similarMessages = await blockCollection . query (
49
51
embeddings . data . data [ 0 ] . embedding ,
50
- 1 ,
52
+ RELATIVE_TEXT_COUNT ,
51
53
{
52
54
userID : user ,
53
55
} ,
@@ -89,6 +91,9 @@ const getChatResponse = async (
89
91
. join ( '\n' )
90
92
91
93
94
+ // ~ TODO: Start adding support for streaming the response
95
+ // https://www.reddit.com/r/ChatGPT/comments/11m3jdw/chatgpt_api_streaming/
96
+ // https://gist.github.com/montanaflynn/6a438f0be606daede899
92
97
const response = await OpenAIClient . createChatCompletion ( {
93
98
messages : [
94
99
{
Original file line number Diff line number Diff line change 1
1
import React , { useState , useEffect } from 'react' ;
2
+ import Image from 'next/image' ;
2
3
3
4
import PageSidebarItem from './PageSidebarItem' ;
5
+ import Brain from '../../public/icons/Brain.svg' ;
6
+ import Search from '../../public/icons/Search.svg' ;
4
7
5
8
export interface PageSidebarItemProps {
6
9
_id : string ,
@@ -55,6 +58,36 @@ const PageSidebar = () => {
55
58
56
59
return (
57
60
< div className = "absolute h-screen pt-12 pr-3 select-none print:h-max w-52 print:w-0 bg-amber-400/10 no-scrollbar dark:bg-white/10" >
61
+ < div className = "flex flex-col w-full gap-2 pb-2 pl-3" >
62
+ < button
63
+ className = "flex flex-row gap-1 p-2 py-1 text-left text-white rounded hover:bg-white/20"
64
+ onClick = { ( ) => {
65
+ document . dispatchEvent ( new CustomEvent ( 'openSearchModal' ) ) ;
66
+ } }
67
+ >
68
+ < Image
69
+ src = { Search }
70
+ alt = "Search"
71
+ width = { 24 }
72
+ height = { 24 }
73
+ />
74
+ Search
75
+ </ button >
76
+ < button
77
+ className = "flex flex-row gap-1 p-2 py-1 text-left text-white rounded hover:bg-white/20"
78
+ onClick = { ( ) => {
79
+ document . dispatchEvent ( new CustomEvent ( 'openChatPage' ) ) ;
80
+ } }
81
+ >
82
+ < Image
83
+ src = { Brain }
84
+ alt = "Chat"
85
+ width = { 24 }
86
+ height = { 24 }
87
+ />
88
+ Chat
89
+ </ button >
90
+ </ div >
58
91
{ /* ~ Render the page tree after it has been loaded */ }
59
92
{ ! isLoading && (
60
93
( pageTree as PageSidebarItemProps [ ] ) . map ( ( pageItem ) => {
You can’t perform that action at this time.
0 commit comments