Merge branch 'dev' into fix/cjk-input-issue
This commit is contained in:
commit
3272c30b20
53
.github/workflows/publish-npm-core.yml
vendored
Normal file
53
.github/workflows/publish-npm-core.yml
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
name: Publish plugin models Package to npmjs
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ["v[0-9]+.[0-9]+.[0-9]+-core"]
|
||||||
|
paths: ["core/**"]
|
||||||
|
pull_request:
|
||||||
|
paths: ["core/**"]
|
||||||
|
jobs:
|
||||||
|
build-and-publish-plugins:
|
||||||
|
environment: production
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: "0"
|
||||||
|
token: ${{ secrets.PAT_SERVICE_ACCOUNT }}
|
||||||
|
|
||||||
|
- name: Install jq
|
||||||
|
uses: dcarbone/install-jq-action@v2.0.1
|
||||||
|
|
||||||
|
- name: Extract tag name without v prefix
|
||||||
|
id: get_version
|
||||||
|
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV && echo "::set-output name=version::${GITHUB_REF#refs/tags/v}"
|
||||||
|
env:
|
||||||
|
GITHUB_REF: ${{ github.ref }}
|
||||||
|
|
||||||
|
- name: "Get Semantic Version from tag"
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
run: |
|
||||||
|
# Get the tag from the event
|
||||||
|
tag=${GITHUB_REF#refs/tags/v}
|
||||||
|
# remove the -core suffix
|
||||||
|
new_version=$(echo $tag | sed -n 's/-core//p')
|
||||||
|
echo $new_version
|
||||||
|
# Replace the old version with the new version in package.json
|
||||||
|
jq --arg version "$new_version" '.version = $version' core/package.json > /tmp/package.json && mv /tmp/package.json core/package.json
|
||||||
|
|
||||||
|
# Print the new version
|
||||||
|
echo "Updated package.json version to: $new_version"
|
||||||
|
cat core/package.json
|
||||||
|
|
||||||
|
# Setup .npmrc file to publish to npm
|
||||||
|
- uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: "20.x"
|
||||||
|
registry-url: "https://registry.npmjs.org"
|
||||||
|
|
||||||
|
- run: cd core && yarn install && yarn build
|
||||||
|
|
||||||
|
- run: cd core && yarn publish --access public
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
env:
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
@ -61,37 +61,6 @@
|
|||||||
},
|
},
|
||||||
"engine": "groq"
|
"engine": "groq"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"sources": [
|
|
||||||
{
|
|
||||||
"url": "https://groq.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"id": "llama-3.1-70b-versatile",
|
|
||||||
"object": "model",
|
|
||||||
"name": "Groq Llama 3.1 70b Versatile",
|
|
||||||
"version": "1.1",
|
|
||||||
"description": "Groq Llama 3.1 70b Versatile with supercharged speed!",
|
|
||||||
"format": "api",
|
|
||||||
"settings": {},
|
|
||||||
"parameters": {
|
|
||||||
"max_tokens": 8000,
|
|
||||||
"temperature": 0.7,
|
|
||||||
"top_p": 0.95,
|
|
||||||
"stream": true,
|
|
||||||
"stop": [],
|
|
||||||
"frequency_penalty": 0,
|
|
||||||
"presence_penalty": 0
|
|
||||||
},
|
|
||||||
"metadata": {
|
|
||||||
"author": "Meta",
|
|
||||||
"tags": [
|
|
||||||
"General",
|
|
||||||
"Big Context Length"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"engine": "groq"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"sources": [
|
"sources": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -99,10 +99,10 @@
|
|||||||
"format": "api",
|
"format": "api",
|
||||||
"settings": {},
|
"settings": {},
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
"max_tokens": 32768,
|
||||||
"temperature": 1,
|
"temperature": 1,
|
||||||
"top_p": 1,
|
"top_p": 1,
|
||||||
"stream": true,
|
"stream": true,
|
||||||
"max_tokens": 32768,
|
|
||||||
"frequency_penalty": 0,
|
"frequency_penalty": 0,
|
||||||
"presence_penalty": 0
|
"presence_penalty": 0
|
||||||
},
|
},
|
||||||
@ -126,9 +126,9 @@
|
|||||||
"format": "api",
|
"format": "api",
|
||||||
"settings": {},
|
"settings": {},
|
||||||
"parameters": {
|
"parameters": {
|
||||||
|
"max_tokens": 65536,
|
||||||
"temperature": 1,
|
"temperature": 1,
|
||||||
"top_p": 1,
|
"top_p": 1,
|
||||||
"max_tokens": 65536,
|
|
||||||
"stream": true,
|
"stream": true,
|
||||||
"frequency_penalty": 0,
|
"frequency_penalty": 0,
|
||||||
"presence_penalty": 0
|
"presence_penalty": 0
|
||||||
|
|||||||
@ -192,8 +192,12 @@ const ModelDropdown = ({
|
|||||||
model?.settings.ctx_len ?? 8192
|
model?.settings.ctx_len ?? 8192
|
||||||
)
|
)
|
||||||
const overriddenParameters = {
|
const overriddenParameters = {
|
||||||
ctx_len: Math.min(8192, model?.settings.ctx_len ?? 8192),
|
ctx_len: !isLocalEngine(model?.engine)
|
||||||
max_tokens: defaultContextLength,
|
? undefined
|
||||||
|
: defaultContextLength,
|
||||||
|
max_tokens: !isLocalEngine(model?.engine)
|
||||||
|
? (model?.parameters.max_tokens ?? 8192)
|
||||||
|
: defaultContextLength,
|
||||||
}
|
}
|
||||||
|
|
||||||
const modelParams = {
|
const modelParams = {
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import { fileUploadAtom } from '@/containers/Providers/Jotai'
|
|||||||
|
|
||||||
import { toaster } from '@/containers/Toast'
|
import { toaster } from '@/containers/Toast'
|
||||||
|
|
||||||
|
import { isLocalEngine } from '@/utils/modelEngine'
|
||||||
import { generateThreadId } from '@/utils/thread'
|
import { generateThreadId } from '@/utils/thread'
|
||||||
|
|
||||||
import { useActiveModel } from './useActiveModel'
|
import { useActiveModel } from './useActiveModel'
|
||||||
@ -113,12 +114,14 @@ export const useCreateNewThread = () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const overriddenSettings = {
|
const overriddenSettings = {
|
||||||
ctx_len: defaultContextLength,
|
ctx_len: !isLocalEngine(model?.engine) ? undefined : defaultContextLength,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use ctx length by default
|
// Use ctx length by default
|
||||||
const overriddenParameters = {
|
const overriddenParameters = {
|
||||||
max_tokens: defaultContextLength,
|
max_tokens: !isLocalEngine(model?.engine)
|
||||||
|
? (model?.parameters.token_limit ?? 8192)
|
||||||
|
: defaultContextLength,
|
||||||
}
|
}
|
||||||
|
|
||||||
const createdAt = Date.now()
|
const createdAt = Date.now()
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
import { useCallback, useEffect, useMemo, useRef, ClipboardEvent } from 'react'
|
import { useCallback, useEffect, useMemo, useRef, ClipboardEvent } from 'react'
|
||||||
|
|
||||||
import { MessageStatus } from '@janhq/core'
|
import { MessageStatus } from '@janhq/core'
|
||||||
import hljs from 'highlight.js'
|
|
||||||
import { useAtom, useAtomValue } from 'jotai'
|
import { useAtom, useAtomValue } from 'jotai'
|
||||||
|
|
||||||
import { BaseEditor, createEditor, Editor, Transforms } from 'slate'
|
import { BaseEditor, createEditor, Editor, Transforms } from 'slate'
|
||||||
@ -134,97 +133,9 @@ const RichTextEditor = ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Editor.isBlock(editor, node) && node.type === 'paragraph') {
|
|
||||||
node.children.forEach((child: { text: any }, childIndex: number) => {
|
|
||||||
const text = child.text
|
|
||||||
|
|
||||||
const codeBlockStartRegex = /```(\w*)/g
|
|
||||||
const matches = [...currentPrompt.matchAll(codeBlockStartRegex)]
|
|
||||||
|
|
||||||
if (matches.length % 2 !== 0) {
|
|
||||||
hasEndBackticks.current = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Match code block start and end
|
|
||||||
const lang = text.match(/^```(\w*)$/)
|
|
||||||
const endMatch = text.match(/^```$/)
|
|
||||||
|
|
||||||
if (lang) {
|
|
||||||
// If it's the start of a code block, store the language
|
|
||||||
currentLanguage.current = lang[1] || 'plaintext'
|
|
||||||
} else if (endMatch) {
|
|
||||||
// Reset language when code block ends
|
|
||||||
currentLanguage.current = 'plaintext'
|
|
||||||
} else if (
|
|
||||||
hasStartBackticks.current &&
|
|
||||||
hasEndBackticks.current &&
|
|
||||||
currentLanguage.current !== 'plaintext'
|
|
||||||
) {
|
|
||||||
// Highlight entire code line if in a code block
|
|
||||||
|
|
||||||
const codeContent = text.trim() // Remove leading spaces for highlighting
|
|
||||||
|
|
||||||
let highlighted = ''
|
|
||||||
highlighted = hljs.highlightAuto(codeContent).value
|
|
||||||
try {
|
|
||||||
highlighted = hljs.highlight(codeContent, {
|
|
||||||
language:
|
|
||||||
currentLanguage.current.length > 1
|
|
||||||
? currentLanguage.current
|
|
||||||
: 'plaintext',
|
|
||||||
}).value
|
|
||||||
} catch (err) {
|
|
||||||
highlighted = hljs.highlight(codeContent, {
|
|
||||||
language: 'javascript',
|
|
||||||
}).value
|
|
||||||
}
|
|
||||||
|
|
||||||
const parser = new DOMParser()
|
|
||||||
const doc = parser.parseFromString(highlighted, 'text/html')
|
|
||||||
|
|
||||||
let slateTextIndex = 0
|
|
||||||
|
|
||||||
doc.body.childNodes.forEach((childNode) => {
|
|
||||||
const childText = childNode.textContent || ''
|
|
||||||
|
|
||||||
const length = childText.length
|
|
||||||
const className =
|
|
||||||
childNode.nodeType === Node.ELEMENT_NODE
|
|
||||||
? (childNode as HTMLElement).className
|
|
||||||
: ''
|
|
||||||
|
|
||||||
ranges.push({
|
|
||||||
anchor: {
|
|
||||||
path: [...path, childIndex],
|
|
||||||
offset: slateTextIndex,
|
|
||||||
},
|
|
||||||
focus: {
|
|
||||||
path: [...path, childIndex],
|
|
||||||
offset: slateTextIndex + length,
|
|
||||||
},
|
|
||||||
type: 'code',
|
|
||||||
code: true,
|
|
||||||
language: currentLanguage.current,
|
|
||||||
className,
|
|
||||||
})
|
|
||||||
|
|
||||||
slateTextIndex += length
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
currentLanguage.current = 'plaintext'
|
|
||||||
ranges.push({
|
|
||||||
anchor: { path: [...path, childIndex], offset: 0 },
|
|
||||||
focus: { path: [...path, childIndex], offset: text.length },
|
|
||||||
type: 'paragraph', // Treat as a paragraph
|
|
||||||
code: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return ranges
|
return ranges
|
||||||
},
|
},
|
||||||
[currentPrompt, editor]
|
[editor]
|
||||||
)
|
)
|
||||||
|
|
||||||
// RenderLeaf applies the decoration styles
|
// RenderLeaf applies the decoration styles
|
||||||
|
|||||||
@ -38,7 +38,9 @@ export const getLogoEngine = (engine: InferenceEngine) => {
|
|||||||
* @param engine
|
* @param engine
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export const isLocalEngine = (engine: string) => {
|
export const isLocalEngine = (engine?: string) => {
|
||||||
|
if (!engine) return false
|
||||||
|
|
||||||
const engineObj = EngineManager.instance().get(engine)
|
const engineObj = EngineManager.instance().get(engine)
|
||||||
if (!engineObj) return false
|
if (!engineObj) return false
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user