Skip to content

Commit

Permalink
Merge branch 'main' into fix/qdrant-data-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnJyong committed Sep 20, 2023
2 parents d53d941 + e65f9cb commit e1fb2b2
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 30 deletions.
11 changes: 11 additions & 0 deletions .github/ISSUE_TEMPLATE/help_wanted.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "🤝 Help Wanted"
description: "Request help from the community"
labels:
- help-wanted
body:
- type: textarea
attributes:
label: Provide a description of the help you need
placeholder: Briefly describe what you need help with.
validations:
required: true
2 changes: 1 addition & 1 deletion api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(self):
self.CONSOLE_URL = get_env('CONSOLE_URL')
self.API_URL = get_env('API_URL')
self.APP_URL = get_env('APP_URL')
self.CURRENT_VERSION = "0.3.22"
self.CURRENT_VERSION = "0.3.23"
self.COMMIT_SHA = get_env('COMMIT_SHA')
self.EDITION = "SELF_HOSTED"
self.DEPLOY_ENV = get_env('DEPLOY_ENV')
Expand Down
6 changes: 3 additions & 3 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3.1'
services:
# API service
api:
image: langgenius/dify-api:0.3.22
image: langgenius/dify-api:0.3.23
restart: always
environment:
# Startup mode, 'api' starts the API server.
Expand Down Expand Up @@ -124,7 +124,7 @@ services:
# worker service
# The Celery worker for processing the queue.
worker:
image: langgenius/dify-api:0.3.22
image: langgenius/dify-api:0.3.23
restart: always
environment:
# Startup mode, 'worker' starts the Celery worker for processing the queue.
Expand Down Expand Up @@ -176,7 +176,7 @@ services:

# Frontend web application.
web:
image: langgenius/dify-web:0.3.22
image: langgenius/dify-web:0.3.23
restart: always
environment:
EDITION: SELF_HOSTED
Expand Down
8 changes: 5 additions & 3 deletions web/app/components/app/chat/copy-btn/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use client'
import React from 'react'
import { useRef, useState } from 'react'
import { t } from 'i18next'
import copy from 'copy-to-clipboard'
import s from './style.module.css'
import Tooltip from '@/app/components/base/tooltip'
import { randomString } from '@/utils'

type ICopyBtnProps = {
value: string
Expand All @@ -16,12 +17,13 @@ const CopyBtn = ({
className,
isPlain,
}: ICopyBtnProps) => {
const [isCopied, setIsCopied] = React.useState(false)
const [isCopied, setIsCopied] = useState(false)
const selector = useRef(`copy-tooltip-${randomString(4)}`)

return (
<div className={`${className}`}>
<Tooltip
selector={`copy-btn-tooltip-${value}`}
selector={selector.current}
content={(isCopied ? t('appApi.copied') : t('appApi.copy')) as string}
className='z-10'
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@ import OpeningStatement from '@/app/components/app/configuration/features/chat-g
import GroupName from '@/app/components/app/configuration/base/group-name'
import Loading from '@/app/components/base/loading'
import Confirm from '@/app/components/base/confirm'
// type
import type { AutomaticRes } from '@/service/debug'

const noDataIcon = (
<svg width="56" height="56" viewBox="0 0 56 56" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10.4998 51.3333V39.6666M10.4998 16.3333V4.66663M4.6665 10.5H16.3332M4.6665 45.5H16.3332M30.3332 6.99996L26.2868 17.5206C25.6287 19.2315 25.2997 20.0869 24.7881 20.8065C24.3346 21.4442 23.7774 22.0014 23.1397 22.4549C22.4202 22.9665 21.5647 23.2955 19.8538 23.9535L9.33317 28L19.8539 32.0464C21.5647 32.7044 22.4202 33.0334 23.1397 33.5451C23.7774 33.9985 24.3346 34.5557 24.7881 35.1934C25.2997 35.913 25.6287 36.7684 26.2868 38.4793L30.3332 49L34.3796 38.4793C35.0376 36.7684 35.3666 35.913 35.8783 35.1934C36.3317 34.5557 36.8889 33.9985 37.5266 33.5451C38.2462 33.0334 39.1016 32.7044 40.8125 32.0464L51.3332 28L40.8125 23.9535C39.1016 23.2955 38.2462 22.9665 37.5266 22.4549C36.8889 22.0014 36.3317 21.4442 35.8783 20.8065C35.3666 20.0869 35.0376 19.2315 34.3796 17.5206L30.3332 6.99996Z" stroke="#EAECF0" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"/>
</svg>
)

export type AutomaticRes = {
prompt: string
variables: string[]
opening_statement: string
}

export type IGetAutomaticResProps = {
mode: AppType
isShow: boolean
Expand Down Expand Up @@ -98,7 +94,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
audiences,
hoping_to_solve: hopingToSolve,
})
setRes(res as AutomaticRes)
setRes(res)
}
finally {
setLoadingFalse()
Expand Down Expand Up @@ -193,7 +189,7 @@ const GetAutomaticRes: FC<IGetAutomaticResProps> = ({
onClose={() => setShowConfirmOverwrite(false)}
onConfirm={() => {
setShowConfirmOverwrite(false)
onFinished(res as AutomaticRes)
onFinished(res!)
}}
onCancel={() => setShowConfirmOverwrite(false)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const TIP_MAP: { [k: string]: TypeWithI18N } = {
'zh-Hans': '免费获取 100 万个 token',
},
[ProviderEnumValue.spark]: {
'en': 'Earn 3 million tokens for free',
'zh-Hans': '免费获取 300 万个 token',
'en': 'Earn 6 million tokens for free',
'zh-Hans': '免费获取 600 万个 token',
},
[ProviderEnumValue.zhipuai]: {
'en': 'Earn 10 million tokens for free',
Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dify-web",
"version": "0.3.22",
"version": "0.3.23",
"private": true,
"scripts": {
"dev": "next dev",
Expand Down
22 changes: 11 additions & 11 deletions web/service/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ export function format(text: string) {
return res.replaceAll('\n', '<br/>').replaceAll('```', '')
}

const handleStream = (response: any, onData: IOnData, onCompleted?: IOnCompleted, onThought?: IOnThought, onMessageEnd?: IOnMessageEnd) => {
const handleStream = (response: Response, onData: IOnData, onCompleted?: IOnCompleted, onThought?: IOnThought, onMessageEnd?: IOnMessageEnd) => {
if (!response.ok)
throw new Error('Network response was not ok')

const reader = response.body.getReader()
const reader = response.body?.getReader()
const decoder = new TextDecoder('utf-8')
let buffer = ''
let bufferObj: any
let bufferObj: Record<string, any>
let isFirstMessage = true
function read() {
let hasError = false
reader.read().then((result: any) => {
reader?.read().then((result: any) => {
if (result.done) {
onCompleted && onCompleted()
return
Expand All @@ -99,7 +99,7 @@ const handleStream = (response: any, onData: IOnData, onCompleted?: IOnCompleted
lines.forEach((message) => {
if (message.startsWith('data: ')) { // check if it starts with data:
try {
bufferObj = JSON.parse(message.substring(6)) // remove data: and parse as json
bufferObj = JSON.parse(message.substring(6)) as Record<string, any>// remove data: and parse as json
}
catch (e) {
// mute handle message cut off
Expand All @@ -113,11 +113,11 @@ const handleStream = (response: any, onData: IOnData, onCompleted?: IOnCompleted
onData('', false, {
conversationId: undefined,
messageId: '',
errorMessage: bufferObj.message,
errorCode: bufferObj.code,
errorMessage: bufferObj?.message,
errorCode: bufferObj?.code,
})
hasError = true
onCompleted && onCompleted(true)
onCompleted?.(true)
return
}
if (bufferObj.event === 'message') {
Expand All @@ -130,10 +130,10 @@ const handleStream = (response: any, onData: IOnData, onCompleted?: IOnCompleted
isFirstMessage = false
}
else if (bufferObj.event === 'agent_thought') {
onThought?.(bufferObj as any)
onThought?.(bufferObj as ThoughtItem)
}
else if (bufferObj.event === 'message_end') {
onMessageEnd?.(bufferObj as any)
onMessageEnd?.(bufferObj as MessageEnd)
}
}
})
Expand All @@ -146,7 +146,7 @@ const handleStream = (response: any, onData: IOnData, onCompleted?: IOnCompleted
errorMessage: `${e}`,
})
hasError = true
onCompleted && onCompleted(true)
onCompleted?.(true)
return
}
if (!hasError)
Expand Down
8 changes: 7 additions & 1 deletion web/service/debug.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import type { IOnCompleted, IOnData, IOnError, IOnMessageEnd } from './base'
import { get, post, ssePost } from './base'

export type AutomaticRes = {
prompt: string
variables: string[]
opening_statement: string
}

export const sendChatMessage = async (appId: string, body: Record<string, any>, { onData, onCompleted, onError, getAbortController, onMessageEnd }: {
onData: IOnData
onCompleted: IOnCompleted
Expand Down Expand Up @@ -46,7 +52,7 @@ export const fetchConvesationMessages = (appId: string, conversation_id: string)
}

export const generateRule = (body: Record<string, any>) => {
return post('/rule-generate', {
return post<AutomaticRes>('/rule-generate', {
body,
})
}
Expand Down
10 changes: 10 additions & 0 deletions web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3752,7 +3752,11 @@ mdast-util-from-markdown@^0.8.5:
parse-entities "^2.0.0"
unist-util-stringify-position "^2.0.0"

<<<<<<< Updated upstream
mdast-util-from-markdown@^1.0.0, mdast-util-from-markdown@^1.1.0, mdast-util-from-markdown@^1.3.0:
=======
mdast-util-from-markdown@^1.0.0, mdast-util-from-markdown@^1.1.0:
>>>>>>> Stashed changes
version "1.3.1"
resolved "https://registry.npmjs.org/mdast-util-from-markdown/-/mdast-util-from-markdown-1.3.1.tgz"
integrity sha512-4xTO/M8c82qBcnQc1tgpNtubGUW/Y1tBQ1B0i5CtSoelOLKFYlElIr3bvgREYYO5iRqbMY1YuqZng0GVOI8Qww==
Expand Down Expand Up @@ -5368,11 +5372,14 @@ safe-regex@^2.1.1:
dependencies:
regexp-tree "~0.1.1"

<<<<<<< Updated upstream
"safer-buffer@>= 2.1.2 < 3.0.0":
version "2.1.2"
resolved "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz"
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==

=======
>>>>>>> Stashed changes
sass@^1.61.0:
version "1.62.1"
resolved "https://registry.npmjs.org/sass/-/sass-1.62.1.tgz"
Expand Down Expand Up @@ -6120,11 +6127,14 @@ web-namespaces@^2.0.0:
resolved "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz"
integrity sha512-bKr1DkiNa2krS7qxNtdrtHAmzuYGFQLiQ13TsorsdT6ULTkPLKuu5+GsFpDlg6JFjUTwX2DyhMPG2be8uPrqsQ==

<<<<<<< Updated upstream
web-worker@^1.2.0:
version "1.2.0"
resolved "https://registry.npmjs.org/web-worker/-/web-worker-1.2.0.tgz"
integrity sha512-PgF341avzqyx60neE9DD+XS26MMNMoUQRz9NOZwW32nPQrF6p77f1htcnjBSEV8BGMKZ16choqUG4hyI0Hx7mA==

=======
>>>>>>> Stashed changes
which-boxed-primitive@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz"
Expand Down

0 comments on commit e1fb2b2

Please sign in to comment.