Skip to content
Merged
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
8 changes: 4 additions & 4 deletions apps/knowledge/sql/blend_search.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ SELECT
FROM
(
SELECT DISTINCT ON
( "paragraph_id" ) ( 1 - distince + ts_similarity ) as similarity, *,
(1 - distince + ts_similarity) AS comprehensive_score
( "paragraph_id" ) ( 1 - distance + ts_similarity ) as similarity, *,
(1 - distance + ts_similarity) AS comprehensive_score
FROM
(
SELECT
*,
(embedding.embedding::vector(%s) <=> %s) as distince,
(embedding.embedding::vector(%s) <=> %s) as distance,
(ts_rank_cd( embedding.search_vector, websearch_to_tsquery('simple', %s ), 32 )) AS ts_similarity
FROM
embedding ${embedding_query}
ORDER BY distince
ORDER BY distance
) TEMP
ORDER BY
paragraph_id,
Expand Down
6 changes: 3 additions & 3 deletions apps/knowledge/sql/embedding_search.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ SELECT
FROM
(
SELECT DISTINCT ON
("paragraph_id") ( 1 - distince ),* ,(1 - distince) AS comprehensive_score
("paragraph_id") ( 1 - distance ),* ,(1 - distance) AS comprehensive_score
FROM
( SELECT *, ( embedding.embedding::vector(%s) <=> %s ) AS distince FROM embedding ${embedding_query} ORDER BY distince) TEMP
( SELECT *, ( embedding.embedding::vector(%s) <=> %s ) AS distance FROM embedding ${embedding_query} ORDER BY distance) TEMP
ORDER BY
paragraph_id,
distince
distance
) DISTINCT_TEMP
WHERE comprehensive_score>%s
ORDER BY comprehensive_score DESC
Expand Down
13 changes: 9 additions & 4 deletions ui/src/views/paragraph/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@
<LayoutContainer showCollapse>
<template #left>
<div class="paragraph-sidebar p-16">
<el-scrollbar class="paragraph-scollbar">
<el-scrollbar class="paragraph-scrollbar">
<el-anchor
direction="vertical"
type="default"
:offset="130"
container=".paragraph-scollbar"
container=".paragraph-scrollbar"
@click="handleClick"
>
<template v-for="item in paragraphDetail" :key="item.id">
Expand All @@ -76,7 +76,7 @@
<div class="w-full">
<el-empty v-if="paragraphDetail.length == 0" :description="$t('common.noData')" />
<div v-else>
<el-scrollbar class="paragraph-scollbar">
<el-scrollbar class="paragraph-scrollbar">
<div class="paragraph-detail">
<el-checkbox-group v-model="multipleSelection">
<InfiniteScroll
Expand Down Expand Up @@ -175,7 +175,12 @@
{{ $t('common.selected') }} {{ multipleSelection.length }}
{{ $t('views.document.items') }}
</span>
<el-button link type="primary" v-if="multipleSelection.length > 0" @click="multipleSelection = []">
<el-button
link
type="primary"
v-if="multipleSelection.length > 0"
@click="multipleSelection = []"
>
{{ $t('common.clear') }}
</el-button>
</div>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The provided code is generally well-structured, but there are a few small issues and enhancements that could be made:

Issues/Improvements:

  1. Typo in container Attribute:

    • In the <el-anchor> component, the attribute used for the container should be .paragraph-scollbar, not .paragragh-scollar. Ensure consistency with HTML tags.
  2. Redundant Class Naming:

    • Both classes have similar names (el-scrollbar), which might contribute to confusion or redundancy. Consider renaming one of these classes if they serve different purposes.
  3. Consistent Styling and Layout:

    • The layout seems consistent overall, but ensure that the padding on the left sidebar is appropriate and does not cause conflicts elsewhere in your design.

Here's the revised version with these improvements applied:

<template>
  <LayoutContainer show-collapse>
    <template #left>
      <div class="paragraph-sidebar p-16">
        <el-scrollbar class="paragraph-scrollbar">
          <el-anchor
            direction="vertical"
            type="default"
            :offset="130"
            container=".paragraph-scrollbar"
            @click="handleClick"
          >
            <!-- Repeated elements -->
            <template v-for="(item, index) in paragraphDetail" :key="index">
              <!-- Element content here -->
            </template>
          </el-anchor>
        </el-scrollbar>
      </div>
    </template>

    <div class="w-full">
      <!-- Possible changes can occur here regarding empty state display -->

    </div>

    <div style="display: flex; justify-content: space-between;">
      <p>{{ $t('common.selected') }} {{ multipleSelection.length }}</p>
      <el-button link type="primary" v-if="multipleSelection.length > 0" @click="multipleSelection = []">
        {{ $t('common.clear') }}
      </el-button>
    </div>
  </LayoutContainer>
</template>

Remember to make necessary adjustments based on the specific context and requirements of your application.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
>
<el-option :label="$t('common.creator')" value="create_user" />
<el-option :label="$t('common.name')" value="name" />
<el-option :label="$t('views.system.resource_management.type')" value="type"/>
<el-option :label="$t('views.system.resource_management.type')" value="type" />
</el-select>
<el-input
v-if="search_type === 'name'"
Expand Down Expand Up @@ -45,7 +45,7 @@
filterable
style="width: 220px"
>
<el-option v-for="u in type_options" :value="u.value" :label="u.label"/>
<el-option v-for="u in type_options" :value="u.value" :label="u.label" />
</el-select>
</div>
</div>
Expand Down Expand Up @@ -306,7 +306,7 @@ const ManagePermission = () => {
permissionPrecise.value.hit_test()
)
}
// sync generete edit export delete

const MoreFilledPermission = () => {
return (
permissionPrecise.value.sync() ||
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The provided code is syntactically correct. It appears to be managing a dropdown menu with options for different search types (creator, name) and handling filtering based on those selections. Here are some general suggestions:

  1. Code Formatting: Ensure consistent indentation throughout your code. While minor adjustments can make the code slightly cleaner, it should maintain readability across different contexts.

  2. Docstring: Consider adding docstrings or comments to describe important sections of the code. This can help others understand its functionality and maintenance needs.

  3. Variable Naming: Consistently use naming conventions such as title instead of $t('views.system.resource_management.type'). Titles should be user-friendly and descriptive.

  4. Function Naming: Use meaningful function names that reflect their purpose. Instead of having long functions like ManagePermission, consider using more specific names that indicate what they do directly (filterPermissions).

  5. Comments: Provide comments to explain complex logic if necessary. For example, explaining why certain checks are performed or when certain operations occur might improve clarity.

Here's an optimized version of the MoreFilledPermission function:

const MoreFilledPermission = () => {
  return (
    permissionPrecise.value.sync() || // Sync permissions data
    permissionPrecise.value.fetchResources() // Fetch resources based on current filters
  );
}

By making these slight improvements, you enhance both readability and maintainability of the codebase.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ const paginationConfig = reactive({
total: 0,
})

// sync generete edit export delete
const MoreFilledPermission = () => {
return permissionPrecise.value.delete() || permissionPrecise.value.modify()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no immediate issue with this code snippet that requires adjustment. However, if you want to optimize it slightly and improve clarity:

const paginationConfig = reactive({
  total: 0,
})

// Suggest renaming generateExportDeletePermissions to make the function name more descriptive
const generateExportDeletePermissions = () => {
  return [
    permissionPrecise.value.delete(),
    permissionPrecise.value.modify(), // Assuming both are booleans or can be truthy/falsy
  ].some(Boolean) || false; // Using Array.prototype.some for a cleaner approach
}

This version uses Array.prototype.some to combine the two checks into one line, which might make the logic easier to read. Note that some(true) will only return true if any element in the array evaluates to truthy; otherwise, it returns false, similar to checking if either condition allows deletion.

Additionally, consider handling edge cases where neither operation (delete nor modify) has access rights differently, depending on your application's requirements.

Expand Down
Loading