Merge pull request #6756 from menloresearch/sync/release-7-1-into-dev
Sync release 0.7.1 to dev
This commit is contained in:
commit
e7fcc809e7
@ -49,6 +49,8 @@ jobs:
|
||||
# Update tauri.conf.json
|
||||
jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = false' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
|
||||
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
|
||||
jq '.bundle.windows.nsis.template = "tauri.bundle.windows.nsis.template"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
|
||||
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
|
||||
jq '.bundle.windows.signCommand = "echo External build - skipping signature: %1"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
|
||||
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
|
||||
jq --arg version "${{ inputs.new_version }}" '.version = $version' web-app/package.json > /tmp/package.json
|
||||
@ -80,6 +82,36 @@ jobs:
|
||||
echo "---------./src-tauri/Cargo.toml---------"
|
||||
cat ./src-tauri/Cargo.toml
|
||||
|
||||
generate_build_version() {
|
||||
### Examble
|
||||
### input 0.5.6 output will be 0.5.6 and 0.5.6.0
|
||||
### input 0.5.6-rc2-beta output will be 0.5.6 and 0.5.6.2
|
||||
### input 0.5.6-1213 output will be 0.5.6 and and 0.5.6.1213
|
||||
local new_version="$1"
|
||||
local base_version
|
||||
local t_value
|
||||
# Check if it has a "-"
|
||||
if [[ "$new_version" == *-* ]]; then
|
||||
base_version="${new_version%%-*}" # part before -
|
||||
suffix="${new_version#*-}" # part after -
|
||||
# Check if it is rcX-beta
|
||||
if [[ "$suffix" =~ ^rc([0-9]+)-beta$ ]]; then
|
||||
t_value="${BASH_REMATCH[1]}"
|
||||
else
|
||||
t_value="$suffix"
|
||||
fi
|
||||
else
|
||||
base_version="$new_version"
|
||||
t_value="0"
|
||||
fi
|
||||
# Export two values
|
||||
new_base_version="$base_version"
|
||||
new_build_version="${base_version}.${t_value}"
|
||||
}
|
||||
generate_build_version ${{ inputs.new_version }}
|
||||
sed -i "s/jan_version/$new_base_version/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
sed -i "s/jan_build/$new_build_version/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
|
||||
if [ "${{ inputs.channel }}" != "stable" ]; then
|
||||
jq '.plugins.updater.endpoints = ["https://delta.jan.ai/${{ inputs.channel }}/latest.json"]' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
|
||||
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
|
||||
@ -103,7 +135,14 @@ jobs:
|
||||
chmod +x .github/scripts/rename-workspace.sh
|
||||
.github/scripts/rename-workspace.sh ./package.json ${{ inputs.channel }}
|
||||
cat ./package.json
|
||||
sed -i "s/jan_productname/Jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
sed -i "s/jan_mainbinaryname/jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
else
|
||||
sed -i "s/jan_productname/Jan/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
sed -i "s/jan_mainbinaryname/jan/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
fi
|
||||
echo "---------nsis.template---------"
|
||||
cat ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
- name: Build app
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
@ -98,9 +98,15 @@ jobs:
|
||||
# Update tauri.conf.json
|
||||
jq --arg version "${{ inputs.new_version }}" '.version = $version | .bundle.createUpdaterArtifacts = true' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
|
||||
mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
|
||||
jq '.bundle.windows.nsis.template = "tauri.bundle.windows.nsis.template"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
|
||||
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
|
||||
jq --arg version "${{ inputs.new_version }}" '.version = $version' web-app/package.json > /tmp/package.json
|
||||
mv /tmp/package.json web-app/package.json
|
||||
|
||||
# Add sign commands to tauri.windows.conf.json
|
||||
jq '.bundle.windows.signCommand = "powershell -ExecutionPolicy Bypass -File ./sign.ps1 %1"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
|
||||
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
|
||||
|
||||
# Update tauri plugin versions
|
||||
|
||||
jq --arg version "${{ inputs.new_version }}" '.version = $version' ./src-tauri/plugins/tauri-plugin-hardware/package.json > /tmp/package.json
|
||||
@ -127,9 +133,35 @@ jobs:
|
||||
echo "---------./src-tauri/Cargo.toml---------"
|
||||
cat ./src-tauri/Cargo.toml
|
||||
|
||||
# Add sign commands to tauri.windows.conf.json
|
||||
jq '.bundle.windows.signCommand = "powershell -ExecutionPolicy Bypass -File ./sign.ps1 %1"' ./src-tauri/tauri.windows.conf.json > /tmp/tauri.windows.conf.json
|
||||
mv /tmp/tauri.windows.conf.json ./src-tauri/tauri.windows.conf.json
|
||||
generate_build_version() {
|
||||
### Example
|
||||
### input 0.5.6 output will be 0.5.6 and 0.5.6.0
|
||||
### input 0.5.6-rc2-beta output will be 0.5.6 and 0.5.6.2
|
||||
### input 0.5.6-1213 output will be 0.5.6 and and 0.5.6.1213
|
||||
local new_version="$1"
|
||||
local base_version
|
||||
local t_value
|
||||
# Check if it has a "-"
|
||||
if [[ "$new_version" == *-* ]]; then
|
||||
base_version="${new_version%%-*}" # part before -
|
||||
suffix="${new_version#*-}" # part after -
|
||||
# Check if it is rcX-beta
|
||||
if [[ "$suffix" =~ ^rc([0-9]+)-beta$ ]]; then
|
||||
t_value="${BASH_REMATCH[1]}"
|
||||
else
|
||||
t_value="$suffix"
|
||||
fi
|
||||
else
|
||||
base_version="$new_version"
|
||||
t_value="0"
|
||||
fi
|
||||
# Export two values
|
||||
new_base_version="$base_version"
|
||||
new_build_version="${base_version}.${t_value}"
|
||||
}
|
||||
generate_build_version ${{ inputs.new_version }}
|
||||
sed -i "s/jan_version/$new_base_version/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
sed -i "s/jan_build/$new_build_version/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
|
||||
echo "---------tauri.windows.conf.json---------"
|
||||
cat ./src-tauri/tauri.windows.conf.json
|
||||
@ -163,7 +195,14 @@ jobs:
|
||||
chmod +x .github/scripts/rename-workspace.sh
|
||||
.github/scripts/rename-workspace.sh ./package.json ${{ inputs.channel }}
|
||||
cat ./package.json
|
||||
sed -i "s/jan_productname/Jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
sed -i "s/jan_mainbinaryname/jan-${{ inputs.channel }}/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
else
|
||||
sed -i "s/jan_productname/Jan/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
sed -i "s/jan_mainbinaryname/jan/g" ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
fi
|
||||
echo "---------nsis.template---------"
|
||||
cat ./src-tauri/tauri.bundle.windows.nsis.template
|
||||
|
||||
- name: Install AzureSignTool
|
||||
run: |
|
||||
|
||||
1
Makefile
1
Makefile
@ -117,7 +117,6 @@ lint: install-and-build
|
||||
test: lint
|
||||
yarn download:bin
|
||||
ifeq ($(OS),Windows_NT)
|
||||
yarn download:windows-installer
|
||||
endif
|
||||
yarn test
|
||||
yarn copy:assets:tauri
|
||||
|
||||
@ -332,12 +332,14 @@ export default class llamacpp_extension extends AIEngine {
|
||||
)
|
||||
// Clear the invalid stored preference
|
||||
this.clearStoredBackendType()
|
||||
bestAvailableBackendString =
|
||||
await this.determineBestBackend(version_backends)
|
||||
bestAvailableBackendString = await this.determineBestBackend(
|
||||
version_backends
|
||||
)
|
||||
}
|
||||
} else {
|
||||
bestAvailableBackendString =
|
||||
await this.determineBestBackend(version_backends)
|
||||
bestAvailableBackendString = await this.determineBestBackend(
|
||||
version_backends
|
||||
)
|
||||
}
|
||||
|
||||
let settings = structuredClone(SETTINGS)
|
||||
@ -2151,7 +2153,12 @@ export default class llamacpp_extension extends AIEngine {
|
||||
if (mmprojPath && !this.isAbsolutePath(mmprojPath))
|
||||
mmprojPath = await joinPath([await getJanDataFolderPath(), path])
|
||||
try {
|
||||
const result = await planModelLoadInternal(path, this.memoryMode, mmprojPath, requestedCtx)
|
||||
const result = await planModelLoadInternal(
|
||||
path,
|
||||
this.memoryMode,
|
||||
mmprojPath,
|
||||
requestedCtx
|
||||
)
|
||||
return result
|
||||
} catch (e) {
|
||||
throw new Error(String(e))
|
||||
@ -2279,12 +2286,18 @@ export default class llamacpp_extension extends AIEngine {
|
||||
}
|
||||
|
||||
// Calculate text tokens
|
||||
const messages = JSON.stringify({ messages: opts.messages })
|
||||
// Use chat_template_kwargs from opts if provided, otherwise default to disable enable_thinking
|
||||
const tokenizeRequest = {
|
||||
messages: opts.messages,
|
||||
chat_template_kwargs: opts.chat_template_kwargs || {
|
||||
enable_thinking: false,
|
||||
},
|
||||
}
|
||||
|
||||
let parseResponse = await fetch(`${baseUrl}/apply-template`, {
|
||||
method: 'POST',
|
||||
headers: headers,
|
||||
body: messages,
|
||||
body: JSON.stringify(tokenizeRequest),
|
||||
})
|
||||
|
||||
if (!parseResponse.ok) {
|
||||
|
||||
@ -35,8 +35,7 @@
|
||||
"copy:assets:mobile": "cpx \"pre-install/*.tgz\" \"src-tauri/resources/pre-install/\" && cpx \"LICENSE\" \"src-tauri/resources/\"",
|
||||
"download:lib": "node ./scripts/download-lib.mjs",
|
||||
"download:bin": "node ./scripts/download-bin.mjs",
|
||||
"download:windows-installer": "node ./scripts/download-win-installer-deps.mjs",
|
||||
"build:tauri:win32": "yarn download:bin && yarn download:windows-installer && yarn tauri build",
|
||||
"build:tauri:win32": "yarn download:bin && yarn tauri build",
|
||||
"build:tauri:linux": "yarn download:bin && NO_STRIP=1 ./src-tauri/build-utils/shim-linuxdeploy.sh yarn tauri build && ./src-tauri/build-utils/buildAppImage.sh",
|
||||
"build:tauri:darwin": "yarn download:bin && yarn tauri build --target universal-apple-darwin",
|
||||
"build:tauri": "yarn build:icon && yarn copy:assets:tauri && run-script-os",
|
||||
|
||||
@ -1,83 +0,0 @@
|
||||
console.log('Downloading Windows installer dependencies...')
|
||||
// scripts/download-win-installer-deps.mjs
|
||||
import https from 'https'
|
||||
import fs, { mkdirSync } from 'fs'
|
||||
import os from 'os'
|
||||
import path from 'path'
|
||||
import { copySync } from 'cpx'
|
||||
|
||||
function download(url, dest) {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(`Downloading ${url} to ${dest}`)
|
||||
const file = fs.createWriteStream(dest)
|
||||
https
|
||||
.get(url, (response) => {
|
||||
console.log(`Response status code: ${response.statusCode}`)
|
||||
if (
|
||||
response.statusCode >= 300 &&
|
||||
response.statusCode < 400 &&
|
||||
response.headers.location
|
||||
) {
|
||||
// Handle redirect
|
||||
const redirectURL = response.headers.location
|
||||
console.log(`Redirecting to ${redirectURL}`)
|
||||
download(redirectURL, dest).then(resolve, reject) // Recursive call
|
||||
return
|
||||
} else if (response.statusCode !== 200) {
|
||||
reject(`Failed to get '${url}' (${response.statusCode})`)
|
||||
return
|
||||
}
|
||||
response.pipe(file)
|
||||
file.on('finish', () => {
|
||||
file.close(resolve)
|
||||
})
|
||||
})
|
||||
.on('error', (err) => {
|
||||
fs.unlink(dest, () => reject(err.message))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log('Starting Windows installer dependencies download')
|
||||
const platform = os.platform() // 'darwin', 'linux', 'win32'
|
||||
const arch = os.arch() // 'x64', 'arm64', etc.
|
||||
|
||||
if (arch != 'x64') return
|
||||
|
||||
|
||||
const libDir = 'src-tauri/resources/lib'
|
||||
const tempDir = 'scripts/dist'
|
||||
|
||||
try {
|
||||
mkdirSync('scripts/dist')
|
||||
} catch (err) {
|
||||
// Expect EEXIST error if the directory already exists
|
||||
}
|
||||
|
||||
// Download VC++ Redistributable 17
|
||||
if (platform == 'win32') {
|
||||
const vcFilename = 'vc_redist.x64.exe'
|
||||
const vcUrl = 'https://aka.ms/vs/17/release/vc_redist.x64.exe'
|
||||
|
||||
console.log(`Downloading VC++ Redistributable...`)
|
||||
const vcSavePath = path.join(tempDir, vcFilename)
|
||||
if (!fs.existsSync(vcSavePath)) {
|
||||
await download(vcUrl, vcSavePath)
|
||||
}
|
||||
|
||||
// copy to tauri resources
|
||||
try {
|
||||
copySync(vcSavePath, libDir)
|
||||
} catch (err) {
|
||||
// Expect EEXIST error
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Windows installer dependencies downloads completed.')
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error('Error:', err)
|
||||
process.exit(1)
|
||||
})
|
||||
1006
src-tauri/tauri.bundle.windows.nsis.template
Normal file
1006
src-tauri/tauri.bundle.windows.nsis.template
Normal file
File diff suppressed because it is too large
Load Diff
@ -11,18 +11,13 @@
|
||||
},
|
||||
|
||||
"bundle": {
|
||||
"targets": ["nsis"],
|
||||
"targets": ["nsis", "msi"],
|
||||
"resources": [
|
||||
"resources/pre-install/**/*",
|
||||
"resources/lib/vc_redist.x64.exe",
|
||||
"resources/LICENSE"
|
||||
],
|
||||
"externalBin": ["resources/bin/bun", "resources/bin/uv"],
|
||||
"windows": {
|
||||
"nsis": {
|
||||
"installerHooks": "./windows/hooks.nsh",
|
||||
"installerIcon": "icons/icon.ico"
|
||||
},
|
||||
"webviewInstallMode": {
|
||||
"silent": true,
|
||||
"type": "downloadBootstrapper"
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
!macro NSIS_HOOK_POSTINSTALL
|
||||
; Check if Visual C++ Redistributable is already installed
|
||||
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Version"
|
||||
${If} $0 == ""
|
||||
; Try alternative registry location
|
||||
ReadRegStr $0 HKLM "SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Version"
|
||||
${EndIf}
|
||||
|
||||
${If} $0 == ""
|
||||
; VC++ Redistributable not found, need to install
|
||||
DetailPrint "Visual C++ Redistributable not found, installing from bundled file..."
|
||||
|
||||
; Install from bundled EXE if not installed
|
||||
${If} ${FileExists} "$INSTDIR\resources\lib\vc_redist.x64.exe"
|
||||
DetailPrint "Installing Visual C++ Redistributable..."
|
||||
; Copy to TEMP folder and then execute installer
|
||||
CopyFiles "$INSTDIR\resources\lib\vc_redist.x64.exe" "$TEMP\vc_redist.x64.exe"
|
||||
ExecWait '"$TEMP\vc_redist.x64.exe" /quiet /norestart' $1
|
||||
|
||||
; Check whether installation process exited successfully (code 0) or not
|
||||
${If} $1 == 0
|
||||
DetailPrint "Visual C++ Redistributable installed successfully"
|
||||
${ElseIf} $1 == 1638
|
||||
DetailPrint "Visual C++ Redistributable already installed (newer version)"
|
||||
${ElseIf} $1 == 3010
|
||||
DetailPrint "Visual C++ Redistributable installed successfully (restart required)"
|
||||
${Else}
|
||||
DetailPrint "Visual C++ installation failed with exit code: $1"
|
||||
${EndIf}
|
||||
|
||||
; Clean up setup files from TEMP and your installed app
|
||||
Delete "$TEMP\vc_redist.x64.exe"
|
||||
Delete "$INSTDIR\resources\lib\vc_redist.x64.exe"
|
||||
${Else}
|
||||
DetailPrint "Visual C++ Redistributable not found at expected location: $INSTDIR\resources\lib\vc_redist.x64.exe"
|
||||
${EndIf}
|
||||
${Else}
|
||||
DetailPrint "Visual C++ Redistributable already installed (version: $0)"
|
||||
${EndIf}
|
||||
|
||||
; ---- Copy LICENSE to install root ----
|
||||
${If} ${FileExists} "$INSTDIR\resources\LICENSE"
|
||||
CopyFiles /SILENT "$INSTDIR\resources\LICENSE" "$INSTDIR\LICENSE"
|
||||
DetailPrint "Copied LICENSE to install root"
|
||||
|
||||
; Optional cleanup - remove from resources folder
|
||||
Delete "$INSTDIR\resources\LICENSE"
|
||||
${Else}
|
||||
DetailPrint "LICENSE not found at expected location: $INSTDIR\resources\LICENSE"
|
||||
${EndIf}
|
||||
|
||||
; ---- Copy vulkan-1.dll to install root ----
|
||||
${If} ${FileExists} "$INSTDIR\resources\lib\vulkan-1.dll"
|
||||
CopyFiles /SILENT "$INSTDIR\resources\lib\vulkan-1.dll" "$INSTDIR\vulkan-1.dll"
|
||||
DetailPrint "Copied vulkan-1.dll to install root"
|
||||
|
||||
; Optional cleanup - remove from resources folder
|
||||
Delete "$INSTDIR\resources\lib\vulkan-1.dll"
|
||||
|
||||
; Only remove the lib directory if it's empty after removing both files
|
||||
RMDir "$INSTDIR\resources\lib"
|
||||
${Else}
|
||||
DetailPrint "vulkan-1.dll not found at expected location: $INSTDIR\resources\lib\vulkan-1.dll"
|
||||
${EndIf}
|
||||
!macroend
|
||||
@ -82,7 +82,7 @@
|
||||
"remark-math": "6.0.0",
|
||||
"sonner": "2.0.5",
|
||||
"tailwindcss": "4.1.4",
|
||||
"token.js": "npm:token.js-fork@0.7.27",
|
||||
"token.js": "npm:token.js-fork@0.7.29",
|
||||
"tw-animate-css": "1.2.8",
|
||||
"ulidx": "2.4.1",
|
||||
"unified": "11.0.5",
|
||||
|
||||
@ -96,7 +96,7 @@ export const predefinedProviders = [
|
||||
{
|
||||
active: true,
|
||||
api_key: '',
|
||||
base_url: 'https://api.anthropic.com',
|
||||
base_url: 'https://api.anthropic.com/v1',
|
||||
provider: 'anthropic',
|
||||
explore_models_url:
|
||||
'https://docs.anthropic.com/en/docs/about-claude/models',
|
||||
@ -127,11 +127,21 @@ export const predefinedProviders = [
|
||||
},
|
||||
],
|
||||
models: [],
|
||||
custom_header: [
|
||||
{
|
||||
header: 'anthropic-version',
|
||||
value: '2023-06-01'
|
||||
},
|
||||
{
|
||||
header: 'anthropic-dangerous-direct-browser-access',
|
||||
value: 'true'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
active: true,
|
||||
api_key: '',
|
||||
base_url: 'https://api.cohere.ai/compatibility/v1',
|
||||
base_url: 'https://api.cohere.ai/v1',
|
||||
explore_models_url: 'https://docs.cohere.com/v2/docs/models',
|
||||
provider: 'cohere',
|
||||
settings: [
|
||||
|
||||
@ -132,7 +132,10 @@ const ChatInput = ({
|
||||
const activeModels = await serviceHub
|
||||
.models()
|
||||
.getActiveModels('llamacpp')
|
||||
setHasActiveModels(activeModels.length > 0)
|
||||
const hasMatchingActiveModel = activeModels.some(
|
||||
(model) => String(model) === selectedModel?.id
|
||||
)
|
||||
setHasActiveModels(activeModels.length > 0 && hasMatchingActiveModel)
|
||||
} catch (error) {
|
||||
console.error('Failed to get active models:', error)
|
||||
setHasActiveModels(false)
|
||||
@ -145,7 +148,7 @@ const ChatInput = ({
|
||||
const intervalId = setInterval(checkActiveModels, 3000)
|
||||
|
||||
return () => clearInterval(intervalId)
|
||||
}, [serviceHub])
|
||||
}, [serviceHub, selectedModel?.id])
|
||||
|
||||
// Check for mmproj existence or vision capability when model changes
|
||||
useEffect(() => {
|
||||
|
||||
@ -320,9 +320,82 @@ export const useModelProvider = create<ModelProviderState>()(
|
||||
})
|
||||
}
|
||||
|
||||
if (version <= 3 && state?.providers) {
|
||||
state.providers.forEach((provider) => {
|
||||
// Migrate Anthropic provider base URL and add custom headers
|
||||
if (provider.provider === 'anthropic') {
|
||||
if (provider.base_url === 'https://api.anthropic.com') {
|
||||
provider.base_url = 'https://api.anthropic.com/v1'
|
||||
}
|
||||
|
||||
// Update base-url in settings
|
||||
if (provider.settings) {
|
||||
const baseUrlSetting = provider.settings.find(
|
||||
(s) => s.key === 'base-url'
|
||||
)
|
||||
if (
|
||||
baseUrlSetting?.controller_props?.value ===
|
||||
'https://api.anthropic.com'
|
||||
) {
|
||||
baseUrlSetting.controller_props.value =
|
||||
'https://api.anthropic.com/v1'
|
||||
}
|
||||
if (
|
||||
baseUrlSetting?.controller_props?.placeholder ===
|
||||
'https://api.anthropic.com'
|
||||
) {
|
||||
baseUrlSetting.controller_props.placeholder =
|
||||
'https://api.anthropic.com/v1'
|
||||
}
|
||||
}
|
||||
|
||||
if (!provider.custom_header) {
|
||||
provider.custom_header = [
|
||||
{
|
||||
header: 'anthropic-version',
|
||||
value: '2023-06-01',
|
||||
},
|
||||
{
|
||||
header: 'anthropic-dangerous-direct-browser-access',
|
||||
value: 'true',
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (provider.provider === 'cohere') {
|
||||
if (provider.base_url === 'https://api.cohere.ai/compatibility/v1') {
|
||||
provider.base_url = 'https://api.cohere.ai/v1'
|
||||
}
|
||||
|
||||
// Update base-url in settings
|
||||
if (provider.settings) {
|
||||
const baseUrlSetting = provider.settings.find(
|
||||
(s) => s.key === 'base-url'
|
||||
)
|
||||
if (
|
||||
baseUrlSetting?.controller_props?.value ===
|
||||
'https://api.cohere.ai/compatibility/v1'
|
||||
) {
|
||||
baseUrlSetting.controller_props.value =
|
||||
'https://api.cohere.ai/v1'
|
||||
}
|
||||
if (
|
||||
baseUrlSetting?.controller_props?.placeholder ===
|
||||
'https://api.cohere.ai/compatibility/v1'
|
||||
) {
|
||||
baseUrlSetting.controller_props.placeholder =
|
||||
'https://api.cohere.ai/v1'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
return state
|
||||
},
|
||||
version: 3,
|
||||
version: 4,
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
@ -39,7 +39,7 @@ function ModelProviders() {
|
||||
toast.error(t('providerAlreadyExists', { name }))
|
||||
return
|
||||
}
|
||||
const newProvider = {
|
||||
const newProvider: ProviderObject = {
|
||||
provider: name,
|
||||
active: true,
|
||||
models: [],
|
||||
|
||||
@ -578,6 +578,9 @@ export class DefaultModelsService implements ModelsService {
|
||||
}
|
||||
}>
|
||||
}>
|
||||
chat_template_kwargs?: {
|
||||
enable_thinking: boolean
|
||||
}
|
||||
}) => Promise<number>
|
||||
}
|
||||
|
||||
@ -654,6 +657,9 @@ export class DefaultModelsService implements ModelsService {
|
||||
return await engine.getTokensCount({
|
||||
model: modelId,
|
||||
messages: transformedMessages,
|
||||
chat_template_kwargs: {
|
||||
enable_thinking: false,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -151,6 +151,12 @@ export class TauriProvidersService extends DefaultProvidersService {
|
||||
headers['Authorization'] = `Bearer ${provider.api_key}`
|
||||
}
|
||||
|
||||
if (provider.custom_header) {
|
||||
provider.custom_header.forEach((header) => {
|
||||
headers[header.header] = header.value
|
||||
})
|
||||
}
|
||||
|
||||
// Always use Tauri's fetch to avoid CORS issues
|
||||
const response = await fetchTauri(`${provider.base_url}/models`, {
|
||||
method: 'GET',
|
||||
|
||||
6
web-app/src/types/modelProviders.d.ts
vendored
6
web-app/src/types/modelProviders.d.ts
vendored
@ -48,6 +48,7 @@ type ProviderObject = {
|
||||
settings: ProviderSetting[]
|
||||
models: Model[]
|
||||
persist?: boolean
|
||||
custom_header?: ProviderCustomHeader[] | null
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,3 +72,8 @@ type ProxyOptions = {
|
||||
verifyHostSSL: boolean
|
||||
noProxy: string
|
||||
}
|
||||
|
||||
type ProviderCustomHeader = {
|
||||
header: string
|
||||
value: string
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user