Skip to content

Commit 0a7ef5b

Browse files
AndlerRLBran18sheriffjimoh
authored
feat: april 1st release - enhance hasura permissions, thread fetching, gemini ai integration (#439)
* fix: change toggler wording + util hook (#424) * impr: makes threads open on profile page and profile tweaks (#421) * update * fix: update * update * update * update * update * fix: opening threads * fix: rm threads dropdwon & added back link to bot page thread view page * fix: rm threads dropdwon & added back link to bot page thread view page * fix: update * fix: added back to profile page * fix: added sticky and color * fix: codeblock ctas refactor markdown rendering, sidebar nav, code block & clipboard hook (#425) * fix: codeblock ctas * fix: ts build * fix: continue thread + allMessages sequence + mobile chat css tweak (#426) * fix: css handleCLick condition * fix: get latest search params, continuous thread * fix(impr): all messages sorting * perf(impr): sign in & up redirection tweak * perf(impr): mobile chat css * chore: next + react security ver upt (#427) * refactor: use chat and continue thread + continue conversation fallback (#432) * refactor: use chat and continue generation * fix: uniq slug and id gen (#433) * fix: uniq thread + msg slug gen * style: formatting * fix: thread user attachments state upt * perf: impr thread component at all pages + mobile tweaks * refactor: thread-component card * chore: restore continue generation v1 * feat(impr): thread component card * fix: admin panel n actions * fix: fetch getThreads * chore: continue conversation v1.2 * chore: continue and update thread content * chore: add ui control continue generation state * chore: fix infinity loop * chore(impr): enable upt msg table permission * fix: seo thread fetch * chore: style formating * fix(impr): continued thread title + thread component reusability * chore: refactor loadings + extending sonners --------- Co-authored-by: bran18 <andreyfdez18@gmail.com> --------- Co-authored-by: Roberto Lucas <andler@bitcash.org> * feat: add gemini provider (#437) * feat: add gemini provider * chore: update icons * feat: impr continuing thread tags + accordion first msg toggle (#435) * feat(wip): impr continuing thread tags + accordion first msg toggle * feat(impr): continuing thread tags + accordion at first message + header mobile tweak * style(impr): mobile thread-component x-axis space * perf(style): coderabbitai feedbacks * fix: css typo * perf: sendMessageFromResponse clicked guard + continued thread tags label tweak * chore: user thread panel clean up * fix: user-thread-panel infinite loader * perf: impr shared accordion animation and ux * style: defaultAccordionState comments loc * fix: record type warning, hasura updateMessage * fix: getThread user data, shared-accordion * fix: coderabbitai observations --------- Co-authored-by: Brandon Fernández <31634868+Bran18@users.noreply.github.com> Co-authored-by: Jimoh sherifdeen <63134009+sheriffjimoh@users.noreply.github.com>
1 parent 5fc400b commit 0a7ef5b

File tree

76 files changed

+1517
-897
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+1517
-897
lines changed

apps/hasura/metadata/databases/masterbots/tables/public_message.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,24 @@ select_permissions:
108108
filter: {}
109109
allow_aggregations: true
110110
comment: ""
111+
update_permissions:
112+
- role: moderator
113+
permission:
114+
columns:
115+
- content
116+
filter: {}
117+
check: null
118+
comment: ""
119+
- role: user
120+
permission:
121+
columns:
122+
- content
123+
filter:
124+
thread:
125+
user_id:
126+
_eq: X-Hasura-User-Id
127+
check: null
128+
comment: ""
111129
delete_permissions:
112130
- role: moderator
113131
permission:

apps/masterbots.ai/app/(browse)/[category]/[domain]/[chatbot]/[threadSlug]/[threadQuestionSlug]/page.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import BrowseList from '@/components/routes/browse/browse-list'
22
import { BrowseSearchInput } from '@/components/routes/browse/browse-search-input'
33
import { PAGE_SIZE } from '@/lib/constants/hasura'
4-
import { getCategories, getThreads } from '@/services/hasura'
4+
import { getBrowseThreads, getCategories } from '@/services/hasura'
55
import type { PageProps } from '@/types/types'
66
import { toSlug } from 'mb-lib'
77

@@ -20,20 +20,23 @@ export default async function BrowserThreadQuestionPage(props: PageProps) {
2020
const category = categories.find(
2121
(category) => toSlug(category.name) === params.category,
2222
)
23-
const threads = await getThreads({
23+
const { threads, count } = await getBrowseThreads({
2424
categoryId: category?.categoryId,
2525
limit: PAGE_SIZE,
26-
jwt: '',
2726
})
2827

2928
return (
30-
<div className="w-full max-w-screen-lg pb-10 mx-auto">
29+
<div className="w-full max-w-screen-xl pb-10 mx-auto">
3130
{/* <BrowseCategoryTabs
3231
initialCategory={params.category}
3332
categories={categories}
3433
/> */}
3534
<BrowseSearchInput />
36-
<BrowseList initialThreads={threads} categoryId={category?.categoryId} />
35+
<BrowseList
36+
initialThreads={threads}
37+
initialCount={count}
38+
categoryId={category?.categoryId}
39+
/>
3740
</div>
3841
)
3942
}

apps/masterbots.ai/app/(browse)/[category]/[domain]/[chatbot]/[threadSlug]/page.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import BrowseList from '@/components/routes/browse/browse-list'
22
import { BrowseSearchInput } from '@/components/routes/browse/browse-search-input'
33
import { PAGE_SIZE } from '@/lib/constants/hasura'
4-
import { getCategories, getThreads } from '@/services/hasura'
4+
import { getBrowseThreads, getCategories } from '@/services/hasura'
55
import type { PageProps } from '@/types/types'
66
import { toSlug } from 'mb-lib'
77

@@ -23,20 +23,23 @@ export default async function ChatPage(props: PageProps) {
2323
const category = categories.find(
2424
(category) => toSlug(category.name) === params.category,
2525
)
26-
const threads = await getThreads({
26+
const { threads, count } = await getBrowseThreads({
2727
categoryId: category?.categoryId,
2828
limit: PAGE_SIZE,
29-
jwt: '',
3029
})
3130

3231
return (
33-
<div className="w-full max-w-screen-lg pb-10 mx-auto">
32+
<div className="w-full max-w-screen-xl pb-10 mx-auto">
3433
{/* <BrowseCategoryTabs
3534
initialCategory={params.category}
3635
categories={categories}
3736
/> */}
3837
<BrowseSearchInput />
39-
<BrowseList initialThreads={threads} categoryId={category?.categoryId} />
38+
<BrowseList
39+
initialThreads={threads}
40+
initialCount={count}
41+
categoryId={category?.categoryId}
42+
/>
4043
</div>
4144
)
4245
}

apps/masterbots.ai/app/(browse)/[category]/[domain]/[chatbot]/page.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BrowseSearchInput } from '@/components/routes/browse/browse-search-inpu
33
import { botNames } from '@/lib/constants/bots-names'
44
import { PAGE_SIZE } from '@/lib/constants/hasura'
55
import { generateMetadataFromSEO } from '@/lib/metadata'
6-
import { getChatbot, getThreads } from '@/services/hasura'
6+
import { getBrowseThreads, getChatbot } from '@/services/hasura'
77
import type { Metadata } from 'next'
88

99
export default async function BrowseCategoryChatbotPage(props: {
@@ -18,10 +18,13 @@ export default async function BrowseCategoryChatbotPage(props: {
1818

1919
if (!chatbot) throw new Error(`Chatbot ${chatbotName} not found`)
2020

21-
const threads = await getThreads({ chatbotName, limit: PAGE_SIZE, jwt: '' })
21+
const { threads, count } = await getBrowseThreads({
22+
chatbotName,
23+
limit: PAGE_SIZE,
24+
})
2225

2326
return (
24-
<div className="w-full max-w-screen-lg pb-10 mx-auto">
27+
<div className="w-full max-w-screen-xl pb-10 mx-auto">
2528
{/* <BrowseCategoryTabs
2629
initialCategory={params.category}
2730
categories={categories}
@@ -31,6 +34,7 @@ export default async function BrowseCategoryChatbotPage(props: {
3134
categoryId={chatbot.categories[0].categoryId}
3235
chatbot={chatbot}
3336
initialThreads={threads}
37+
initialCount={count}
3438
/>
3539
</div>
3640
)

apps/masterbots.ai/app/(browse)/[category]/page.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import BrowseList from '@/components/routes/browse/browse-list'
22
import { BrowseSearchInput } from '@/components/routes/browse/browse-search-input'
33
import { PAGE_SIZE } from '@/lib/constants/hasura'
44
import { generateMetadataFromSEO } from '@/lib/metadata'
5-
import { getCategories, getThreads } from '@/services/hasura'
5+
import { getBrowseThreads, getCategories } from '@/services/hasura'
66
import { toSlug } from 'mb-lib'
77
import type { Metadata } from 'next'
88

@@ -14,20 +14,23 @@ export default async function BrowseCategoryPage(props: {
1414
const category = categories.find(
1515
(category) => toSlug(category.name) === params.category,
1616
)
17-
const threads = await getThreads({
17+
const { threads, count } = await getBrowseThreads({
1818
categoryId: category?.categoryId,
1919
limit: PAGE_SIZE,
20-
jwt: '',
2120
})
2221

2322
return (
24-
<div className="w-full max-w-screen-lg pb-10 mx-auto">
23+
<div className="w-full max-w-screen-xl pb-10 mx-auto">
2524
{/* <BrowseCategoryTabs
2625
initialCategory={params.category}
2726
categories={categories}
2827
/> */}
2928
<BrowseSearchInput />
30-
<BrowseList initialThreads={threads} categoryId={category?.categoryId} />
29+
<BrowseList
30+
initialThreads={threads}
31+
categoryId={category?.categoryId}
32+
initialCount={count}
33+
/>
3134
</div>
3235
)
3336
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import BrowseList from '@/components/routes/browse/browse-list'
22
import { BrowseSearchInput } from '@/components/routes/browse/browse-search-input'
33
import { PAGE_SIZE } from '@/lib/constants/hasura'
4-
import { getThreads } from '@/services/hasura'
4+
import { getBrowseThreads } from '@/services/hasura'
55

66
export default async function HomePage() {
7-
const threads = await getThreads({ limit: PAGE_SIZE, jwt: '' })
7+
const { threads, count } = await getBrowseThreads({ limit: PAGE_SIZE })
88

99
return (
1010
<>
1111
<BrowseSearchInput />
12-
<BrowseList initialThreads={threads} />
12+
<BrowseList initialThreads={threads} initialCount={count} />
1313
</>
1414
)
1515
}

apps/masterbots.ai/app/actions/ai-main-call.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type {
2525
JSONResponseStream,
2626
} from '@/types/types'
2727
import { createAnthropic } from '@ai-sdk/anthropic'
28+
import { createGoogleGenerativeAI } from '@ai-sdk/google'
2829
import { createGroq } from '@ai-sdk/groq'
2930
import { createOpenAI } from '@ai-sdk/openai'
3031
import {
@@ -97,6 +98,17 @@ export async function initializePerplexity(apiKey: string) {
9798
})
9899
}
99100

101+
const initializeGoogle = (apiKey: string) => {
102+
if (!apiKey) {
103+
throw new Error(
104+
'GOOGLE_GENERATIVE_AI_API_KEY is not defined in environment variables',
105+
)
106+
}
107+
return createGoogleGenerativeAI({
108+
apiKey,
109+
})
110+
}
111+
100112
// * This function improves the message using the AI
101113
export async function improveMessage(
102114
userPrompt: {
@@ -412,6 +424,26 @@ export async function createResponseStream(
412424
})
413425
break
414426
}
427+
case 'Gemini': {
428+
const googleAI = initializeGoogle(
429+
previewToken || (process.env.GOOGLE_GENERATIVE_AI_API_KEY as string),
430+
)
431+
const googleModel = googleAI(model)
432+
response = await streamText({
433+
model: googleModel,
434+
messages: coreMessages,
435+
temperature: 0.3,
436+
tools,
437+
maxRetries: 2,
438+
providerOptions: {
439+
google: {
440+
//? Enables web search
441+
useSearchGrounding: webSearch || false,
442+
},
443+
},
444+
})
445+
break
446+
}
415447
default:
416448
throw new Error('Unsupported client type')
417449
}

apps/masterbots.ai/app/api/chat/models/models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ export enum AIModels {
77
WordWare = 'wordware-ai',
88
DeepSeekR1 = 'deepseek-r1',
99
DeepSeekGroq = 'deepseek-r1-distill-llama-70b',
10+
Gemini = 'gemini-2.0-flash',
1011
}

apps/masterbots.ai/app/b/[botSlug]/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default async function BotThreadsPage(props: PageProps) {
2121
if (!chatbot) throw new Error(`Chatbot ${chatbotName} not found`)
2222

2323
// session will always be defined
24-
const threads = await getBrowseThreads({
24+
const { threads, count } = await getBrowseThreads({
2525
chatbotName,
2626
limit: PAGE_SIZE,
2727
})
@@ -41,6 +41,7 @@ export default async function BotThreadsPage(props: PageProps) {
4141
</div>
4242
<BrowseSpecificThreadList
4343
initialThreads={threads}
44+
initialCount={count}
4445
PAGE_SIZE={PAGE_SIZE}
4546
query={{
4647
chatbotName,

apps/masterbots.ai/app/c/[category]/[domain]/[chatbot]/[threadSlug]/[threadQuestionSlug]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default async function BotThreadPopUpQuestionPage(props: {
4040
throw new Error('User ID is missing.')
4141
}
4242

43-
const threads = await getThreads({
43+
const { threads, count } = await getThreads({
4444
chatbotName,
4545
jwt: jwt as string,
4646
userId,
@@ -49,7 +49,7 @@ export default async function BotThreadPopUpQuestionPage(props: {
4949

5050
return (
5151
<>
52-
<ThreadPanel threads={threads} />
52+
<ThreadPanel threads={threads} count={count} />
5353
<ChatChatbot chatbot={chatbot} />
5454
</>
5555
)

0 commit comments

Comments
 (0)