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

Model Runtime #1858

Merged
merged 1,324 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1324 commits
Select commit Hold shift + click to select a range
96f55e3
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 26, 2023
410dddd
fix: model parameter model
zxhlyh Dec 26, 2023
d7a6b8f
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
zxhlyh Dec 26, 2023
a0c2169
fix bug
takatost Dec 26, 2023
07b408c
fix bug
takatost Dec 26, 2023
926f31b
fix: content moderation
zxhlyh Dec 26, 2023
47cc11c
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
zxhlyh Dec 26, 2023
8af4d7b
fix bugs
takatost Dec 26, 2023
99271ec
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 26, 2023
ca848a8
remove debug code
takatost Dec 26, 2023
1d34c2c
refactor azure openai.
GarfieldDai Dec 26, 2023
28ef34a
optimize
takatost Dec 26, 2023
458a008
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 26, 2023
0249633
model selector
zxhlyh Dec 26, 2023
08ab266
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
zxhlyh Dec 26, 2023
06c0403
optimize default model
takatost Dec 26, 2023
bd647b0
optimize default model
takatost Dec 26, 2023
cc506df
fix bug
takatost Dec 26, 2023
1c50056
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 26, 2023
eb92647
optimize default model
takatost Dec 26, 2023
cf75984
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 26, 2023
28de28b
refactor azure openai.
GarfieldDai Dec 26, 2023
d49229d
Merge branch 'feat/model-runtime' into deploy/dev
GarfieldDai Dec 26, 2023
b333189
hooks
zxhlyh Dec 26, 2023
b4b7f47
add lru cache for rsa decrypt decoding
takatost Dec 26, 2023
031a1e9
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 26, 2023
2483135
optimize generate speed
takatost Dec 26, 2023
0ca6b42
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 26, 2023
b72b304
fix annotation
takatost Dec 26, 2023
67f2d74
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 26, 2023
5f7a55d
fix: default provider model icon
zxhlyh Dec 27, 2023
f060d8d
hooks
zxhlyh Dec 26, 2023
f3259a8
fix: default provider model icon
zxhlyh Dec 27, 2023
e303956
openAI API-compatibility
guchenhe Dec 27, 2023
437147b
refactor azure openai.
GarfieldDai Dec 27, 2023
7d7bdc1
Merge branch 'feat/model-runtime' into deploy/dev
GarfieldDai Dec 27, 2023
db96302
fix: model icon name
zxhlyh Dec 27, 2023
aaf6adb
merge feat/model-provider-based-on-runtime
zxhlyh Dec 27, 2023
55e8039
fix yaml formatting
guchenhe Dec 27, 2023
b95155e
add zhipuai
takatost Dec 27, 2023
02d5480
fix zhipuai
takatost Dec 27, 2023
012f785
Merge branch 'feat/model-runtime' into deploy/dev
guchenhe Dec 27, 2023
41696e3
fix: provider context
zxhlyh Dec 27, 2023
ab53da2
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
zxhlyh Dec 27, 2023
2cf5ba6
fix schema parse
takatost Dec 27, 2023
5f63ea6
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 27, 2023
dd99a61
refactor azure openai.
GarfieldDai Dec 27, 2023
0cf6468
Merge branch 'feat/model-runtime' into deploy/dev
GarfieldDai Dec 27, 2023
9b1363d
fix: provider context
zxhlyh Dec 27, 2023
b692c5d
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
zxhlyh Dec 27, 2023
6779a5e
fix model get price
takatost Dec 27, 2023
4a4e871
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 27, 2023
e9dbbd2
add celery scheduler
JohnJyong Dec 27, 2023
d3acb42
fix: background & icon
zxhlyh Dec 27, 2023
3dca7ce
Merge branch 'feat/model-runtime' into deploy/dev
zxhlyh Dec 27, 2023
333f20a
fix bugs
takatost Dec 27, 2023
a2eb96d
fix: zhipuai
zxhlyh Dec 27, 2023
c109626
Merge branch 'feat/model-runtime' into deploy/dev
zxhlyh Dec 27, 2023
7ae8d79
fix: splitting text ui broken
iamjoel Dec 27, 2023
d2a6b2d
Merge branch 'fix/splitting-text-ui' into deploy/dev
iamjoel Dec 27, 2023
6dd914f
fix quota
zxhlyh Dec 27, 2023
5a47a31
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
zxhlyh Dec 27, 2023
77c1cb1
fix model not exist issue
JohnJyong Dec 27, 2023
a6cf7c9
fix embeddings base64 decode
JohnJyong Dec 27, 2023
13c9794
change priority
zxhlyh Dec 27, 2023
47dce8e
Merge branch 'feat/model-runtime' into deploy/dev
JohnJyong Dec 27, 2023
66acc75
change priority
zxhlyh Dec 27, 2023
00d571e
feat: able to detect chat/generation model automatically
Yeuoly Dec 27, 2023
9e7a049
fix: provider_configuration.py
GarfieldDai Dec 27, 2023
66ae242
Merge branch 'feat/model-runtime' into deploy/dev
GarfieldDai Dec 27, 2023
265e061
fix blocking metadata issue
JohnJyong Dec 27, 2023
7258363
Merge remote-tracking branch 'origin/feat/model-runtime' into feat/mo…
JohnJyong Dec 27, 2023
63d9857
Merge branch 'feat/model-runtime' into deploy/dev
JohnJyong Dec 27, 2023
eaf4a69
fix agent
takatost Dec 27, 2023
2c64b2c
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 27, 2023
2054f2d
refactor: azure openai.
GarfieldDai Dec 27, 2023
76d3c1e
fix message not save
takatost Dec 27, 2023
b1e71e6
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 27, 2023
6185b7d
fix function and embedding
takatost Dec 27, 2023
ad750f5
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 27, 2023
ddbca0d
refactor: azure openai.
GarfieldDai Dec 27, 2023
f68cbb5
Merge branch 'feat/model-runtime' into deploy/dev
GarfieldDai Dec 27, 2023
9e17bf0
refactor: azure openai.
GarfieldDai Dec 27, 2023
47e8178
Merge branch 'feat/model-runtime' into deploy/dev
GarfieldDai Dec 27, 2023
f6efdf9
fix bug
takatost Dec 27, 2023
a175bd5
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 27, 2023
a8b1288
refactor: azure openai.
GarfieldDai Dec 27, 2023
f34579b
Merge branch 'feat/model-runtime' into deploy/dev
GarfieldDai Dec 27, 2023
71c9064
add clean unused datasets and embedding cache
JohnJyong Dec 27, 2023
3ffdfbb
add clean unused datasets and embedding cache
JohnJyong Dec 27, 2023
5381836
Merge branch 'feat/add-data-clean-schedule' into deploy/dev
JohnJyong Dec 27, 2023
68eef70
pip install sympy==1.12.
GarfieldDai Dec 28, 2023
7ab4d48
fix: zhipuai spark tongyi
zxhlyh Dec 28, 2023
cf84b2e
add clean unused datasets and embedding cache
JohnJyong Dec 28, 2023
8a112ed
Merge branch 'feat/add-data-clean-schedule' into deploy/dev
JohnJyong Dec 28, 2023
53983fa
Merge remote-tracking branch 'origin/deploy/dev' into deploy/dev
JohnJyong Dec 28, 2023
4b4bd75
add clean unused datasets and embedding cache
JohnJyong Dec 28, 2023
82dccc6
Merge branch 'feat/add-data-clean-schedule' into deploy/dev
JohnJyong Dec 28, 2023
39fb921
add clean unused datasets and embedding cache
JohnJyong Dec 28, 2023
1cc5a2a
Merge branch 'feat/add-data-clean-schedule' into deploy/dev
JohnJyong Dec 28, 2023
9004f0f
add clean unused datasets and embedding cache
JohnJyong Dec 28, 2023
0aee5d0
Merge branch 'feat/add-data-clean-schedule' into deploy/dev
JohnJyong Dec 28, 2023
177915a
fix: baichuan does not support system message
Yeuoly Dec 28, 2023
10353f1
add clean unused datasets and embedding cache
JohnJyong Dec 28, 2023
10550f6
Merge branch 'feat/add-data-clean-schedule' into deploy/dev
JohnJyong Dec 28, 2023
d8ad66e
fix: add get_customizable_model_schema to xinference
Yeuoly Dec 28, 2023
46b98ec
fix: zhipuai spark tongyi
zxhlyh Dec 28, 2023
8635c58
fix: baichuan does not support system message
Yeuoly Dec 28, 2023
3ed46ce
fix: add get_customizable_model_schema to xinference
Yeuoly Dec 28, 2023
c23f37c
fix: universal chat
zxhlyh Dec 28, 2023
d5d7699
merge model-provider-based-on-runtime
zxhlyh Dec 28, 2023
643845c
temp
iamjoel Dec 26, 2023
b78d12e
chore: retriever_resources to new struct
iamjoel Dec 28, 2023
3440bec
Merge branch 'main' into feat/model-provider-based-on-runtime
iamjoel Dec 28, 2023
b768764
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
iamjoel Dec 28, 2023
ca83d99
multi-tenancy for google genai client
guchenhe Dec 28, 2023
1081104
clean up
guchenhe Dec 28, 2023
0b572d1
Merge branch 'fix/google-client-tenancy' into feat/model-runtime
guchenhe Dec 28, 2023
b1a9b35
add model type in ai model base class
takatost Dec 28, 2023
fd12ce4
add clean unused datasets and embedding cache
JohnJyong Dec 28, 2023
7ebc7bb
Merge branch 'feat/add-data-clean-schedule' into deploy/dev
JohnJyong Dec 28, 2023
fc793e1
Merge branch 'feat/model-runtime' into deploy/dev
GarfieldDai Dec 28, 2023
3a2d273
fix: credentials error.
GarfieldDai Dec 28, 2023
6f8ecdb
Merge branch 'feat/model-runtime' into deploy/dev
GarfieldDai Dec 28, 2023
433b08e
fix dataset query in completion app
takatost Dec 28, 2023
c862c5c
add clean unused datasets and embedding cache
JohnJyong Dec 28, 2023
1c5b11a
Merge branch 'feat/add-data-clean-schedule' into deploy/dev
JohnJyong Dec 28, 2023
8426bdd
Merge remote-tracking branch 'origin/deploy/dev' into deploy/dev
JohnJyong Dec 28, 2023
06268ad
fix dataset query in completion app
takatost Dec 28, 2023
cf8f708
fix: some
zxhlyh Dec 28, 2023
ae9bce7
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
zxhlyh Dec 28, 2023
680d7b7
fix: Unbound type of embedding_model_instance when using economy mode
Yeuoly Dec 28, 2023
582ca01
Merge branch 'feat/document-segmentic' into deploy/dev
Yeuoly Dec 28, 2023
ef63077
fix: some
zxhlyh Dec 28, 2023
c024882
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
zxhlyh Dec 28, 2023
0f31f5f
fix: tooltip in model-item
zxhlyh Dec 28, 2023
efa2eb9
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
zxhlyh Dec 28, 2023
77ab63b
tidy up UI for configuring OpenAI API-compatible models
guchenhe Dec 28, 2023
df67d5a
feat: update yaml.
GarfieldDai Dec 28, 2023
0abaa92
Merge branch 'feat/model-runtime' into deploy/dev
GarfieldDai Dec 28, 2023
4bace2a
fix message stream id param
takatost Dec 28, 2023
f84d4e6
fix credentials encrypted when get model schema
takatost Dec 28, 2023
6fa4b4d
fix provider title
guchenhe Dec 28, 2023
8207869
Merge remote-tracking branch 'refs/remotes/origin/feat/model-runtime'…
guchenhe Dec 28, 2023
77acd31
Merge branch 'feat/model-runtime' into deploy/dev
guchenhe Dec 28, 2023
dba4f6e
fix: chatglm api_base should be required
Yeuoly Dec 28, 2023
35e4f4b
Merge branch 'feat/model-runtime' into deploy/dev
Yeuoly Dec 28, 2023
3087fc5
fix dataset query not record
takatost Dec 28, 2023
e030458
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 28, 2023
f392b3c
fix: openllm credentials
Yeuoly Dec 28, 2023
66253f4
fix: model parameter rule
zxhlyh Dec 28, 2023
79b34de
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
zxhlyh Dec 28, 2023
58b8495
fix: model modal style
zxhlyh Dec 28, 2023
c468061
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
zxhlyh Dec 28, 2023
b181682
fix: error in minimax system message
Yeuoly Dec 28, 2023
e31f6c2
Merge branch 'feat/model-runtime' into deploy/dev
Yeuoly Dec 28, 2023
30efd07
fix: azure icon
zxhlyh Dec 28, 2023
1a1b943
add type `switch` for CredentialFormSchema
takatost Dec 28, 2023
00ffdc2
Merge branch 'feat/model-runtime' into deploy/dev
zxhlyh Dec 28, 2023
59a2c8c
add clean unused datasets and embedding cache
JohnJyong Dec 28, 2023
bdf4773
Merge branch 'feat/add-data-clean-schedule' into deploy/dev
JohnJyong Dec 28, 2023
be9021c
fix bugs
takatost Dec 28, 2023
0a43db8
fix: model-selector style
zxhlyh Dec 28, 2023
0b77449
fix: compeltion type
Yeuoly Dec 28, 2023
18828ff
Merge branch 'feat/model-provider-based-on-runtime' into deploy/dev
zxhlyh Dec 28, 2023
2644503
Merge branch 'feat/model-runtime' into deploy/dev
Yeuoly Dec 28, 2023
c27c4db
fix: tongyi variable name
zxhlyh Dec 28, 2023
7118f31
Merge branch 'feat/model-runtime' into deploy/dev
zxhlyh Dec 28, 2023
9af8a59
fix: missing system prompt, missing arguments
Yeuoly Dec 28, 2023
4f3ff71
fix: missing system prompt, missing arguments
Yeuoly Dec 28, 2023
f76a00f
fix: baichuan max usage
Yeuoly Dec 28, 2023
3420454
Merge branch 'feat/model-runtime' into deploy/dev
Yeuoly Dec 28, 2023
db069fa
fix bugs
takatost Dec 28, 2023
d09723a
fix deprecated models still in model list
takatost Dec 28, 2023
7815485
fix system content empty
takatost Dec 28, 2023
d033609
fix: erniebot temperature
Yeuoly Dec 28, 2023
a833026
Merge branch 'feat/model-runtime' into deploy/dev
Yeuoly Dec 28, 2023
321675a
fix parameter credentials invalid in free quota types
takatost Dec 28, 2023
6f3d210
fix: support partical default models
Yeuoly Dec 28, 2023
c8ef7dc
Merge branch 'feat/model-runtime' into deploy/dev
Yeuoly Dec 28, 2023
bc40abe
add switch prefer provider type when add credentials for provider
takatost Dec 28, 2023
e08c13d
cut down openai API-compatible model config options; fix gemini bugs
guchenhe Dec 28, 2023
a34fe35
fix speech2text
takatost Dec 28, 2023
69c9bcc
Merge branch 'feat/model-runtime' into deploy/dev
takatost Dec 28, 2023
299ea51
refactor huggingface and replicate.
GarfieldDai Dec 28, 2023
aa543ea
Merge branch 'feat/model-runtime' into deploy/dev
GarfieldDai Dec 28, 2023
9ec8fa0
cut down openai API-compatible model config options; fix gemini bugs
guchenhe Dec 28, 2023
53bd2e1
fix: baichuan text-embedding
Yeuoly Dec 28, 2023
709fbdb
Merge branch 'feat/model-runtime' into deploy/dev
Yeuoly Dec 28, 2023
15d6806
add hack around gemini-vision-pro single-turn chat
guchenhe Dec 28, 2023
d408a38
Bugfix
takatost Dec 28, 2023
63acf6c
fix: replace openai completion credentials validation model with text…
Yeuoly Dec 30, 2023
120ecb5
fix: remove monkeypatch
Yeuoly Dec 30, 2023
e17e7a1
fix: branch conflict
Yeuoly Dec 30, 2023
35b2561
fix: branch conflict
Yeuoly Dec 30, 2023
3622fa8
feat: add mock to openai
Yeuoly Dec 30, 2023
09dc09c
feat: add mock support to xinference
Yeuoly Dec 31, 2023
de00184
refactor replicate.
GarfieldDai Jan 1, 2024
f21461c
refactor huggingface.
GarfieldDai Jan 1, 2024
db5036e
fix bugs
takatost Jan 1, 2024
855df40
fix bugs
takatost Jan 1, 2024
5bd9760
fix bug
takatost Jan 1, 2024
4aedb2c
fix tests
takatost Jan 1, 2024
b45f8d4
replace image
takatost Jan 1, 2024
c66b5a2
fix: chatglm max tokens
Yeuoly Jan 2, 2024
33d2f79
fix dataset in agent
takatost Jan 2, 2024
0deab49
fix: customizable model missing use_template
Yeuoly Jan 2, 2024
dc21ea8
fix: localai
Yeuoly Jan 2, 2024
281bd30
huggingface namespace validate.
GarfieldDai Jan 2, 2024
ba33ec7
fix chat app system message missing
takatost Jan 2, 2024
3cbb3b7
fix bugs
takatost Jan 2, 2024
b169781
add completion support for openai api compatible
guchenhe Jan 2, 2024
57a5837
fix conversation_histories_role not exists in completion app
takatost Jan 2, 2024
7777c34
fix
guchenhe Jan 2, 2024
9344091
fix model property key
guchenhe Jan 2, 2024
a1028ec
fix bug
takatost Jan 2, 2024
9006060
fix: external_data_variables key error
Yeuoly Jan 2, 2024
668b762
Merge branch 'feat/model-runtime' into feat/model-runtime-add-mock
Yeuoly Jan 2, 2024
a0835ea
fix: add mock support to chatglm
Yeuoly Jan 2, 2024
97df96a
add link to runtime contributing guide
guchenhe Jan 2, 2024
7871f9c
refactor huggingface.
GarfieldDai Jan 2, 2024
a48dfd1
fix gemini pro vision bug
takatost Jan 2, 2024
f774f5d
fix bug
takatost Jan 2, 2024
0a08553
fix openai ft models
takatost Jan 2, 2024
7544334
fix tool enabled missing
takatost Jan 2, 2024
99da304
feat: mock
Yeuoly Jan 2, 2024
98f58ff
merge main
zxhlyh Jan 2, 2024
5b6d3c0
fix tool enabled missing in agent
takatost Jan 2, 2024
71cb2e0
fix max token bug
takatost Jan 2, 2024
e23f347
fix mode enum
takatost Jan 2, 2024
89c51e0
fix: spark tongyi zhipu
zxhlyh Jan 2, 2024
1fe2bed
fix grpc/gevent conflict
guchenhe Jan 2, 2024
37e77f4
fix: tongyi llm & zhipu embedding
zxhlyh Jan 2, 2024
d6ee7bd
refactor.
GarfieldDai Jan 2, 2024
6f65d12
feat: mock
Yeuoly Jan 2, 2024
f1c8364
fix: conflict
Yeuoly Jan 2, 2024
b3b9c64
fix: add default value to top k
Yeuoly Jan 2, 2024
745d349
fix: miss test
Yeuoly Jan 2, 2024
bfd95a6
feat: add github actions
Yeuoly Jan 2, 2024
8671204
fix: actions
Yeuoly Jan 2, 2024
98fdac3
fix: remobe line breaker
Yeuoly Jan 2, 2024
cf77abc
ci: remove unit tests
Yeuoly Jan 2, 2024
39c441f
optimize
takatost Jan 2, 2024
f7541a6
hosting config add edition logic
takatost Jan 2, 2024
b3ca03a
fix.
GarfieldDai Jan 2, 2024
09c4dac
fix output moderation
takatost Jan 2, 2024
de3f328
bump version to 0.4.0
takatost Jan 2, 2024
0b6460b
feat: add huggingface mock
Yeuoly Jan 2, 2024
015f439
fix: huggingface
Yeuoly Jan 2, 2024
6540524
remove gpt-2 cache in dockerfile
takatost Jan 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
58 changes: 58 additions & 0 deletions .github/workflows/api-model-runtime-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Run Pytest

on:
pull_request:
branches:
- main
push:
branches:
- deploy/dev
- feat/model-runtime

jobs:
test:
runs-on: ubuntu-latest

env:
OPENAI_API_KEY: sk-IamNotARealKeyJustForMockTestKawaiiiiiiiiii
AZURE_OPENAI_API_BASE: https://difyai-openai.openai.azure.com
AZURE_OPENAI_API_KEY: xxxxb1707exxxxxxxxxxaaxxxxxf94
ANTHROPIC_API_KEY: sk-ant-api11-IamNotARealKeyJustForMockTestKawaiiiiiiiiii-NotBaka-ASkksz
CHATGLM_API_BASE: http://a.abc.com:11451
XINFERENCE_SERVER_URL: http://a.abc.com:11451
XINFERENCE_GENERATION_MODEL_UID: generate
XINFERENCE_CHAT_MODEL_UID: chat
XINFERENCE_EMBEDDINGS_MODEL_UID: embedding
XINFERENCE_RERANK_MODEL_UID: rerank
GOOGLE_API_KEY: abcdefghijklmnopqrstuvwxyz
HUGGINGFACE_API_KEY: hf-awuwuwuwuwuwuwuwuwuwuwuwuwuwuwuwuwu
HUGGINGFACE_TEXT_GEN_ENDPOINT_URL: a
HUGGINGFACE_TEXT2TEXT_GEN_ENDPOINT_URL: b
HUGGINGFACE_EMBEDDINGS_ENDPOINT_URL: c
MOCK_SWITCH: true


steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Cache pip dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('api/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -r api/requirements.txt

- name: Run pytest
run: pytest api/tests/integration_tests/model_runtime/anthropic api/tests/integration_tests/model_runtime/azure_openai api/tests/integration_tests/model_runtime/openai api/tests/integration_tests/model_runtime/chatglm api/tests/integration_tests/model_runtime/google api/tests/integration_tests/model_runtime/xinference api/tests/integration_tests/model_runtime/huggingface_hub/test_llm.py
38 changes: 0 additions & 38 deletions .github/workflows/api-unit-tests.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ Did you have an issue, like a merge conflict, or don't know how to open a pull r

Stuck somewhere? Have any questions? Join the [Discord Community Server](https://discord.gg/j3XRWSPBf7). We are here to help!


### Provider Integrations
If you see a model provider not yet supported by Dify that you'd like to use, follow these [steps](api/core/model_runtime/README.md) to submit a PR.


### i18n (Internationalization) Support

We are looking for contributors to help with translations in other languages. If you are interested in helping, please join the [Discord Community Server](https://discord.gg/AhzKf7dNgk) and let us know.
Expand Down
15 changes: 15 additions & 0 deletions api/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Celery",
"type": "python",
"request": "launch",
"module": "celery",
"justMyCode": true,
"args": ["-A", "app.celery", "worker", "-P", "gevent", "-c", "1", "--loglevel", "info", "-Q", "dataset,generation,mail"],
"envFile": "${workspaceFolder}/.env",
"env": {
"FLASK_APP": "app.py",
"FLASK_DEBUG": "1",
"GEVENT_SUPPORT": "True"
},
"console": "integratedTerminal"
},
{
"name": "Python: Flask",
"type": "python",
Expand Down
3 changes: 0 additions & 3 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ RUN apt-get update \
COPY --from=base /pkg /usr/local
COPY . /app/api/

RUN python -c "from transformers import GPT2TokenizerFast; GPT2TokenizerFast.from_pretrained('gpt2')"
ENV TRANSFORMERS_OFFLINE true

COPY docker/entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

Expand Down
34 changes: 20 additions & 14 deletions api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
if not os.environ.get("DEBUG") or os.environ.get("DEBUG").lower() != 'true':
from gevent import monkey
monkey.patch_all()
if os.environ.get("VECTOR_STORE") == 'milvus':
import grpc.experimental.gevent
grpc.experimental.gevent.init_gevent()
# if os.environ.get("VECTOR_STORE") == 'milvus':
import grpc.experimental.gevent
grpc.experimental.gevent.init_gevent()

import langchain
langchain.verbose = True

import time
import logging
Expand All @@ -18,9 +21,8 @@
from flask import Flask, request, Response
from flask_cors import CORS

from core.model_providers.providers import hosted
from extensions import ext_celery, ext_sentry, ext_redis, ext_login, ext_migrate, \
ext_database, ext_storage, ext_mail, ext_code_based_extension
ext_database, ext_storage, ext_mail, ext_code_based_extension, ext_hosting_provider
from extensions.ext_database import db
from extensions.ext_login import login_manager

Expand Down Expand Up @@ -79,8 +81,6 @@ def create_app(test_config=None) -> Flask:
register_blueprints(app)
register_commands(app)

hosted.init_app(app)

return app


Expand All @@ -95,6 +95,7 @@ def initialize_extensions(app):
ext_celery.init_app(app)
ext_login.init_app(app)
ext_mail.init_app(app)
ext_hosting_provider.init_app(app)
ext_sentry.init_app(app)


Expand All @@ -105,13 +106,18 @@ def load_user_from_request(request_from_flask_login):
if request.blueprint == 'console':
# Check if the user_id contains a dot, indicating the old format
auth_header = request.headers.get('Authorization', '')
if ' ' not in auth_header:
raise Unauthorized('Invalid Authorization header format. Expected \'Bearer <api-key>\' format.')
auth_scheme, auth_token = auth_header.split(None, 1)
auth_scheme = auth_scheme.lower()
if auth_scheme != 'bearer':
raise Unauthorized('Invalid Authorization header format. Expected \'Bearer <api-key>\' format.')

if not auth_header:
auth_token = request.args.get('_token')
if not auth_token:
raise Unauthorized('Invalid Authorization token.')
else:
if ' ' not in auth_header:
raise Unauthorized('Invalid Authorization header format. Expected \'Bearer <api-key>\' format.')
auth_scheme, auth_token = auth_header.split(None, 1)
auth_scheme = auth_scheme.lower()
if auth_scheme != 'bearer':
raise Unauthorized('Invalid Authorization header format. Expected \'Bearer <api-key>\' format.')

decoded = PassportService().verify(auth_token)
user_id = decoded.get('user_id')

Expand Down
28 changes: 15 additions & 13 deletions api/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@
from qdrant_client.http.models import TextIndexParams, TextIndexType, TokenizerType
from tqdm import tqdm
from flask import current_app, Flask
from langchain.embeddings import OpenAIEmbeddings
from werkzeug.exceptions import NotFound

from core.embedding.cached_embedding import CacheEmbedding
from core.index.index import IndexBuilder
from core.model_providers.model_factory import ModelFactory
from core.model_providers.models.embedding.openai_embedding import OpenAIEmbedding
from core.model_providers.models.entity.model_params import ModelType
from core.model_providers.providers.hosted import hosted_model_providers
from core.model_providers.providers.openai_provider import OpenAIProvider
from core.model_manager import ModelManager
from core.model_runtime.entities.model_entities import ModelType
from libs.password import password_pattern, valid_password, hash_password
from libs.helper import email as email_validate
from extensions.ext_database import db
Expand Down Expand Up @@ -327,26 +323,32 @@ def create_qdrant_indexes():
except NotFound:
break

model_manager = ModelManager()

page += 1
for dataset in datasets:
if dataset.index_struct_dict:
if dataset.index_struct_dict['type'] != 'qdrant':
try:
click.echo('Create dataset qdrant index: {}'.format(dataset.id))
try:
embedding_model = ModelFactory.get_embedding_model(
embedding_model = model_manager.get_model_instance(
tenant_id=dataset.tenant_id,
model_provider_name=dataset.embedding_model_provider,
model_name=dataset.embedding_model
provider=dataset.embedding_model_provider,
model_type=ModelType.TEXT_EMBEDDING,
model=dataset.embedding_model

)
except Exception:
try:
embedding_model = ModelFactory.get_embedding_model(
tenant_id=dataset.tenant_id
embedding_model = model_manager.get_default_model_instance(
tenant_id=dataset.tenant_id,
model_type=ModelType.TEXT_EMBEDDING,
)
dataset.embedding_model = embedding_model.name
dataset.embedding_model_provider = embedding_model.model_provider.provider_name
dataset.embedding_model = embedding_model.model
dataset.embedding_model_provider = embedding_model.provider
except Exception:

provider = Provider(
id='provider_id',
tenant_id=dataset.tenant_id,
Expand Down
2 changes: 1 addition & 1 deletion api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def __init__(self):
# ------------------------
# General Configurations.
# ------------------------
self.CURRENT_VERSION = "0.3.34"
self.CURRENT_VERSION = "0.4.0"
self.COMMIT_SHA = get_env('COMMIT_SHA')
self.EDITION = "SELF_HOSTED"
self.DEPLOY_ENV = get_env('DEPLOY_ENV')
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/console/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from .datasets import datasets, datasets_document, datasets_segments, file, hit_testing, data_source

# Import workspace controllers
from .workspace import workspace, members, providers, model_providers, account, tool_providers, models
from .workspace import workspace, members, model_providers, account, tool_providers, models

# Import explore controllers
from .explore import installed_app, recommended_app, completion, conversation, message, parameter, saved_message, audio
Expand Down
Loading
Loading