Skip to content

Commit

Permalink
Add score and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jlpereira committed Jan 29, 2024
1 parent 36446d1 commit 74c36c6
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 148 deletions.
3 changes: 2 additions & 1 deletion src/adapters/makeIAMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ export function makeIAMessage(response: BHLQuestResponse): BHLQuestMessage {
(item): BHLQuestMessageReference =>
({
link: item.outlink,
pageId: item.pageId,
score: item.score,
text: item.text,
title: item.reference,
pageId: item.pageId,
pageIndex: item.pageIndex,
pages: item.pages.map((item) => ({
id: item.id,
Expand Down
6 changes: 3 additions & 3 deletions src/components/Chat/BHLQuest/BHLQuestMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
/>
<div v-else>I cannot provide an answer to your question.</div>
<template v-if="message.references">
<h3 class="my-2 font-semibold">References</h3>
<h3 class="mt-4 font-semibold text-lg">References</h3>
<ul>
<li
v-for="(reference, index) in message.references"
:key="message.date"
class="my-2"
>
<ChatAIReference
<BHLQuestReference
:reference="reference"
:index="index"
/>
Expand All @@ -27,7 +27,7 @@

<script setup lang="ts">
import { BHLQuestMessage } from '@/types'
import ChatAIReference from './BHLQuestReference.vue'
import BHLQuestReference from './BHLQuestReference.vue'
type Props = {
message: BHLQuestMessage
Expand Down
32 changes: 12 additions & 20 deletions src/components/Chat/BHLQuest/BHLQuestReference.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
class="text-primary-color break-all"
>
{{ reference.title }}
<p
v-if="referenceScore"
class="text-sm text-gray-500"
>
Score {{ reference.score.toFixed(4) }}
</p>
</a>
</div>
<template v-if="isExpanded">
Expand All @@ -46,15 +52,6 @@
v-html="parseOCRText(text)"
/>
</div>
<div
v-if="isImageViewerVisible"
class="mt-2"
>
<ImageViewer
:page-ids="reference.pages"
:page-index="reference.pageIndex"
/>
</div>
</template>
</div>
</template>
Expand All @@ -65,7 +62,6 @@ import { BHLQuestMessageReference } from '@/types'
import { useSettings } from '@/store'
import IconChevronLeft from '@/components/Icon/IconChevronLeft.vue'
import IconChevronDown from '@/components/Icon/IconChevronDown.vue'
import ImageViewer from '@/components/ImageViewer/ImageViewer.vue'
interface Props {
index: number
Expand All @@ -74,23 +70,19 @@ interface Props {
defineProps<Props>()
const referenceRef = ref<HTMLElement | null>(null)
const { referencePreformattedText, referenceExpanded } = useSettings()
const { referencePreformattedText, referenceExpanded, referenceScore } =
useSettings()
const textComponent = computed(() =>
referencePreformattedText.value ? 'pre' : 'p'
)
const isExpanded = ref(true)
const isImageViewerVisible = ref(false)
function parseOCRText(text: string) {
return (
text
//.replaceAll('\r\r', '\r')
.replace(/(\r?\r){2,}/g, '')
.replace(/(\r\n)+/g, '\r\n')
.trim()
)
return text
.replace(/(\r?\r){2,}/g, '')
.replace(/(\r\n)+/g, '\r\n')
.trim()
}
watch(
Expand Down
65 changes: 0 additions & 65 deletions src/components/ImageViewer/ImagePage.vue

This file was deleted.

54 changes: 0 additions & 54 deletions src/components/ImageViewer/ImageViewer.vue

This file was deleted.

12 changes: 12 additions & 0 deletions src/components/Setting/PanelSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
Expand
</label>
</li>

<li>
<label>
<input
Expand All @@ -48,6 +49,16 @@
Preformatted text
</label>
</li>

<li>
<label>
<input
type="checkbox"
v-model="referenceScore"
/>
Score
</label>
</li>
</ul>
</div>
<div class="mb-4">
Expand All @@ -70,6 +81,7 @@ const {
openSettings,
referenceExpanded,
referencePreformattedText,
referenceScore,
parameters
} = useSettings()
</script>
2 changes: 1 addition & 1 deletion src/components/VCard.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div class="border p-4 rounded-lg border-base-border">
<div class="border p-4 rounded-lg border-gray-300">
<slot />
</div>
</template>
Expand Down
1 change: 1 addition & 0 deletions src/store/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const state = reactive<StoreSettings>({
openSettings: true,
referenceExpanded: true,
referencePreformattedText: true,
referenceScore: true,
parameters: {
scoreThreshold: 0.65,
maxResults: 5
Expand Down
7 changes: 4 additions & 3 deletions src/types/BHLQuestMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { ChatMessage } from './ChatMessage'

export type BHLQuestMessageReference = {
link: string
text: string[]
title: string
pageIndex: number
pageId: number
pageIndex: number
pages: Page[]
score: number
text: string[]
title: string
}

type Page = {
Expand Down
3 changes: 2 additions & 1 deletion src/types/StoreSettings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export type StoreSettings = {
keepChat: boolean
referenceExpanded: boolean
openSettings: boolean
referenceExpanded: boolean
referencePreformattedText: boolean
referenceScore: boolean
parameters: RequestParameters
}

Expand Down

0 comments on commit 74c36c6

Please sign in to comment.