Parcourir la source

Fix: add prologue to api. (#9322)

### What problem does this PR solve?


### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.20.1
Kevin Hu il y a 2 mois
Parent
révision
a02ca16260
Aucun compte lié à l'adresse e-mail de l'auteur

+ 3
- 2
api/apps/canvas_app.py Voir le fichier

@@ -28,7 +28,7 @@ from api.db import FileType
from api.db.services.canvas_service import CanvasTemplateService, UserCanvasService, API4ConversationService
from api.db.services.document_service import DocumentService
from api.db.services.file_service import FileService
from api.db.services.user_service import TenantService
from api.db.services.user_service import TenantService, UserTenantService
from api.db.services.user_canvas_version import UserCanvasVersionService
from api.settings import RetCode
from api.utils import get_uuid
@@ -101,7 +101,8 @@ def save():
@login_required
def get(canvas_id):
e, c = UserCanvasService.get_by_tenant_id(canvas_id)
if not e or c["user_id"] != current_user.id:
tids = [t.tenant_id for t in UserTenantService.query(user_id=current_user.id)]
if not e or (c["user_id"] != current_user.id and c["user_id"] not in tids):
return get_data_error_result(message="canvas not found.")
return get_json_result(data=c)


+ 1
- 0
api/apps/sdk/session.py Voir le fichier

@@ -862,5 +862,6 @@ def begin_inputs(tenant_id, agent_id):
"title": cvs.title,
"avatar": cvs.avatar,
"inputs": canvas.get_component_input_form("begin"),
"prologue": canvas.get_prologue()
}
)

+ 1
- 0
api/db/services/canvas_service.py Voir le fichier

@@ -172,6 +172,7 @@ def completion(tenant_id, agent_id, session_id=None, **kwargs):
conv.message.append({"role": "assistant", "content": txt, "created_at": time.time(), "id": message_id})
conv.reference = canvas.get_reference()
conv.errors = canvas.error
conv.dsl = str(canvas)
conv = conv.to_dict()
API4ConversationService.append_message(conv["id"], conv)


+ 3
- 2
api/db/services/llm_service.py Voir le fichier

@@ -225,10 +225,11 @@ class TenantLLMService(CommonService):
if llm_id == llm["llm_name"]:
return llm["model_type"].split(",")[-1]

for llm in TenantLLMService.query(llm_name=llm_id):
for llm in LLMService.query(llm_name=llm_id):
return llm.model_type

for llm in LLMService.query(llm_name=llm_id):
llm = TenantLLMService.get_or_none(llm_name=llm_id)
if llm:
return llm.model_type
for llm in TenantLLMService.query(llm_name=llm_id):
return llm.model_type

Chargement…
Annuler
Enregistrer