Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
59ba46d2
Unverified
Commit
59ba46d2
authored
Feb 26, 2024
by
Yeuoly
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: sse
parent
3b55dc08
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
21 deletions
+7
-21
__init__.py
api/controllers/inner_api/__init__.py
+1
-1
model.py
api/controllers/inner_api/model.py
+0
-16
model_runner.py
api/core/app_runner/model_runner.py
+5
-3
completion_service.py
api/services/completion_service.py
+1
-1
No files found.
api/controllers/inner_api/__init__.py
View file @
59ba46d2
...
@@ -4,4 +4,4 @@ from libs.external_api import ExternalApi
...
@@ -4,4 +4,4 @@ from libs.external_api import ExternalApi
bp
=
Blueprint
(
'inner_api'
,
__name__
,
url_prefix
=
'/inner/api'
)
bp
=
Blueprint
(
'inner_api'
,
__name__
,
url_prefix
=
'/inner/api'
)
api
=
ExternalApi
(
bp
)
api
=
ExternalApi
(
bp
)
from
.
import
authorization
from
.
import
authorization
,
model_runtime
,
app
\ No newline at end of file
\ No newline at end of file
api/controllers/inner_api/model.py
deleted
100644 → 0
View file @
3b55dc08
from
flask_restful
import
Resource
from
controllers.console.setup
import
setup_required
from
controllers.inner_api
import
api
from
controllers.inner_api.wraps
import
inner_api_only
class
EnterpriseModelInvokeApi
(
Resource
):
"""Model invoke API for enterprise edition"""
@
setup_required
@
inner_api_only
def
post
(
self
):
pass
api
.
add_resource
(
EnterpriseModelInvokeApi
,
'/model/invoke'
)
\ No newline at end of file
api/core/app_runner/model_runner.py
View file @
59ba46d2
import
json
from
collections.abc
import
Generator
from
collections.abc
import
Generator
from
typing
import
Optional
,
Union
,
cast
from
typing
import
Optional
,
Union
,
cast
...
@@ -92,9 +94,9 @@ class ModelRunner:
...
@@ -92,9 +94,9 @@ class ModelRunner:
usage
.
currency
=
chunk
.
delta
.
usage
.
currency
usage
.
currency
=
chunk
.
delta
.
usage
.
currency
yield
jsonable_encoder
(
chunk
)
yield
'data: '
+
json
.
dumps
(
jsonable_encoder
(
chunk
))
+
'
\n\n
'
model_was_invoked
(
model_was_invoked
.
send
(
None
,
None
,
tenant_id
=
tenant_id
,
tenant_id
=
tenant_id
,
model_config
=
{
model_config
=
{
...
@@ -118,7 +120,7 @@ class ModelRunner:
...
@@ -118,7 +120,7 @@ class ModelRunner:
"""
"""
usage
=
response
.
usage
or
LLMUsage
.
empty_usage
()
usage
=
response
.
usage
or
LLMUsage
.
empty_usage
()
model_was_invoked
(
model_was_invoked
.
send
(
None
,
None
,
tenant_id
=
tenant_id
,
tenant_id
=
tenant_id
,
model_config
=
{
model_config
=
{
...
...
api/services/completion_service.py
View file @
59ba46d2
...
@@ -339,7 +339,7 @@ class CompletionService:
...
@@ -339,7 +339,7 @@ class CompletionService:
raise
QuotaExceededError
(
f
"Model provider {provider} quota exceeded."
)
raise
QuotaExceededError
(
f
"Model provider {provider} quota exceeded."
)
converted_tools
=
[]
converted_tools
=
[]
for
tool
in
tools
:
for
tool
in
tools
or
[]
:
converted_tools
.
append
(
PromptMessageTool
(
converted_tools
.
append
(
PromptMessageTool
(
name
=
tool
[
'name'
],
name
=
tool
[
'name'
],
description
=
tool
[
'description'
],
description
=
tool
[
'description'
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment