-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#55 Adding feature toggles and place holders for the Documents tab
- Loading branch information
Showing
8 changed files
with
197 additions
and
11 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
...64457_adding_feature_map_so_we_can_enable_and_disable_based_on_model_design/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "Model" ADD COLUMN "features" JSONB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import OpenAI from 'openai'; | ||
import { PrismaClient } from '@prisma/client'; | ||
import { getToken } from 'next-auth/jwt'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
const prisma = new PrismaClient(); | ||
|
||
const getId = (req: Request) => { | ||
const url = new URL(req.url); | ||
return url.pathname.split('/').splice(-1, 1)[0]; | ||
}; | ||
|
||
// Note: We should not cache the models list as it may change frequently for different organizations | ||
export async function GET(req: NextRequest, res: NextResponse) { | ||
const token = await getToken({ req }); | ||
if (token) { | ||
let id = getId(req); | ||
let model = await prisma.model.findFirst({ | ||
where: { | ||
id: id, | ||
}, | ||
include: { | ||
provider: true, | ||
}, | ||
}); | ||
return Response.json(model, { status: 200 }); | ||
} else { | ||
// Not Signed in | ||
return Response.json({ message: 'Unauthenticated' }, { status: 401 }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'use client'; | ||
|
||
import React, { useContext, useEffect, useState } from 'react'; | ||
import AssistantContext from '@/app/assistants/[id]/AssistantContext'; | ||
import { getModel } from '@/app/assistants/[id]/client'; | ||
import { Spinner } from 'flowbite-react'; | ||
import { Model } from '@/app/types/model'; | ||
import { HiOutlineFolder } from "react-icons/hi"; | ||
|
||
export default function Documents() { | ||
const { assistant } = useContext(AssistantContext); | ||
const [loading, setLoading] = useState(true); | ||
const [model, setModel] = useState<Model | null>(null); | ||
|
||
useEffect(() => { | ||
if (assistant.modelId) { | ||
getModel(assistant.modelId).then(([status,response]) => { | ||
console.log(response); | ||
setModel(response); | ||
setLoading(false); | ||
}); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div className='stack items-center justify-center'> | ||
<h3 className='pb-4 text-3xl font-bold dark:text-white'>Documents</h3> | ||
{ | ||
loading ? ( | ||
<div className="bg-grey flex h-[calc(100vh-120px)] items-center justify-center "> | ||
<Spinner /> | ||
</div> | ||
) : ( | ||
<div> | ||
{ model?.features?.retrieval ? ( | ||
<div> | ||
This model supports document retrieval, we are working on it | ||
</div> | ||
) : ( | ||
<div className='bg-grey flex flex-col h-[calc(100vh-120px)] items-center justify-center'> | ||
<HiOutlineFolder className='text-9xl text-gray-400 dark:text-gray-700' /> | ||
<p className='text-gray-400 dark:text-gray-400'>Support for documents is not available for <b>{model? model.id : 'this model'}</b> yet.</p> | ||
</div> | ||
) | ||
} | ||
</div> | ||
) | ||
} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters