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
133 changes: 133 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"react-router-dom": "^6.28.1",
"react-syntax-highlighter": "^15.6.1",
"rehype-katex": "^7.0.1",
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0",
"semver": "^7.7.1",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"edit": "Edit",
"editDescription": "Editing this message will regenerate a new response",
"cancel": "Cancel",
"save": "Save"
"save": "Save",
"toolCalls": "🛠 Tool Calls Result from {{name}}"
},
"welcome": {
"title": "Welcome to Dive AI",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"edit": "编辑",
"editDescription": "编辑此消息将重新生成一个新回复",
"cancel": "取消",
"save": "保存"
"save": "保存",
"toolCalls": "🛠 请求 {{name}} 工具结果"
},
"welcome": {
"title": "欢迎使用 Dive AI",
Expand Down
3 changes: 2 additions & 1 deletion public/locales/zh-TW/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"edit": "編輯",
"editDescription": "編輯此訊息將會重新生成一個新的回應",
"cancel": "取消",
"save": "儲存"
"save": "儲存",
"toolCalls": "🛠 呼叫 {{name}} 工具結果"
},
"welcome": {
"title": "歡迎使用 Dive AI",
Expand Down
15 changes: 5 additions & 10 deletions src/styles/overlay/_Tools.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,12 @@
margin: 10px 0;
border-radius: 8px;
overflow: hidden;
background: var(--bg-op-dark-extremeweak);

summary {
padding: 10px 15px;
cursor: pointer;
user-select: none;
font-weight: 500;

&:hover {
background: var(--bg-op-dark-extremeweak);
}
color: var(--text-inverted-weak);
}

.tool-content {
Expand Down Expand Up @@ -191,11 +186,11 @@
.verify-btn {
background: var(--bg-success);
color: var(--text-light);

&:hover:not(:disabled) {
background: var(--bg-hover-success);
}

&:active:not(:disabled) {
background: var(--bg-active-success);
}
Expand All @@ -204,11 +199,11 @@
.submit-btn {
background: var(--bg-pri-blue);
color: var(--text-light);

&:hover:not(:disabled) {
background: var(--bg-hover-blue);
}

&:active:not(:disabled) {
background: var(--bg-active-blue);
}
Expand Down
40 changes: 30 additions & 10 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,34 @@ import { ModelConfig } from "./atoms/configState"


export const getModelPrefix = (config: ModelConfig, length: number = 5) => {
if(config.apiKey) return config.apiKey.slice(-length)
try {
if(config.baseURL) {
const url = new URL(config.baseURL)
return url.hostname.slice(0, length)
}
} catch (error) {
return config.baseURL
}
return ""
if(config.apiKey) return config.apiKey.slice(-length)
try {
if(config.baseURL) {
const url = new URL(config.baseURL)
return url.hostname.slice(0, length)
}
} catch (error) {
return config.baseURL
}
return ""
}

export function safeBase64Encode(str: string): string {
try {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g,
(_, p1) => String.fromCharCode(parseInt(p1, 16))))
} catch (e) {
console.error("Encoding error:", e)
return ""
}
}

export function safeBase64Decode(str: string): string {
try {
return decodeURIComponent(Array.prototype.map.call(atob(str),
c => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join(""))
} catch (e) {
console.error("Decoding error:", e)
return str
}
}
5 changes: 0 additions & 5 deletions src/views/Chat/ChatMessages.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useEffect, useRef } from "react"
import Message from "./Message"
import { ToolCall, ToolResult } from "./ToolPanel"
import { isChatStreamingAtom } from "../../atoms/chatState"
import { useAtomValue } from "jotai"

Expand All @@ -11,8 +10,6 @@ export interface Message {
timestamp: number
files?: File[]
isError?: boolean
toolCalls?: ToolCall[]
toolResults?: ToolResult[]
}

interface Props {
Expand Down Expand Up @@ -69,8 +66,6 @@ const ChatMessages = ({ messages, isLoading, onRetry, onEdit }: Props) => {
files={message.files}
isError={message.isError}
isLoading={!message.isSent && index === messages.length - 1 && isLoading}
toolCalls={message.toolCalls}
toolResults={message.toolResults}
messageId={message.id}
onRetry={() => onRetry(message.id)}
onEdit={(newText: string) => onEdit(message.id, newText)}
Expand Down
Loading