Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync release 0.4.10 to dev #2566

Merged
merged 13 commits into from
Apr 2, 2024
Merged
8 changes: 8 additions & 0 deletions core/src/browser/extensions/engines/OAIEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,20 @@ export abstract class OAIEngine extends AIEngine {
events.emit(MessageEvent.OnMessageUpdate, message)
},
error: async (err: any) => {
console.error(`Inference error: ${JSON.stringify(err, null, 2)}`)
if (this.isCancelled || message.content.length) {
message.status = MessageStatus.Stopped
events.emit(MessageEvent.OnMessageUpdate, message)
return
}
message.status = MessageStatus.Error
message.content[0] = {
type: ContentType.Text,
text: {
value: err.message,
annotations: [],
},
}
message.error_code = err.code
events.emit(MessageEvent.OnMessageUpdate, message)
},
Expand Down
2 changes: 2 additions & 0 deletions core/src/types/message/messageEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export enum MessageStatus {
export enum ErrorCode {
InvalidApiKey = 'invalid_api_key',

InsufficientQuota = 'insufficient_quota',

Unknown = 'unknown',
}

Expand Down
6 changes: 4 additions & 2 deletions extensions/assistant-extension/src/tools/retrieval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class RetrievalTool extends InferenceTool {
tool?: AssistantTool
): Promise<MessageRequest> {
if (!data.model || !data.messages) {
return Promise.resolve(this.normalize(data))
return Promise.resolve(data)
}

const latestMessage = data.messages[data.messages.length - 1]
Expand All @@ -38,6 +38,8 @@ export class RetrievalTool extends InferenceTool {
docFile,
data.model?.engine
)
} else {
return Promise.resolve(data)
}
} else if (
// Check whether we need to ingest document or not
Expand All @@ -48,7 +50,7 @@ export class RetrievalTool extends InferenceTool {
) {
// No document ingested, reroute the result to inference engine

return Promise.resolve(this.normalize(data))
return Promise.resolve(data)
}
// 2. Load agent on thread changed
if (this.retrievalThreadId !== data.threadId) {
Expand Down
2 changes: 1 addition & 1 deletion extensions/model-extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@janhq/model-extension",
"version": "1.0.28",
"version": "1.0.30",
"description": "Model Management Extension provides model exploration and seamless downloads",
"main": "dist/index.js",
"module": "dist/module.js",
Expand Down
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.2-GGUF/resolve/main/mistral-7b-instruct-v0.2.Q4_K_M.gguf"
}
],
"id": "mistral-7b",
"id": "mistral-ins-7b-q4",
"object": "model",
"name": "Mistral Instruct 7B Q4",
"version": "1.0",
Expand All @@ -29,7 +29,7 @@
"author": "MistralAI",
"tags": ["Featured", "7B", "Foundational Model"],
"size": 4370000000,
"cover": "https://raw.githubusercontent.com/janhq/jan/dev/models/mistral-7b/cover.png"
"cover": "https://raw.githubusercontent.com/janhq/jan/dev/models/mistral-ins-7b-q4/cover.png"
},
"engine": "nitro"
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "https://huggingface.co/janhq/stealth-v1.3-GGUF/resolve/main/stealth-v1.3.Q4_K_M.gguf"
}
],
"id": "stealth-7b",
"id": "stealth-v1.2-7b",
"object": "model",
"name": "Stealth 7B Q4",
"version": "1.0",
Expand Down
34 changes: 34 additions & 0 deletions models/tinyllama-1.1b/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"sources": [
{
"filename": "tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf",
"url": "https://huggingface.co/TheBloke/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf"
}
],
"id": "tinyllama-1.1b",
"object": "model",
"name": "TinyLlama Chat 1.1B Q4",
"version": "1.0",
"description": "TinyLlama is a tiny model with only 1.1B. It's a good model for less powerful computers.",
"format": "gguf",
"settings": {
"ctx_len": 4096,
"prompt_template": "<|system|>\n{system_message}<|user|>\n{prompt}<|assistant|>",
"llama_model_path": "tinyllama-1.1b-chat-v1.0.Q4_K_M.gguf"
},
"parameters": {
"temperature": 0.7,
"top_p": 0.95,
"stream": true,
"max_tokens": 2048,
"stop": [],
"frequency_penalty": 0,
"presence_penalty": 0
},
"metadata": {
"author": "TinyLlama",
"tags": ["Tiny", "Foundation Model"],
"size": 669000000
},
"engine": "nitro"
}
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"url": "https://huggingface.co/janhq/trinity-v1.2-GGUF/resolve/main/trinity-v1.2.Q4_K_M.gguf"
}
],
"id": "trinity-7b",
"id": "trinity-v1.2-7b",
"object": "model",
"name": "Trinity-v1.2 7B Q4",
"version": "1.0",
Expand All @@ -28,7 +28,7 @@
"author": "Jan",
"tags": ["7B", "Merged", "Featured"],
"size": 4370000000,
"cover": "https://raw.githubusercontent.com/janhq/jan/dev/models/trinity-7b/cover.png"
"cover": "https://raw.githubusercontent.com/janhq/jan/dev/models/trinity-v1.2-7b/cover.png"
},
"engine": "nitro"
}
34 changes: 34 additions & 0 deletions web/containers/AutoLink/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react'

type Props = {
text: string
}

const AutoLink: React.FC<Props> = ({ text }) => {
const delimiter =
/((?:https?:\/\/)?(?:(?:[a-z0-9]?(?:[a-z0-9-]{1,61}[a-z0-9])?\.[^.|\s])+[a-z.]*[a-z]+|(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})(?::\d{1,5})*[a-z0-9.,_/~#&=;%+?\-\\(\\)]*)/gi

return (
<>
{text.split(delimiter).map((word) => {
const match = word.match(delimiter)
if (match) {
const url = match[0]
return (
<a
key={url}
target="blank"
href={url.startsWith('http') ? url : `http://${url}`}
className="text-primary dark:text-blue-400"
>
{url}
</a>
)
}
return word
})}
</>
)
}

export default React.memo(AutoLink)
8 changes: 4 additions & 4 deletions web/hooks/useSendChatMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ export default function useSendChatMessage() {
selectedModelRef.current?.id ??
activeThreadRef.current.assistants[0].model.id

if (base64Blob) {
setFileUpload([])
}

if (modelRef.current?.id !== modelId) {
setQueuedMessage(true)
const error = await startModel(modelId).catch((error: Error) => error)
Expand Down Expand Up @@ -262,10 +266,6 @@ export default function useSendChatMessage() {
// Reset states
setReloadModel(false)
setEngineParamsUpdate(false)

if (base64Blob) {
setFileUpload([])
}
}

return {
Expand Down
16 changes: 9 additions & 7 deletions web/screens/Chat/ErrorMessage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Button } from '@janhq/uikit'
import { useAtomValue, useSetAtom } from 'jotai'
import { RefreshCcw } from 'lucide-react'

import AutoLink from '@/containers/AutoLink'
import ModalTroubleShooting, {
modalTroubleShootingAtom,
} from '@/containers/ModalTroubleShoot'
Expand Down Expand Up @@ -31,10 +32,11 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
resendChatMessage(message)
}

const errorTitle = getErrorTitle(
message.error_code ?? ErrorCode.Unknown,
message.content[0]?.text?.value
)
const errorTitle =
getErrorTitle(
message.error_code ?? ErrorCode.Unknown,
message.content[0]?.text?.value
) ?? 'Unknown error occurred.'

return (
<div className="mt-10">
Expand Down Expand Up @@ -84,7 +86,7 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
Model is currently unavailable. Please switch to a different
model or install the{' '}
<button
className="font-medium text-blue-500"
className="font-medium text-primary dark:text-blue-400"
onClick={() => setMainState(MainViewState.Settings)}
>
{loadModelError.split('::')[1] ?? ''}
Expand All @@ -95,9 +97,9 @@ const ErrorMessage = ({ message }: { message: ThreadMessage }) => {
) : (
<div
key={message.id}
className="flex flex-col items-center text-center text-sm font-medium text-gray-500"
className="mx-6 flex flex-col items-center space-y-2 text-center text-sm font-medium text-gray-500"
>
<p>{errorTitle}</p>
<AutoLink text={errorTitle} />
<p>
Jan’s in beta. Access&nbsp;
<span
Expand Down
8 changes: 5 additions & 3 deletions web/screens/ExploreModels/ExploreModelItemHeader/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback } from 'react'
import { useCallback, useState } from 'react'

import { Model } from '@janhq/core'
import {
Expand Down Expand Up @@ -70,6 +70,7 @@ const ExploreModelItemHeader: React.FC<Props> = ({ model, onClick, open }) => {
const { requestCreateNewThread } = useCreateNewThread()
const totalRam = useAtomValue(totalRamAtom)
const { settings } = useSettings()
const [imageLoaded, setImageLoaded] = useState(true)

const nvidiaTotalVram = useAtomValue(nvidiaTotalVramAtom)
const setMainViewState = useSetAtom(mainViewStateAtom)
Expand Down Expand Up @@ -143,9 +144,10 @@ const ExploreModelItemHeader: React.FC<Props> = ({ model, onClick, open }) => {
className="cursor-pointer rounded-t-md bg-background"
onClick={onClick}
>
{model.metadata.cover && (
<div className="relative h-full w-full ">
{model.metadata.cover && imageLoaded && (
<div className="relative h-full w-full">
<img
onError={() => setImageLoaded(false)}
src={model.metadata.cover}
className="h-[250px] w-full object-cover"
alt={`Cover - ${model.id}`}
Expand Down
Loading