-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support o1 and o1-high-reasoning for custom assistants
- Loading branch information
Henry Fontanier
committed
Dec 23, 2024
1 parent
20216a0
commit f26aa54
Showing
13 changed files
with
158 additions
and
27 deletions.
There are no files selected for viewing
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
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
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,20 @@ | ||
import type { LightWorkspaceType } from "@dust-tt/types"; | ||
import type { Fetcher } from "swr"; | ||
|
||
import { fetcher, useSWRWithDefaults } from "@app/lib/swr/swr"; | ||
import type { GetAvailableModelsResponseType } from "@app/pages/api/w/[wId]/models"; | ||
|
||
export function useModels({ owner }: { owner: LightWorkspaceType }) { | ||
const modelsFetcher: Fetcher<GetAvailableModelsResponseType> = fetcher; | ||
|
||
const { data, error } = useSWRWithDefaults( | ||
`/api/w/${owner.sId}/models`, | ||
modelsFetcher | ||
); | ||
|
||
return { | ||
models: data ? data.models : [], | ||
isModelsLoading: !error && !data, | ||
isModelsError: !!error, | ||
}; | ||
} |
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,67 @@ | ||
import type { | ||
ModelConfigurationType, | ||
WithAPIErrorResponse, | ||
} from "@dust-tt/types"; | ||
import { isProviderWhitelisted } from "@dust-tt/types"; | ||
import type { NextApiRequest, NextApiResponse } from "next"; | ||
|
||
import { USED_MODEL_CONFIGS } from "@app/components/providers/types"; | ||
import { withSessionAuthenticationForWorkspace } from "@app/lib/api/auth_wrappers"; | ||
import type { Authenticator } from "@app/lib/auth"; | ||
import { getFeatureFlags } from "@app/lib/auth"; | ||
import { isUpgraded } from "@app/lib/plans/plan_codes"; | ||
import { apiError } from "@app/logger/withlogging"; | ||
|
||
export type GetAvailableModelsResponseType = { | ||
models: ModelConfigurationType[]; | ||
}; | ||
|
||
async function handler( | ||
req: NextApiRequest, | ||
res: NextApiResponse<WithAPIErrorResponse<GetAvailableModelsResponseType>>, | ||
auth: Authenticator | ||
): Promise<void> { | ||
const owner = auth.getNonNullableWorkspace(); | ||
const plan = auth.plan(); | ||
|
||
switch (req.method) { | ||
case "GET": | ||
const featureFlags = await getFeatureFlags(owner); | ||
|
||
const models: ModelConfigurationType[] = []; | ||
for (const m of USED_MODEL_CONFIGS) { | ||
if ( | ||
!isProviderWhitelisted(owner, m.providerId) || | ||
(m.largeModel && !isUpgraded(plan)) | ||
) { | ||
continue; | ||
} | ||
|
||
if (m.featureFlag && !featureFlags.includes(m.featureFlag)) { | ||
continue; | ||
} | ||
|
||
if ( | ||
m.customAssistantFeatureFlag && | ||
!featureFlags.includes(m.customAssistantFeatureFlag) | ||
) { | ||
continue; | ||
} | ||
|
||
models.push(m); | ||
} | ||
|
||
return res.status(200).json({ models }); | ||
|
||
default: | ||
return apiError(req, res, { | ||
status_code: 405, | ||
api_error: { | ||
type: "method_not_supported_error", | ||
message: "The method passed is not supported, GET is expected.", | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
export default withSessionAuthenticationForWorkspace(handler); |
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
Oops, something went wrong.