mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: self-deployed LLM error, (#9217)
### What problem does this PR solve? Close #9197 Close #9145 ### Type of change - [x] Refactoring - [x] Bug fixing.
This commit is contained in:
@ -75,11 +75,13 @@ def retrieval(tenant_id):
|
|||||||
for c in ranks["chunks"]:
|
for c in ranks["chunks"]:
|
||||||
e, doc = DocumentService.get_by_id( c["doc_id"])
|
e, doc = DocumentService.get_by_id( c["doc_id"])
|
||||||
c.pop("vector", None)
|
c.pop("vector", None)
|
||||||
|
meta = getattr(doc, 'meta_fields', {})
|
||||||
|
meta["doc_id"] = c["doc_id"]
|
||||||
records.append({
|
records.append({
|
||||||
"content": c["content_with_weight"],
|
"content": c["content_with_weight"],
|
||||||
"score": c["similarity"],
|
"score": c["similarity"],
|
||||||
"title": c["docnm_kwd"],
|
"title": c["docnm_kwd"],
|
||||||
"metadata": getattr(doc, 'meta_fields', {})
|
"metadata": meta
|
||||||
})
|
})
|
||||||
|
|
||||||
return jsonify({"records": records})
|
return jsonify({"records": records})
|
||||||
|
|||||||
@ -173,7 +173,8 @@ 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.message.append({"role": "assistant", "content": txt, "created_at": time.time(), "id": message_id})
|
||||||
conv.reference = canvas.get_reference()
|
conv.reference = canvas.get_reference()
|
||||||
conv.errors = canvas.error
|
conv.errors = canvas.error
|
||||||
API4ConversationService.append_message(conv.id, conv.to_dict())
|
conv = conv.to_dict()
|
||||||
|
API4ConversationService.append_message(conv["id"], conv)
|
||||||
|
|
||||||
|
|
||||||
def completionOpenAI(tenant_id, agent_id, question, session_id=None, stream=True, **kwargs):
|
def completionOpenAI(tenant_id, agent_id, question, session_id=None, stream=True, **kwargs):
|
||||||
|
|||||||
@ -225,6 +225,9 @@ class TenantLLMService(CommonService):
|
|||||||
if llm_id == llm["llm_name"]:
|
if llm_id == llm["llm_name"]:
|
||||||
return llm["model_type"].split(",")[-1]
|
return llm["model_type"].split(",")[-1]
|
||||||
|
|
||||||
|
for llm in LLMService.query(llm_name=llm_id):
|
||||||
|
return llm.model_type
|
||||||
|
|
||||||
|
|
||||||
class LLMBundle:
|
class LLMBundle:
|
||||||
def __init__(self, tenant_id, llm_type, llm_name=None, lang="Chinese", **kwargs):
|
def __init__(self, tenant_id, llm_type, llm_name=None, lang="Chinese", **kwargs):
|
||||||
|
|||||||
@ -123,7 +123,7 @@ class RAGFlowS3:
|
|||||||
|
|
||||||
@use_prefix_path
|
@use_prefix_path
|
||||||
@use_default_bucket
|
@use_default_bucket
|
||||||
def put(self, bucket, fnm, binary):
|
def put(self, bucket, fnm, binary, **kwargs):
|
||||||
logging.debug(f"bucket name {bucket}; filename :{fnm}:")
|
logging.debug(f"bucket name {bucket}; filename :{fnm}:")
|
||||||
for _ in range(1):
|
for _ in range(1):
|
||||||
try:
|
try:
|
||||||
@ -140,7 +140,7 @@ class RAGFlowS3:
|
|||||||
|
|
||||||
@use_prefix_path
|
@use_prefix_path
|
||||||
@use_default_bucket
|
@use_default_bucket
|
||||||
def rm(self, bucket, fnm):
|
def rm(self, bucket, fnm, **kwargs):
|
||||||
try:
|
try:
|
||||||
self.conn.delete_object(Bucket=bucket, Key=fnm)
|
self.conn.delete_object(Bucket=bucket, Key=fnm)
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -148,7 +148,7 @@ class RAGFlowS3:
|
|||||||
|
|
||||||
@use_prefix_path
|
@use_prefix_path
|
||||||
@use_default_bucket
|
@use_default_bucket
|
||||||
def get(self, bucket, fnm):
|
def get(self, bucket, fnm, **kwargs):
|
||||||
for _ in range(1):
|
for _ in range(1):
|
||||||
try:
|
try:
|
||||||
r = self.conn.get_object(Bucket=bucket, Key=fnm)
|
r = self.conn.get_object(Bucket=bucket, Key=fnm)
|
||||||
@ -162,7 +162,7 @@ class RAGFlowS3:
|
|||||||
|
|
||||||
@use_prefix_path
|
@use_prefix_path
|
||||||
@use_default_bucket
|
@use_default_bucket
|
||||||
def obj_exist(self, bucket, fnm):
|
def obj_exist(self, bucket, fnm, **kwargs):
|
||||||
try:
|
try:
|
||||||
if self.conn.head_object(Bucket=bucket, Key=fnm):
|
if self.conn.head_object(Bucket=bucket, Key=fnm):
|
||||||
return True
|
return True
|
||||||
@ -174,7 +174,7 @@ class RAGFlowS3:
|
|||||||
|
|
||||||
@use_prefix_path
|
@use_prefix_path
|
||||||
@use_default_bucket
|
@use_default_bucket
|
||||||
def get_presigned_url(self, bucket, fnm, expires):
|
def get_presigned_url(self, bucket, fnm, expires, **kwargs):
|
||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
try:
|
try:
|
||||||
r = self.conn.generate_presigned_url('get_object',
|
r = self.conn.generate_presigned_url('get_object',
|
||||||
|
|||||||
Reference in New Issue
Block a user