Compare commits
7
Commits
0.3.31
...
0.3.31-fix2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
caa330c91f | ||
|
|
4a55d5729d | ||
|
|
d6a6697891 | ||
|
|
778cfb37a2 | ||
|
|
ce85ee3aa6 | ||
|
|
b23de4affc | ||
|
|
d8a7e894aa |
@@ -34,9 +34,7 @@ jobs:
|
||||
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
type=ref,event=branch
|
||||
type=sha,enable=true,priority=100,prefix=,suffix=,format=long
|
||||
type=semver,pattern={{major}}.{{minor}}.{{patch}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
|
||||
@@ -34,9 +34,7 @@ jobs:
|
||||
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
type=ref,event=branch
|
||||
type=sha,enable=true,priority=100,prefix=,suffix=,format=long
|
||||
type=semver,pattern={{major}}.{{minor}}.{{patch}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
type=semver,pattern={{major}}
|
||||
type=raw,value=${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v4
|
||||
|
||||
@@ -32,9 +32,12 @@ class AnthropicProvider(BaseModelProvider):
|
||||
if model_type == ModelType.TEXT_GENERATION:
|
||||
return [
|
||||
{
|
||||
'id': 'claude-instant-1',
|
||||
'name': 'claude-instant-1',
|
||||
'id': 'claude-2.1',
|
||||
'name': 'claude-2.1',
|
||||
'mode': ModelMode.CHAT.value,
|
||||
'features': [
|
||||
ModelFeature.AGENT_THOUGHT.value
|
||||
]
|
||||
},
|
||||
{
|
||||
'id': 'claude-2',
|
||||
@@ -44,6 +47,11 @@ class AnthropicProvider(BaseModelProvider):
|
||||
ModelFeature.AGENT_THOUGHT.value
|
||||
]
|
||||
},
|
||||
{
|
||||
'id': 'claude-instant-1',
|
||||
'name': 'claude-instant-1',
|
||||
'mode': ModelMode.CHAT.value,
|
||||
},
|
||||
]
|
||||
else:
|
||||
return []
|
||||
@@ -73,12 +81,18 @@ class AnthropicProvider(BaseModelProvider):
|
||||
:param model_type:
|
||||
:return:
|
||||
"""
|
||||
model_max_tokens = {
|
||||
'claude-instant-1': 100000,
|
||||
'claude-2': 100000,
|
||||
'claude-2.1': 200000,
|
||||
}
|
||||
|
||||
return ModelKwargsRules(
|
||||
temperature=KwargRule[float](min=0, max=1, default=1, precision=2),
|
||||
top_p=KwargRule[float](min=0, max=1, default=0.7, precision=2),
|
||||
presence_penalty=KwargRule[float](enabled=False),
|
||||
frequency_penalty=KwargRule[float](enabled=False),
|
||||
max_tokens=KwargRule[int](alias="max_tokens_to_sample", min=10, max=100000, default=256, precision=0),
|
||||
max_tokens=KwargRule[int](alias="max_tokens_to_sample", min=10, max=model_max_tokens.get(model_name, 100000), default=256, precision=0),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -23,8 +23,14 @@
|
||||
"currency": "USD"
|
||||
},
|
||||
"claude-2": {
|
||||
"prompt": "11.02",
|
||||
"completion": "32.68",
|
||||
"prompt": "8.00",
|
||||
"completion": "24.00",
|
||||
"unit": "0.000001",
|
||||
"currency": "USD"
|
||||
},
|
||||
"claude-2.1": {
|
||||
"prompt": "8.00",
|
||||
"completion": "24.00",
|
||||
"unit": "0.000001",
|
||||
"currency": "USD"
|
||||
}
|
||||
|
||||
+15
-3
@@ -1,7 +1,7 @@
|
||||
from typing import Dict
|
||||
|
||||
from httpx import Limits
|
||||
from langchain.chat_models import ChatAnthropic
|
||||
from langchain.schema import ChatMessage, BaseMessage, HumanMessage, AIMessage, SystemMessage
|
||||
from langchain.utils import get_from_dict_or_env, check_package_version
|
||||
from pydantic import root_validator
|
||||
|
||||
@@ -29,8 +29,7 @@ class AnthropicLLM(ChatAnthropic):
|
||||
base_url=values["anthropic_api_url"],
|
||||
api_key=values["anthropic_api_key"],
|
||||
timeout=values["default_request_timeout"],
|
||||
max_retries=0,
|
||||
connection_pool_limits=Limits(max_connections=200, max_keepalive_connections=100),
|
||||
max_retries=0
|
||||
)
|
||||
values["async_client"] = anthropic.AsyncAnthropic(
|
||||
base_url=values["anthropic_api_url"],
|
||||
@@ -46,3 +45,16 @@ class AnthropicLLM(ChatAnthropic):
|
||||
"Please it install it with `pip install anthropic`."
|
||||
)
|
||||
return values
|
||||
|
||||
def _convert_one_message_to_text(self, message: BaseMessage) -> str:
|
||||
if isinstance(message, ChatMessage):
|
||||
message_text = f"\n\n{message.role.capitalize()}: {message.content}"
|
||||
elif isinstance(message, HumanMessage):
|
||||
message_text = f"{self.HUMAN_PROMPT} {message.content}"
|
||||
elif isinstance(message, AIMessage):
|
||||
message_text = f"{self.AI_PROMPT} {message.content}"
|
||||
elif isinstance(message, SystemMessage):
|
||||
message_text = f"{message.content}"
|
||||
else:
|
||||
raise ValueError(f"Got unknown type {message}")
|
||||
return message_text
|
||||
|
||||
@@ -35,7 +35,7 @@ docx2txt==0.8
|
||||
pypdfium2==4.16.0
|
||||
resend~=0.5.1
|
||||
pyjwt~=2.6.0
|
||||
anthropic~=0.3.4
|
||||
anthropic~=0.7.2
|
||||
newspaper3k==0.2.8
|
||||
google-api-python-client==2.90.0
|
||||
wikipedia==1.4.0
|
||||
|
||||
@@ -31,12 +31,12 @@ def mock_chat_generate_invalid(messages: List[BaseMessage],
|
||||
run_manager: Optional[CallbackManagerForLLMRun] = None,
|
||||
**kwargs: Any):
|
||||
raise anthropic.APIStatusError('Invalid credentials',
|
||||
request=httpx._models.Request(
|
||||
method='POST',
|
||||
url='https://api.anthropic.com/v1/completions',
|
||||
),
|
||||
response=httpx._models.Response(
|
||||
status_code=401,
|
||||
request=httpx._models.Request(
|
||||
method='POST',
|
||||
url='https://api.anthropic.com/v1/completions',
|
||||
)
|
||||
),
|
||||
body=None
|
||||
)
|
||||
|
||||
@@ -2,7 +2,7 @@ version: '3.1'
|
||||
services:
|
||||
# API service
|
||||
api:
|
||||
image: langgenius/dify-api:0.3.31
|
||||
image: langgenius/dify-api:0.3.31-fix2
|
||||
restart: always
|
||||
environment:
|
||||
# Startup mode, 'api' starts the API server.
|
||||
@@ -128,7 +128,7 @@ services:
|
||||
# worker service
|
||||
# The Celery worker for processing the queue.
|
||||
worker:
|
||||
image: langgenius/dify-api:0.3.31
|
||||
image: langgenius/dify-api:0.3.31-fix2
|
||||
restart: always
|
||||
environment:
|
||||
# Startup mode, 'worker' starts the Celery worker for processing the queue.
|
||||
@@ -196,7 +196,7 @@ services:
|
||||
|
||||
# Frontend web application.
|
||||
web:
|
||||
image: langgenius/dify-web:0.3.31
|
||||
image: langgenius/dify-web:0.3.31-fix2
|
||||
restart: always
|
||||
environment:
|
||||
EDITION: SELF_HOSTED
|
||||
@@ -280,7 +280,7 @@ services:
|
||||
# (if uncommented, you need to comment out the weaviate service above,
|
||||
# and set VECTOR_STORE to qdrant in the api & worker service.)
|
||||
# qdrant:
|
||||
# image: qdrant/qdrant:latest
|
||||
# image: langgenius/qdrant:latest
|
||||
# restart: always
|
||||
# volumes:
|
||||
# - ./volumes/qdrant:/qdrant/storage
|
||||
@@ -302,4 +302,4 @@ services:
|
||||
- api
|
||||
- web
|
||||
ports:
|
||||
- "80:80"
|
||||
- "80:80"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
'use client'
|
||||
import type { FC } from 'react'
|
||||
import React, { useRef, useState } from 'react'
|
||||
import { useClickAway } from 'ahooks'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Toast from '../../base/toast'
|
||||
import { XClose } from '@/app/components/base/icons/src/vender/line/general'
|
||||
@@ -31,10 +30,10 @@ const ModifyRetrievalModal: FC<Props> = ({
|
||||
const { t } = useTranslation()
|
||||
const [retrievalConfig, setRetrievalConfig] = useState(value)
|
||||
|
||||
useClickAway(() => {
|
||||
if (ref)
|
||||
onHide()
|
||||
}, ref)
|
||||
// useClickAway(() => {
|
||||
// if (ref)
|
||||
// onHide()
|
||||
// }, ref)
|
||||
|
||||
const {
|
||||
rerankDefaultModel,
|
||||
|
||||
@@ -688,6 +688,7 @@ const Main: FC<IMainProps> = () => {
|
||||
onUnpin={handleUnpin}
|
||||
controlUpdateList={controlUpdateConversationList}
|
||||
onDelete={handleDelete}
|
||||
onStartChat={() => handleConversationIdChange('-1')}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -668,7 +668,7 @@ const Main: FC<IMainProps> = ({
|
||||
onUnpin={handleUnpin}
|
||||
controlUpdateList={controlUpdateConversationList}
|
||||
onDelete={handleDelete}
|
||||
onStartChat={handleStartChat}
|
||||
onStartChat={() => handleConversationIdChange('-1')}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Vendored
+1
-3
@@ -1,5 +1,3 @@
|
||||
declare module 'lamejs';
|
||||
declare module 'react-18-input-autosize';
|
||||
declare module 'fetch-readablestream' {
|
||||
export default function fetchReadableStream(url: string, options?: RequestInit): Promise<Response>
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
"echarts": "^5.4.1",
|
||||
"echarts-for-react": "^3.0.2",
|
||||
"emoji-mart": "^5.5.2",
|
||||
"fetch-readablestream": "^0.2.0",
|
||||
"i18next": "^22.4.13",
|
||||
"i18next-resources-to-backend": "^1.1.3",
|
||||
"immer": "^9.0.19",
|
||||
|
||||
+1
-7
@@ -1,11 +1,8 @@
|
||||
import fetchStream from 'fetch-readablestream'
|
||||
import { API_PREFIX, IS_CE_EDITION, PUBLIC_API_PREFIX } from '@/config'
|
||||
import Toast from '@/app/components/base/toast'
|
||||
import type { MessageEnd, MessageReplace, ThoughtItem } from '@/app/components/app/chat/type'
|
||||
import { isSupportNativeFetchStream } from '@/utils/stream'
|
||||
|
||||
const TIME_OUT = 100000
|
||||
const supportNativeFetchStream = isSupportNativeFetchStream()
|
||||
|
||||
const ContentType = {
|
||||
json: 'application/json',
|
||||
@@ -223,9 +220,6 @@ const baseFetch = <T>(
|
||||
if (body && bodyStringify)
|
||||
options.body = JSON.stringify(body)
|
||||
|
||||
// for those do not support native fetch stream, we use fetch-readablestream as polyfill
|
||||
const doFetch = supportNativeFetchStream ? globalThis.fetch : fetchStream
|
||||
|
||||
// Handle timeout
|
||||
return Promise.race([
|
||||
new Promise((resolve, reject) => {
|
||||
@@ -234,7 +228,7 @@ const baseFetch = <T>(
|
||||
}, TIME_OUT)
|
||||
}),
|
||||
new Promise((resolve, reject) => {
|
||||
doFetch(urlWithPrefix, options as RequestInit)
|
||||
globalThis.fetch(urlWithPrefix, options as RequestInit)
|
||||
.then((res) => {
|
||||
const resClone = res.clone()
|
||||
// Error handler
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
// https://developer.chrome.com/articles/fetch-streaming-requests/#feature-detection
|
||||
export const isSupportNativeFetchStream = () => {
|
||||
const supportsRequestStreams = (() => {
|
||||
let duplexAccessed = false
|
||||
|
||||
const params = {
|
||||
body: new ReadableStream(),
|
||||
method: 'POST',
|
||||
get duplex() {
|
||||
duplexAccessed = true
|
||||
return 'half'
|
||||
},
|
||||
}
|
||||
|
||||
const hasContentType = new Request('', params).headers.has('Content-Type')
|
||||
|
||||
return duplexAccessed && !hasContentType
|
||||
})()
|
||||
|
||||
return supportsRequestStreams
|
||||
}
|
||||
Reference in New Issue
Block a user