Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
isthaison authored Dec 9, 2024
2 parents 16d4aae + afe82fe commit 6e894cf
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ RUN --mount=type=cache,id=ragflow_apt,target=/var/cache/apt,sharing=locked \
fi; \
rm -f /etc/apt/apt.conf.d/docker-clean && \
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache && \
chmod 1777 /tmp && \
apt update && \
apt --no-install-recommends install -y ca-certificates && \
apt update && \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.deps
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This builds an image that contains the resources needed by Dockerfile
#
FROM ubuntu:22.04
FROM scratch

# Copy resources downloaded via download_deps.py
COPY chromedriver-linux64-121-0-6167-85 chrome-linux64-121-0-6167-85 cl100k_base.tiktoken libssl1.1_1.1.1f-1ubuntu2_amd64.deb libssl1.1_1.1.1f-1ubuntu2_arm64.deb tika-server-standard-3.0.0.jar tika-server-standard-3.0.0.jar.md5 libssl*.deb /
Expand Down
3 changes: 3 additions & 0 deletions api/apps/document_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ def change_parser():
# @login_required
def get_image(image_id):
try:
arr = image_id.split("-")
if len(arr) != 2:
return get_data_error_result(message="Image not found.")
bkt, nm = image_id.split("-")
response = flask.make_response(STORAGE_IMPL.get(bkt, nm))
response.headers.set('Content-Type', 'image/JPEG')
Expand Down
13 changes: 7 additions & 6 deletions api/db/services/canvas_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import json
from uuid import uuid4
from agent.canvas import Canvas
from api.db.db_models import DB, CanvasTemplate, UserCanvas
from api.db.db_models import DB, CanvasTemplate, UserCanvas, API4Conversation
from api.db.services.api_service import API4ConversationService
from api.db.services.common_service import CommonService
from api.db.services.conversation_service import structure_answer
Expand Down Expand Up @@ -65,23 +65,24 @@ def completion(tenant_id, agent_id, question, session_id=None, stream=True, **kw
"id": session_id,
"dialog_id": cvs.id,
"user_id": kwargs.get("user_id", ""),
"message": [{"role": "assistant", "content": canvas.get_prologue()}],
"source": "agent",
"dsl": json.loads(cvs.dsl)
}
API4ConversationService.save(**conv)
yield "data:" + json.dumps({"code": 0,
if canvas.get_preset_param():
yield "data:" + json.dumps({"code": 0,
"message": "",
"data": {
"session_id": session_id,
"answer": canvas.get_prologue(),
"answer": "",
"reference": [],
"param": canvas.get_preset_param()
}
},
ensure_ascii=False) + "\n\n"
yield "data:" + json.dumps({"code": 0, "message": "", "data": True}, ensure_ascii=False) + "\n\n"
return
yield "data:" + json.dumps({"code": 0, "message": "", "data": True}, ensure_ascii=False) + "\n\n"
return
conv = API4Conversation(**conv)
else:
session_id = session_id
e, conv = API4ConversationService.get_by_id(session_id)
Expand Down
2 changes: 2 additions & 0 deletions api/db/services/conversation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ def get_list(cls,dialog_id,page_number, items_per_page, orderby, desc, id , name

def structure_answer(conv, ans, message_id, session_id):
reference = ans["reference"]
if not isinstance(reference, dict):
reference = {}
temp_reference = deepcopy(ans["reference"])
if not conv.reference:
conv.reference.append(temp_reference)
Expand Down
3 changes: 2 additions & 1 deletion rag/llm/cv_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from io import BytesIO
import json
import requests
from transformers import GenerationConfig

from rag.nlp import is_english
from api.utils import get_uuid
Expand Down Expand Up @@ -510,6 +509,7 @@ def describe(self, image, max_tokens=2048):
return res.text,res.usage_metadata.total_token_count

def chat(self, system, history, gen_conf, image=""):
from transformers import GenerationConfig
if system:
history[-1]["content"] = system + history[-1]["content"] + "user query: " + history[-1]["content"]
try:
Expand All @@ -533,6 +533,7 @@ def chat(self, system, history, gen_conf, image=""):
return "**ERROR**: " + str(e), 0

def chat_streamly(self, system, history, gen_conf, image=""):
from transformers import GenerationConfig
if system:
history[-1]["content"] = system + history[-1]["content"] + "user query: " + history[-1]["content"]

Expand Down

0 comments on commit 6e894cf

Please sign in to comment.