Skip to content

Commit b6814a9

Browse files
authored
Merge pull request #305 from n4ze3m/next
v1.4.4
2 parents 17dc6a6 + 0c48bfa commit b6814a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+634
-224
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ keys.json
4545
# WXT
4646
.wxt
4747
# WebStorm
48-
.idea
48+
.idea

bun.lockb

1.98 KB
Binary file not shown.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"remark-math": "5.1.1",
5959
"tesseract.js": "^5.1.1",
6060
"turndown": "^7.1.3",
61+
"unist-util-visit": "^5.0.0",
6162
"yt-transcript": "^0.0.2",
6263
"zustand": "^4.5.0"
6364
},

src/assets/locale/ar/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,9 @@
125125
"pin": "تثبيت",
126126
"unpin": "إلغاء التثبيت",
127127
"generationInfo": "معلومات التوليد",
128-
"sidebarChat": "دردشة الشريط الجانبي"
128+
"sidebarChat": "دردشة الشريط الجانبي",
129+
"reasoning": {
130+
"thinking": "جاري التفكير....",
131+
"thought": "فكر لمدة {{time}}"
132+
}
129133
}

src/assets/locale/da/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,9 @@
118118
"pin": "Fastgør",
119119
"unpin": "Frigør",
120120
"generationInfo": "Genererings Info",
121-
"sidebarChat": "Sidepanel Chat"
121+
"sidebarChat": "Sidepanel Chat",
122+
"reasoning": {
123+
"thinking": "Tænker....",
124+
"thought": "Tænkte i {{time}}"
125+
}
122126
}

src/assets/locale/de/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,9 @@
118118
"pin": "Anheften",
119119
"unpin": "Losheften",
120120
"generationInfo": "Generierungsinformationen",
121-
"sidebarChat": "Seitenleisten-Chat"
121+
"sidebarChat": "Seitenleisten-Chat",
122+
"reasoning": {
123+
"thinking": "Denke nach....",
124+
"thought": "Gedanke für {{time}}"
125+
}
122126
}

src/assets/locale/en/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,9 @@
152152
"pin": "Pin",
153153
"unpin": "Unpin",
154154
"generationInfo": "Generation Info",
155-
"sidebarChat": "Sidebar Chat"
155+
"sidebarChat": "Sidebar Chat",
156+
"reasoning": {
157+
"thinking": "Thinking....",
158+
"thought": "Thought for {{time}}"
159+
}
156160
}

src/assets/locale/es/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,9 @@
117117
"pin": "Fijar",
118118
"unpin": "Desfijar",
119119
"generationInfo": "Información de Generación",
120-
"sidebarChat": "Chat lateral"
120+
"sidebarChat": "Chat lateral",
121+
"reasoning": {
122+
"thinking": "Pensando....",
123+
"thought": "Pensamiento por {{time}}"
124+
}
121125
}

src/assets/locale/fa/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,9 @@
111111
"pin": "پین کردن",
112112
"unpin": "حذف پین",
113113
"generationInfo": "اطلاعات تولید",
114-
"sidebarChat": "چت کناری"
114+
"sidebarChat": "چت کناری",
115+
"reasoning": {
116+
"thinking": "در حال فکر کردن....",
117+
"thought": "فکر کردن برای {{time}}"
118+
}
115119
}

src/assets/locale/fr/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,9 @@
117117
"pin": "Épingler",
118118
"unpin": "Désépingler",
119119
"generationInfo": "Informations de génération",
120-
"sidebarChat": "Chat latéral"
120+
"sidebarChat": "Chat latéral",
121+
"reasoning": {
122+
"thinking": "Réflexion....",
123+
"thought": "Réflexion pendant {{time}}"
124+
}
121125
}

src/assets/locale/it/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,9 @@
117117
"pin": "Fissa",
118118
"unpin": "Rimuovi",
119119
"generationInfo": "Informazioni sulla Generazione",
120-
"sidebarChat": "Chat Laterale"
120+
"sidebarChat": "Chat Laterale",
121+
"reasoning": {
122+
"thinking": "Pensando....",
123+
"thought": "Pensato per {{time}}"
124+
}
121125
}

src/assets/locale/ja-JP/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,9 @@
117117
"pin": "固定",
118118
"unpin": "固定解除",
119119
"generationInfo": "生成情報",
120-
"sidebarChat": "サイドバーチャット"
120+
"sidebarChat": "サイドバーチャット",
121+
"reasoning": {
122+
"thinking": "考え中....",
123+
"thought": "{{time}}の思考"
124+
}
121125
}

src/assets/locale/ko/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,9 @@
117117
"pin": "고정",
118118
"unpin": "고정 해제",
119119
"generationInfo": "생성 정보",
120-
"sidebarChat": "사이드바 채팅"
120+
"sidebarChat": "사이드바 채팅",
121+
"reasoning": {
122+
"thinking": "생각 중....",
123+
"thought": "{{time}} 동안 생각함"
124+
}
121125
}

src/assets/locale/ml/common.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@
116116
"pin": "പിൻ ചെയ്യുക",
117117
"unpin": "അൺപിൻ ചെയ്യുക",
118118
"generationInfo": "ജനറേഷൻ വിവരങ്ങൾ",
119-
"sidebarChat": "സൈഡ്ബാർ ചാറ്റ്"
120-
119+
"sidebarChat": "സൈഡ്ബാർ ചാറ്റ്",
120+
"reasoning": {
121+
"thinking": "ചിന്തിക്കുന്നു....",
122+
"thought": "{{time}} നേരത്തെ ചിന്ത"
123+
}
121124
}

src/assets/locale/no/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,9 @@
118118
"pin": "Fest",
119119
"unpin": "Løsne",
120120
"generationInfo": "Generasjonsinformasjon",
121-
"sidebarChat": "Sidepanel-chat"
121+
"sidebarChat": "Sidepanel-chat",
122+
"reasoning": {
123+
"thinking": "Tenker....",
124+
"thought": "Tenkte i {{time}}"
125+
}
122126
}

src/assets/locale/pt-BR/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,9 @@
117117
"pin": "Fixar",
118118
"unpin": "Desafixar",
119119
"generationInfo": "Informações de Geração",
120-
"sidebarChat": "Chat Lateral"
120+
"sidebarChat": "Chat Lateral",
121+
"reasoning": {
122+
"thinking": "Pensando....",
123+
"thought": "Pensou por {{time}}"
124+
}
121125
}

src/assets/locale/ru/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,9 @@
117117
"pin": "Закрепить",
118118
"unpin": "Открепить",
119119
"generationInfo": "Информация о генерации",
120-
"sidebarChat": "Боковой чат"
120+
"sidebarChat": "Боковой чат",
121+
"reasoning": {
122+
"thinking": "Размышляю...",
123+
"thought": "Размышлял {{time}}"
124+
}
121125
}

src/assets/locale/sv/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,9 @@
122122
"pin": "Fäst",
123123
"unpin": "Ta bort fäst",
124124
"generationInfo": "Generationsinformation",
125-
"sidebarChat": "Sidofältschatt"
125+
"sidebarChat": "Sidofältschatt",
126+
"reasoning": {
127+
"thinking": "Tänker....",
128+
"thought": "Tänkte i {{time}}"
129+
}
126130
}

src/assets/locale/uk/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,9 @@
122122
"pin": "Прикріпити",
123123
"unpin": "Відкріпити",
124124
"generationInfo": "Інформація про генерацію",
125-
"sidebarChat": "Бічний чат"
125+
"sidebarChat": "Бічний чат",
126+
"reasoning": {
127+
"thinking": "Думаю....",
128+
"thought": "Думав протягом {{time}}"
129+
}
126130
}

src/assets/locale/zh/common.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,9 @@
117117
"pin": "置顶",
118118
"unpin": "取消置顶",
119119
"generationInfo": "生成信息",
120-
"sidebarChat": "侧边栏聊天"
120+
"sidebarChat": "侧边栏聊天",
121+
"reasoning": {
122+
"thinking": "思考中....",
123+
"thought": "思考了 {{time}}"
124+
}
121125
}

src/components/Common/Playground/Message.tsx

+41-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import { useTTS } from "@/hooks/useTTS"
1818
import { tagColors } from "@/utils/color"
1919
import { removeModelSuffix } from "@/db/models"
2020
import { GenerationInfo } from "./GenerationInfo"
21-
21+
import { parseReasoning } from "@/libs/reasoning"
22+
import { humanizeMilliseconds } from "@/utils/humanize-miliseconds"
2223
type Props = {
2324
message: string
2425
message_type?: string
@@ -40,6 +41,8 @@ type Props = {
4041
onSourceClick?: (source: any) => void
4142
isTTSEnabled?: boolean
4243
generationInfo?: any
44+
isStreaming: boolean
45+
reasoningTimeTaken?: number
4346
}
4447

4548
export const PlaygroundMessage = (props: Props) => {
@@ -48,7 +51,6 @@ export const PlaygroundMessage = (props: Props) => {
4851

4952
const { t } = useTranslation("common")
5053
const { cancel, isSpeaking, speak } = useTTS()
51-
5254
return (
5355
<div className="group w-full text-gray-800 dark:text-gray-100">
5456
<div className="text-base md:max-w-2xl lg:max-w-xl xl:max-w-3xl flex lg:px-0 m-auto w-full">
@@ -94,7 +96,40 @@ export const PlaygroundMessage = (props: Props) => {
9496
<div className="flex flex-grow flex-col">
9597
{!editMode ? (
9698
props.isBot ? (
97-
<Markdown message={props.message} />
99+
<>
100+
{parseReasoning(props.message).map((e, i) => {
101+
if (e.type === "reasoning") {
102+
return (
103+
<Collapse
104+
key={i}
105+
className="border-none !mb-3"
106+
items={[
107+
{
108+
key: "reasoning",
109+
label:
110+
props.isStreaming && e?.reasoning_running ? (
111+
<div className="flex items-center gap-2">
112+
<span className="italic">
113+
{t("reasoning.thinking")}
114+
</span>
115+
</div>
116+
) : (
117+
t("reasoning.thought", {
118+
time: humanizeMilliseconds(
119+
props.reasoningTimeTaken
120+
)
121+
})
122+
),
123+
children: <Markdown message={e.content} />
124+
}
125+
]}
126+
/>
127+
)
128+
}
129+
130+
return <Markdown key={i} message={e.content} />
131+
})}
132+
</>
98133
) : (
99134
<p
100135
className={`prose dark:prose-invert whitespace-pre-line prose-p:leading-relaxed prose-pre:p-0 dark:prose-dark ${
@@ -220,8 +255,8 @@ export const PlaygroundMessage = (props: Props) => {
220255
}
221256
title={t("generationInfo")}>
222257
<button
223-
aria-label={t("generationInfo")}
224-
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
258+
aria-label={t("generationInfo")}
259+
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
225260
<InfoIcon className="w-3 h-3 text-gray-400 group-hover:text-gray-500" />
226261
</button>
227262
</Popover>
@@ -231,7 +266,7 @@ export const PlaygroundMessage = (props: Props) => {
231266
props.currentMessageIndex === props.totalMessages - 1 && (
232267
<Tooltip title={t("regenerate")}>
233268
<button
234-
aria-label={t("regenerate")}
269+
aria-label={t("regenerate")}
235270
onClick={props.onRengerate}
236271
className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
237272
<RotateCcw className="w-3 h-3 text-gray-400 group-hover:text-gray-500" />

src/components/Common/Settings/AdvanceOllamaSettings.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,25 @@ import { SaveButton } from "../SaveButton"
1616
export const AdvanceOllamaSettings = () => {
1717
const [form] = Form.useForm()
1818
const watchUrlRewriteEnabled = Form.useWatch("urlRewriteEnabled", form)
19+
const { t } = useTranslation("settings")
1920

2021
const fetchAdvancedData = async () => {
22+
try {
2123
const [urlRewriteEnabled, rewriteUrl, headers] = await Promise.all([
2224
isUrlRewriteEnabled(),
2325
getRewriteUrl(),
2426
customOllamaHeaders()
2527
])
2628
form.setFieldsValue({ urlRewriteEnabled, rewriteUrl, headers })
29+
} catch (e) {
30+
console.error(e)
31+
}
2732
}
2833

2934
React.useEffect(() => {
3035
fetchAdvancedData()
3136
}, [])
3237

33-
const { t } = useTranslation("settings")
3438

3539
return (
3640
<Form

src/components/Layouts/Header.tsx

+19-8
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,30 @@ export const Header: React.FC<Props> = ({
120120
{"/"}
121121
</span>
122122
<div className="hidden lg:block">
123-
<PageAssistSelect
123+
<Select
124124
className="w-80"
125125
placeholder={t("common:selectAModel")}
126-
loadingText={t("common:selectAModel")}
126+
// loadingText={t("common:selectAModel")}
127127
value={selectedModel}
128128
onChange={(e) => {
129-
setSelectedModel(e.value)
130-
localStorage.setItem("selectedModel", e.value)
129+
setSelectedModel(e)
130+
localStorage.setItem("selectedModel", e)
131+
}}
132+
filterOption={(input, option) => {
133+
//@ts-ignore
134+
return (
135+
option?.label?.props["data-title"]
136+
?.toLowerCase()
137+
?.indexOf(input.toLowerCase()) >= 0
138+
)
131139
}}
132-
isLoading={isModelsLoading}
140+
showSearch
141+
loading={isModelsLoading}
133142
options={models?.map((model) => ({
134143
label: (
135144
<span
136145
key={model.model}
146+
data-title={model.name}
137147
className="flex flex-row gap-3 items-center ">
138148
<ProviderIcons
139149
provider={model?.provider}
@@ -144,9 +154,10 @@ export const Header: React.FC<Props> = ({
144154
),
145155
value: model.model
146156
}))}
147-
onRefresh={() => {
148-
refetch()
149-
}}
157+
size="large"
158+
// onRefresh={() => {
159+
// refetch()
160+
// }}
150161
/>
151162
</div>
152163
<div className="lg:hidden">

src/components/Layouts/MoreOptions.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ const generateChatImage = async (messages: Message[]) => {
122122
})
123123

124124
canvas.height = totalHeight
125-
console.log(totalHeight)
126125

127126
ctx.fillStyle = "#ffffff"
128127
ctx.fillRect(0, 0, canvas.width, canvas.height)

0 commit comments

Comments
 (0)