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

feat: llm ops tracing #5476

Closed
wants to merge 349 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
349 commits
Select commit Hold shift + click to select a range
7b23a9d
feat: show file extenstion
iamjoel Jun 4, 2024
4936499
Merge branch 'feat/document-support-rename' into deploy/dev
iamjoel Jun 4, 2024
1fa12b6
Merge branch 'main' into feat/firecrawl-fe
iamjoel Jun 4, 2024
10e0f43
chore: crawel text
iamjoel Jun 4, 2024
43b169b
DocumentRenameApi http method
JohnJyong Jun 4, 2024
f82f81f
Merge branch 'feat/rename-document' into deploy/dev
JohnJyong Jun 4, 2024
df97c6b
feat: firecrawl no data
iamjoel Jun 4, 2024
5aef25b
feat: handle show config firecrawl
iamjoel Jun 4, 2024
437e287
feat: add cooldown timer
nite-knite Jun 4, 2024
18d517a
Merge branch 'feat/model-load-balancing' into deploy/dev
nite-knite Jun 4, 2024
fdae549
feat: firecrawl header
iamjoel Jun 4, 2024
b37a636
fix bugs
takatost Jun 4, 2024
dea04ad
Merge branch 'refs/heads/feat/load-balancing' into deploy/dev
takatost Jun 4, 2024
3481c75
fix provider managed position
takatost Jun 4, 2024
10ecc9d
Merge branch 'refs/heads/feat/load-balancing' into deploy/dev
takatost Jun 4, 2024
633c0c8
feat: render with model load balancing modal with context
nite-knite Jun 4, 2024
542f22c
feat: update load balancing entry modal title
nite-knite Jun 4, 2024
230d9e5
Merge branch 'feat/model-load-balancing' into deploy/dev
nite-knite Jun 4, 2024
9311376
just add
iamjoel Jun 4, 2024
7cb374b
feat: update model load balancing entry modal form
nite-knite Jun 4, 2024
a8a054e
Merge branch 'feat/model-load-balancing' into deploy/dev
nite-knite Jun 4, 2024
baad0a7
options temp
iamjoel Jun 5, 2024
f36763f
note editor
zxhlyh Jun 5, 2024
5a0bfb6
feat: options main
iamjoel Jun 5, 2024
b4a1089
feat: option styles
iamjoel Jun 5, 2024
446f24c
feat: valid crawl options
iamjoel Jun 5, 2024
33d1533
feat: error info
iamjoel Jun 5, 2024
a278e92
feat: crawl options struct
iamjoel Jun 5, 2024
67322e7
note editor
zxhlyh Jun 5, 2024
0c222db
Merge branch 'main' into feat/workflow-add-note-node
zxhlyh Jun 5, 2024
eff80c8
feat: scrawl loading
iamjoel Jun 5, 2024
0448c49
feat: result
iamjoel Jun 5, 2024
cdfc6f9
Merge branch 'main' into feat/workflow-add-note-node
zxhlyh Jun 6, 2024
c8294ac
feat: crawl result
iamjoel Jun 6, 2024
4aaa6fa
feat: add login by mail evn
iamjoel Jun 6, 2024
0f5f115
feat: use email login
iamjoel Jun 6, 2024
dde6eab
just add
iamjoel Jun 6, 2024
74c24cc
feat: handle preview
iamjoel Jun 6, 2024
b9349b2
add total and current page number
JohnJyong Jun 6, 2024
1d3dc21
feat: finish step one
iamjoel Jun 6, 2024
042bc4f
feat: step two
iamjoel Jun 6, 2024
7ba0332
Merge branch 'main' into feat/firecrawl-data-source
JohnJyong Jun 6, 2024
131f152
merge migration
JohnJyong Jun 6, 2024
207fb6f
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 6, 2024
ce6e738
Merge branch 'main' into feat/firecrawl-fe
iamjoel Jun 6, 2024
dcf9882
feat: list page
iamjoel Jun 6, 2024
c9dda6e
feat: config firecrawl main
iamjoel Jun 6, 2024
a1e73bb
chore: config i18n
iamjoel Jun 6, 2024
05674c5
optimize firecrawl error msg
JohnJyong Jun 6, 2024
8a7b142
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 6, 2024
980ce12
feat: fetch and remove
iamjoel Jun 6, 2024
1ce9844
optimize firecrawl error msg
JohnJyong Jun 6, 2024
2ad4e2f
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 6, 2024
43f4e3a
optimize firecrawl error msg
JohnJyong Jun 6, 2024
2715a5a
optimize firecrawl error msg
JohnJyong Jun 6, 2024
5b711df
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 6, 2024
637546a
feat: crawl api
iamjoel Jun 7, 2024
06764b2
add delete binding
JohnJyong Jun 7, 2024
58c5034
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 7, 2024
a5f2b4a
feat: firecrawel init datasets
iamjoel Jun 7, 2024
e10c625
add delete binding
JohnJyong Jun 7, 2024
005bf8c
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 7, 2024
2e3b900
feat: handle error show
iamjoel Jun 7, 2024
ead40f6
add delete binding
JohnJyong Jun 7, 2024
d7a1b7c
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 7, 2024
cd01ff7
feat: handle prossed info
iamjoel Jun 7, 2024
923cef1
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 7, 2024
649a63a
chore: remove popup
iamjoel Jun 7, 2024
fb7842e
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 7, 2024
6e86c73
fix: process show error
iamjoel Jun 7, 2024
6c238d8
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 7, 2024
8e8418c
fix: other error status
iamjoel Jun 7, 2024
44ca9f6
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 7, 2024
be91a90
fix firecrawl issue
JohnJyong Jun 7, 2024
6dd4aec
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 7, 2024
592f795
chore: add only_main_content to api
iamjoel Jun 7, 2024
537f7ec
chore: add only_main_content to api
iamjoel Jun 7, 2024
affbcf4
note editor
zxhlyh Jun 7, 2024
bf6b6eb
feat: add dataset delete endpoint (#5035)
perzeuss Jun 7, 2024
f75a4a5
Merge branch 'main' into feat/workflow-add-note-node
zxhlyh Jun 11, 2024
1f31a85
fix: api success message
iamjoel Jun 11, 2024
5870e5f
fix firecrawl issue
JohnJyong Jun 11, 2024
a0583a7
fix: added key not refresh data
iamjoel Jun 11, 2024
419b715
fix firecrawl issue
JohnJyong Jun 11, 2024
06768db
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 11, 2024
4a56405
chore: add loading text
iamjoel Jun 11, 2024
812cbc8
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 11, 2024
36ef4d9
feat: web scrapy sync
iamjoel Jun 11, 2024
d263f2a
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 11, 2024
658c9e1
feat: add crawl time
iamjoel Jun 11, 2024
fc42124
fix firecrawl issue
JohnJyong Jun 11, 2024
871baa2
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 11, 2024
b40006f
Merge remote-tracking branch 'origin/deploy/dev' into deploy/dev
JohnJyong Jun 11, 2024
251a199
feat: help link url
iamjoel Jun 11, 2024
d1c86bc
fix: handle crawl error
iamjoel Jun 11, 2024
a43c301
feat: always can change options
iamjoel Jun 11, 2024
a35335d
chore: split options from other painel
iamjoel Jun 11, 2024
9ed2ba3
fix: popover pos loc
iamjoel Jun 11, 2024
2aa9512
fix: apps not found to app list page
iamjoel Jun 11, 2024
306c449
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 11, 2024
6a6a950
chore: remove for test data
iamjoel Jun 11, 2024
2cc535f
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 11, 2024
66808f8
note editor
zxhlyh Jun 11, 2024
35d3912
fix: websit hover chore
iamjoel Jun 12, 2024
b3fd664
chore: code beaty
iamjoel Jun 12, 2024
e4e26e5
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 12, 2024
777674c
fix: time cosuming not right
iamjoel Jun 12, 2024
6c50696
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 12, 2024
8543457
feat: edit page add web crawl
iamjoel Jun 12, 2024
dc0b9e2
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 12, 2024
6b61693
Merge branch 'main' into feat/firecrawl-fe
iamjoel Jun 12, 2024
77cff58
note editor
zxhlyh Jun 12, 2024
3776aa5
Merge branch 'main' into feat/workflow-add-note-node
zxhlyh Jun 12, 2024
59a50bc
chore: remove login by password
iamjoel Jun 12, 2024
b2a7680
chore: remove login by password
iamjoel Jun 12, 2024
cbf5032
fix: first error not show error status
iamjoel Jun 12, 2024
5a80b54
note editor
zxhlyh Jun 12, 2024
77b2924
Merge branch 'main' into feat/workflow-add-note-node
zxhlyh Jun 12, 2024
0e3deb5
feat: tracing panel
iamjoel Jun 12, 2024
17a9b8d
feat: 18n and config btn
iamjoel Jun 12, 2024
b6a3f64
chore: fold btn
iamjoel Jun 12, 2024
0c6b71b
note node
zxhlyh Jun 12, 2024
1f60ae9
fix firecrawl issue
JohnJyong Jun 12, 2024
cef123d
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 12, 2024
7dcae09
Merge branch 'main' into feat/workflow-add-note-node
zxhlyh Jun 13, 2024
e2212bd
fix firecrawl issue
JohnJyong Jun 13, 2024
c402fff
feat: unfold panel
iamjoel Jun 13, 2024
901e3ba
Merge branch 'main' into feat/firecrawl-data-source
JohnJyong Jun 13, 2024
cbb4be6
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 13, 2024
626b6d0
feat: split config button
iamjoel Jun 13, 2024
c7ea324
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 13, 2024
b5b2868
chore: remove log
iamjoel Jun 13, 2024
186ee4f
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 13, 2024
049dae0
feat: popup struct
iamjoel Jun 13, 2024
bc3d07a
note node
zxhlyh Jun 13, 2024
017371b
Merge branch 'main' into feat/workflow-add-note-node
zxhlyh Jun 13, 2024
81ac5a7
feat: add error message
iamjoel Jun 13, 2024
fd43d91
fix: step two detect dataset type error
iamjoel Jun 13, 2024
e72f0c8
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 13, 2024
f85d87e
missing file
iamjoel Jun 13, 2024
b9635c9
note node
zxhlyh Jun 13, 2024
3a7447b
Merge branch 'main' into feat/workflow-add-note-node
zxhlyh Jun 13, 2024
2cd1a22
Merge branch 'feat/workflow-add-note-node' into deploy/dev
zxhlyh Jun 13, 2024
5be6966
fix: note editor
zxhlyh Jun 13, 2024
863a4fb
Merge branch 'feat/workflow-add-note-node' into deploy/dev
zxhlyh Jun 13, 2024
0515542
add aws s3 iam check
JohnJyong Jun 13, 2024
0b93bf9
Merge branch 'feat/aws-s3-iam-auth-check' into deploy/dev
JohnJyong Jun 13, 2024
f718b17
add aws s3 iam check
JohnJyong Jun 13, 2024
6c194a6
chore(deps): bump authlib from 1.2.0 to 1.3.1 in /api
dependabot[bot] Jun 13, 2024
0bcb28e
update requirements.txt
takatost Jun 13, 2024
3822491
merge
takatost Jun 13, 2024
ecb9b50
fix
zxhlyh Jun 14, 2024
f7b635f
Merge branch 'feat/workflow-add-note-node' into deploy/dev
zxhlyh Jun 14, 2024
d26f1a8
chore: change field loc
iamjoel Jun 14, 2024
d67e3bf
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 14, 2024
92f4631
fix
zxhlyh Jun 14, 2024
5d69242
Merge branch 'feat/workflow-add-note-node' into deploy/dev
zxhlyh Jun 14, 2024
51539ce
feat: tracing state
iamjoel Jun 14, 2024
823b077
fix
zxhlyh Jun 14, 2024
1e7da3d
Merge branch 'feat/workflow-add-note-node' into deploy/dev
zxhlyh Jun 14, 2024
a725daa
feat: tracing des and i18n
iamjoel Jun 14, 2024
4faa03d
Merge branch 'main' into deploy/dev
JzoNgKVO Jun 14, 2024
9a15bb9
Merge branch 'main' into feat/workflow-add-note-node
zxhlyh Jun 14, 2024
8285fd3
add aws s3 iam check
JohnJyong Jun 14, 2024
4bf20f6
Merge branch 'feat/aws-s3-iam-auth-check' into deploy/dev
JohnJyong Jun 14, 2024
2d9742c
feat: tracing panel
iamjoel Jun 14, 2024
ea0930c
feat: fold btn tooltip
iamjoel Jun 14, 2024
545f142
fix
zxhlyh Jun 14, 2024
7ae7437
Merge branch 'feat/workflow-add-note-node' into deploy/dev
zxhlyh Jun 14, 2024
7c7f624
feat: choosed provider status
iamjoel Jun 14, 2024
fc688eb
fix
zxhlyh Jun 14, 2024
03d0af9
Merge branch 'feat/workflow-add-note-node' into deploy/dev
zxhlyh Jun 14, 2024
99f514a
Merge branch 'main' into feat/workflow-add-note-node
zxhlyh Jun 14, 2024
d77923e
feat: hide extra error
iamjoel Jun 14, 2024
c0c4019
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 14, 2024
52a38a5
fix
zxhlyh Jun 14, 2024
2dd603d
Merge branch 'feat/workflow-add-note-node' into deploy/dev
zxhlyh Jun 14, 2024
11a31f0
fix
zxhlyh Jun 14, 2024
8af8328
Merge branch 'feat/workflow-add-note-node' into deploy/dev
zxhlyh Jun 14, 2024
aa77f68
fix
zxhlyh Jun 14, 2024
0cff42a
Merge branch 'feat/workflow-add-note-node' into deploy/dev
zxhlyh Jun 14, 2024
47dafa9
feat: config provider struct
iamjoel Jun 14, 2024
de7167e
fix
zxhlyh Jun 14, 2024
8576a97
Merge branch 'feat/workflow-add-note-node' into deploy/dev
zxhlyh Jun 14, 2024
4c31a33
add crawl to s3 service
JohnJyong Jun 14, 2024
847b3fc
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 14, 2024
231b8f6
fix: note editor italic
zxhlyh Jun 14, 2024
c12cb8b
resolve conflict
zxhlyh Jun 14, 2024
8cf55c1
temp
iamjoel Jun 14, 2024
240c732
add crawl to s3 service
JohnJyong Jun 14, 2024
6b03d7c
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 14, 2024
06fe0f4
Merge branch 'main' into feat/firecrawl-data-source
JohnJyong Jun 14, 2024
d842ea1
add crawl to s3 service
JohnJyong Jun 14, 2024
da83e24
chore: max depth optional
iamjoel Jun 14, 2024
05a612a
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 14, 2024
a85d220
feat: change doc link
iamjoel Jun 14, 2024
04eb0a5
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 14, 2024
233c9e9
add crawl to s3 service
JohnJyong Jun 14, 2024
bea2557
lint
JohnJyong Jun 14, 2024
66a73f7
lint
JohnJyong Jun 14, 2024
d96562d
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 14, 2024
867f17b
lint
JohnJyong Jun 14, 2024
15b5521
Merge branch 'feat/firecrawl-data-source' into deploy/dev
JohnJyong Jun 14, 2024
6be340c
fix: setting firecrawl error
iamjoel Jun 14, 2024
b0dc517
Merge branch 'feat/firecrawl-fe' into deploy/dev
iamjoel Jun 14, 2024
901670f
chore: upgrade next to 14.1.1
iamjoel Jun 17, 2024
2a35dbc
mrege
iamjoel Jun 17, 2024
e2ca7d3
Merge branch 'main' into feat/tracing-fe
iamjoel Jun 17, 2024
4842f1d
Merge branch 'main' into deploy/dev
iamjoel Jun 17, 2024
69533fb
feat: dialog i18n
iamjoel Jun 17, 2024
c856e74
feat: remove dialog i18n
iamjoel Jun 17, 2024
48760e8
feat: page header to comp
iamjoel Jun 18, 2024
d14bc6b
feat: detail config
iamjoel Jun 18, 2024
ee039fb
feat: add llm ops tracing
ZhouhaoJiang Jun 16, 2024
ebe8012
feat: add remove tracing app
ZhouhaoJiang Jun 17, 2024
79867d3
feat: update trace table
ZhouhaoJiang Jun 17, 2024
32b555c
feat: change table struct
ZhouhaoJiang Jun 18, 2024
0370fb6
Merge remote-tracking branch 'origin/main' into feat/llm-ops-tracing
ZhouhaoJiang Jun 18, 2024
0ec3b99
feat: change TraceAppConfigApi request type patch
ZhouhaoJiang Jun 18, 2024
809411c
Merge branch 'refs/heads/feat/llm-ops-tracing' into deploy/dev
ZhouhaoJiang Jun 18, 2024
f32f587
feat: tracing status enabled
iamjoel Jun 18, 2024
8e6ffd3
feat: create and add config
iamjoel Jun 18, 2024
aa2bdd0
feat: configged sync to panel
iamjoel Jun 18, 2024
3560b2c
feat: handle config actrive
iamjoel Jun 18, 2024
c4a611c
feat: in use label
iamjoel Jun 18, 2024
2953be5
feat: different choose status
iamjoel Jun 18, 2024
a848260
feat: update default reply when config is none
ZhouhaoJiang Jun 18, 2024
2156a34
Merge branch 'refs/heads/feat/llm-ops-tracing' into deploy/dev
ZhouhaoJiang Jun 18, 2024
273179b
feat: can crud
iamjoel Jun 18, 2024
ff17d33
chore: save and update
iamjoel Jun 18, 2024
365ede3
Merge branch 'feat/tracing-fe' into deploy/dev
iamjoel Jun 18, 2024
757b8cf
fix: advanced chat trace error
ZhouhaoJiang Jun 19, 2024
3c1593b
Merge branch 'refs/heads/feat/llm-ops-tracing' into deploy/dev
ZhouhaoJiang Jun 19, 2024
14b5f63
feat: add llm ops tracing
ZhouhaoJiang Jun 16, 2024
e61d9d5
feat: add remove tracing app
ZhouhaoJiang Jun 17, 2024
429fe5c
feat: update trace table
ZhouhaoJiang Jun 17, 2024
6f53b75
feat: change table struct
ZhouhaoJiang Jun 18, 2024
4ef224a
feat: change TraceAppConfigApi request type patch
ZhouhaoJiang Jun 18, 2024
c9a36e6
feat: update default reply when config is none
ZhouhaoJiang Jun 18, 2024
4d41ae7
fix: advanced chat trace error
ZhouhaoJiang Jun 19, 2024
90b1c65
Merge branch 'refs/heads/deploy/dev' into feat/llm-ops-tracing
ZhouhaoJiang Jun 19, 2024
a70ace8
feat: add trace ops api check
ZhouhaoJiang Jun 19, 2024
c7bd901
fix: uuid error
ZhouhaoJiang Jun 19, 2024
7221f10
feat: update workflow trace conversation_id
ZhouhaoJiang Jun 19, 2024
423bb4c
feat: format input and out
ZhouhaoJiang Jun 20, 2024
f9c9efe
Merge branch 'refs/heads/main' into feat/llm-ops-tracing
ZhouhaoJiang Jun 20, 2024
4e13f6e
feat: add ops trace encrypt_config decrypt_config obfuscate_config
ZhouhaoJiang Jun 20, 2024
c38fd13
feat: generate tracing_instance in app_generator
ZhouhaoJiang Jun 21, 2024
96fd562
Merge branch 'refs/heads/main' into feat/llm-ops-tracing
ZhouhaoJiang Jun 21, 2024
2e3aa5d
feat: update down_revision
ZhouhaoJiang Jun 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,4 @@ WORKFLOW_CALL_MAX_DEPTH=5
# App configuration
APP_MAX_EXECUTION_TIME=1200


1 change: 1 addition & 0 deletions api/controllers/console/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
generator,
message,
model_config,
ops_trace,
site,
statistic,
workflow,
Expand Down
40 changes: 35 additions & 5 deletions api/controllers/console/app/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
import uuid

from flask_login import current_user
Expand All @@ -9,17 +8,14 @@
from controllers.console.app.wraps import get_app_model
from controllers.console.setup import setup_required
from controllers.console.wraps import account_initialization_required, cloud_edition_billing_resource_check
from core.tools.tool_manager import ToolManager
from core.tools.utils.configuration import ToolParameterConfigurationManager
from fields.app_fields import (
app_detail_fields,
app_detail_fields_with_site,
app_pagination_fields,
)
from libs.login import login_required
from models.model import App, AppMode, AppModelConfig
from services.app_service import AppService
from services.tag_service import TagService
from services.ops_trace.ops_trace_service import OpsTraceService

ALLOW_CREATE_APP_MODES = ['chat', 'agent-chat', 'advanced-chat', 'workflow', 'completion']

Expand Down Expand Up @@ -286,6 +282,39 @@ def post(self, app_model):
return app_model


class AppTraceApi(Resource):
@setup_required
@login_required
@account_initialization_required
def get(self, app_id):
"""Get app trace"""
app_trace_config = OpsTraceService.get_app_tracing_config(
app_id=app_id
)

return app_trace_config

@setup_required
@login_required
@account_initialization_required
def post(self, app_id):
# add app trace
if not current_user.is_admin_or_owner:
raise Forbidden()
parser = reqparse.RequestParser()
parser.add_argument('enabled', type=bool, required=True, location='json')
parser.add_argument('tracing_provider', type=str, required=True, location='json')
args = parser.parse_args()

OpsTraceService.update_app_tracing_config(
app_id=app_id,
enabled=args['enabled'],
tracing_provider=args['tracing_provider'],
)

return {"result": "success"}


api.add_resource(AppListApi, '/apps')
api.add_resource(AppImportApi, '/apps/import')
api.add_resource(AppApi, '/apps/<uuid:app_id>')
Expand All @@ -295,3 +324,4 @@ def post(self, app_model):
api.add_resource(AppIconApi, '/apps/<uuid:app_id>/icon')
api.add_resource(AppSiteStatus, '/apps/<uuid:app_id>/site-enable')
api.add_resource(AppApiStatus, '/apps/<uuid:app_id>/api-enable')
api.add_resource(AppTraceApi, '/apps/<uuid:app_id>/trace')
12 changes: 12 additions & 0 deletions api/controllers/console/app/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,15 @@ class DraftWorkflowNotSync(BaseHTTPException):
error_code = 'draft_workflow_not_sync'
description = "Workflow graph might have been modified, please refresh and resubmit."
code = 400


class TracingConfigNotExist(BaseHTTPException):
error_code = 'trace_config_not_exist'
description = "Trace config not exist."
code = 400


class TracingConfigIsExist(BaseHTTPException):
error_code = 'trace_config_is_exist'
description = "Trace config is exist."
code = 400
99 changes: 99 additions & 0 deletions api/controllers/console/app/ops_trace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
from flask_restful import Resource, reqparse

from controllers.console import api
from controllers.console.app.error import TracingConfigIsExist, TracingConfigNotExist
from controllers.console.setup import setup_required
from controllers.console.wraps import account_initialization_required
from libs.login import login_required
from services.ops_trace.ops_trace_service import OpsTraceService


class TraceAppConfigApi(Resource):
"""
Manage trace app configurations
"""

@setup_required
@login_required
@account_initialization_required
def get(self, app_id):
parser = reqparse.RequestParser()
parser.add_argument('tracing_provider', type=str, required=True, location='args')
args = parser.parse_args()

try:
trace_config = OpsTraceService.get_tracing_app_config(
app_id=app_id, tracing_provider=args['tracing_provider']
)
if not trace_config:
return {"has_not_configured": True}
return trace_config
except Exception as e:
raise e

@setup_required
@login_required
@account_initialization_required
def post(self, app_id):
"""Create a new trace app configuration"""
parser = reqparse.RequestParser()
parser.add_argument('tracing_provider', type=str, required=True, location='json')
parser.add_argument('tracing_config', type=dict, required=True, location='json')
args = parser.parse_args()

try:
result = OpsTraceService.create_tracing_app_config(
app_id=app_id,
tracing_provider=args['tracing_provider'],
tracing_config=args['tracing_config']
)
if not result:
raise TracingConfigIsExist()
return {"result": "success"}
except Exception as e:
raise e

@setup_required
@login_required
@account_initialization_required
def patch(self, app_id):
"""Update an existing trace app configuration"""
parser = reqparse.RequestParser()
parser.add_argument('tracing_provider', type=str, required=True, location='json')
parser.add_argument('tracing_config', type=dict, required=True, location='json')
args = parser.parse_args()

try:
result = OpsTraceService.update_tracing_app_config(
app_id=app_id,
tracing_provider=args['tracing_provider'],
tracing_config=args['tracing_config']
)
if not result:
raise TracingConfigNotExist()
return {"result": "success"}
except Exception as e:
raise e

@setup_required
@login_required
@account_initialization_required
def delete(self, app_id):
"""Delete an existing trace app configuration"""
parser = reqparse.RequestParser()
parser.add_argument('tracing_provider', type=str, required=True, location='args')
args = parser.parse_args()

try:
result = OpsTraceService.delete_tracing_app_config(
app_id=app_id,
tracing_provider=args['tracing_provider']
)
if not result:
raise TracingConfigNotExist()
return {"result": "success"}
except Exception as e:
raise e


api.add_resource(TraceAppConfigApi, '/apps/<uuid:app_id>/trace-config')
1 change: 1 addition & 0 deletions api/controllers/console/datasets/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,4 @@ class DatasetInUseError(BaseHTTPException):
error_code = 'dataset_in_use'
description = "The dataset is being used by some apps. Please remove the dataset from the apps before deleting it."
code = 409

57 changes: 35 additions & 22 deletions api/core/agent/cot_agent_runner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from abc import ABC, abstractmethod
from collections.abc import Generator
from typing import Union
from typing import Optional, Union

from core.agent.base_agent_runner import BaseAgentRunner
from core.agent.entities import AgentScratchpadUnit
Expand All @@ -20,6 +20,7 @@
from core.tools.tool.tool import Tool
from core.tools.tool_engine import ToolEngine
from models.model import Message
from services.ops_trace.base_trace_instance import BaseTraceInstance


class CotAgentRunner(BaseAgentRunner, ABC):
Expand All @@ -31,17 +32,21 @@ class CotAgentRunner(BaseAgentRunner, ABC):
_query: str = None
_prompt_messages_tools: list[PromptMessage] = None

def run(self, message: Message,
query: str,
inputs: dict[str, str],
) -> Union[Generator, LLMResult]:
def run(
self, message: Message,
query: str,
inputs: dict[str, str],
) -> Union[Generator, LLMResult]:
"""
Run Cot agent application
"""
app_generate_entity = self.application_generate_entity
self._repack_app_generate_entity(app_generate_entity)
self._init_react_state(query)

# get tracing instance
tracing_instance = app_generate_entity.tracing_instance

# check model mode
if 'Observation' not in app_generate_entity.model_conf.stop:
if app_generate_entity.model_conf.provider not in self._ignore_observation_providers:
Expand Down Expand Up @@ -183,7 +188,7 @@ def increase_usage(final_llm_usage_dict: dict[str, LLMUsage], usage: LLMUsage):
messages_ids=[],
llm_usage=usage_dict['usage']
)

if not scratchpad.is_final():
self.queue_manager.publish(QueueAgentThoughtEvent(
agent_thought_id=agent_thought.id
Expand All @@ -209,9 +214,10 @@ def increase_usage(final_llm_usage_dict: dict[str, LLMUsage], usage: LLMUsage):
function_call_state = True
# action is tool call, invoke tool
tool_invoke_response, tool_invoke_meta = self._handle_invoke_action(
action=scratchpad.action,
action=scratchpad.action,
tool_instances=tool_instances,
message_file_ids=message_file_ids
message_file_ids=message_file_ids,
tracing_instance=tracing_instance,
)
scratchpad.observation = tool_invoke_response
scratchpad.agent_response = tool_invoke_response
Expand All @@ -237,8 +243,7 @@ def increase_usage(final_llm_usage_dict: dict[str, LLMUsage], usage: LLMUsage):

# update prompt tool message
for prompt_tool in self._prompt_messages_tools:
self.update_prompt_message_tool(
tool_instances[prompt_tool.name], prompt_tool)
self.update_prompt_message_tool(tool_instances[prompt_tool.name], prompt_tool)

iteration_step += 1

Expand All @@ -257,12 +262,12 @@ def increase_usage(final_llm_usage_dict: dict[str, LLMUsage], usage: LLMUsage):

# save agent thought
self.save_agent_thought(
agent_thought=agent_thought,
agent_thought=agent_thought,
tool_name='',
tool_input={},
tool_invoke_meta={},
thought=final_answer,
observation={},
observation={},
answer=final_answer,
messages_ids=[]
)
Expand All @@ -275,14 +280,15 @@ def increase_usage(final_llm_usage_dict: dict[str, LLMUsage], usage: LLMUsage):
message=AssistantPromptMessage(
content=final_answer
),
usage=llm_usage['usage'] if llm_usage['usage'] else LLMUsage.empty_usage(
),
usage=llm_usage['usage'] if llm_usage['usage'] else LLMUsage.empty_usage(),
system_fingerprint=''
)), PublishFrom.APPLICATION_MANAGER)

def _handle_invoke_action(self, action: AgentScratchpadUnit.Action,
def _handle_invoke_action(self, action: AgentScratchpadUnit.Action,
tool_instances: dict[str, Tool],
message_file_ids: list[str]) -> tuple[str, ToolInvokeMeta]:
message_file_ids: list[str],
tracing_instance: Optional[BaseTraceInstance] = None
) -> tuple[str, ToolInvokeMeta]:
"""
handle invoke action
:param action: action
Expand All @@ -297,7 +303,7 @@ def _handle_invoke_action(self, action: AgentScratchpadUnit.Action,
if not tool_instance:
answer = f"there is not a tool named {tool_call_name}"
return answer, ToolInvokeMeta.error_instance(answer)

if isinstance(tool_call_args, str):
try:
tool_call_args = json.loads(tool_call_args)
Expand All @@ -312,14 +318,14 @@ def _handle_invoke_action(self, action: AgentScratchpadUnit.Action,
tenant_id=self.tenant_id,
message=self.message,
invoke_from=self.application_generate_entity.invoke_from,
agent_tool_callback=self.agent_callback
agent_tool_callback=self.agent_callback,
tracing_instance=tracing_instance,
)

# publish files
for message_file, save_as in message_files:
if save_as:
self.variables_pool.set_file(
tool_name=tool_call_name, value=message_file.id, name=save_as)
self.variables_pool.set_file(tool_name=tool_call_name, value=message_file.id, name=save_as)

# publish message file
self.queue_manager.publish(QueueMessageFileEvent(
Expand Down Expand Up @@ -350,15 +356,15 @@ def _fill_in_inputs_from_external_data_tools(self, instruction: str, inputs: dic
continue

return instruction

def _init_react_state(self, query) -> None:
"""
init agent scratchpad
"""
self._query = query
self._agent_scratchpad = []
self._historic_prompt_messages = self._organize_historic_prompt_messages()

@abstractmethod
def _organize_prompt_messages(self) -> list[PromptMessage]:
"""
Expand Down Expand Up @@ -390,6 +396,13 @@ def _organize_historic_prompt_messages(self, current_session_messages: list[Prom
scratchpads: list[AgentScratchpadUnit] = []
current_scratchpad: AgentScratchpadUnit = None

self.history_prompt_messages = AgentHistoryPromptTransform(
model_config=self.model_config,
prompt_messages=current_session_messages or [],
history_messages=self.history_prompt_messages,
memory=self.memory
).get_prompt()

for message in self.history_prompt_messages:
if isinstance(message, AssistantPromptMessage):
if not current_scratchpad:
Expand Down
4 changes: 4 additions & 0 deletions api/core/agent/fc_agent_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ def run(self,
}
final_answer = ''

# get tracing instance
tracing_instance = app_generate_entity.tracing_instance

def increase_usage(final_llm_usage_dict: dict[str, LLMUsage], usage: LLMUsage):
if not final_llm_usage_dict['usage']:
final_llm_usage_dict['usage'] = usage
Expand Down Expand Up @@ -243,6 +246,7 @@ def increase_usage(final_llm_usage_dict: dict[str, LLMUsage], usage: LLMUsage):
message=self.message,
invoke_from=self.application_generate_entity.invoke_from,
agent_tool_callback=self.agent_callback,
tracing_instance=tracing_instance
)
# publish files
for message_file, save_as in message_files:
Expand Down
Loading
Loading