Merge branch 'main' into basic-ui

This commit is contained in:
ManishMadan2882
2025-01-09 02:22:43 +05:30
17 changed files with 244 additions and 172 deletions

View File

@@ -185,8 +185,13 @@ class SubmitFeedback(Resource):
),
"answer": fields.String(required=False, description="The AI answer"),
"feedback": fields.String(required=True, description="User feedback"),
"question_index":fields.Integer(required=True, description="The question number in that particular conversation"),
"conversation_id":fields.String(required=True, description="id of the particular conversation"),
"question_index": fields.Integer(
required=True,
description="The question number in that particular conversation",
),
"conversation_id": fields.String(
required=True, description="id of the particular conversation"
),
"api_key": fields.String(description="Optional API key"),
},
)
@@ -196,21 +201,24 @@ class SubmitFeedback(Resource):
)
def post(self):
data = request.get_json()
required_fields = [ "feedback","conversation_id","question_index"]
required_fields = ["feedback", "conversation_id", "question_index"]
missing_fields = check_required_fields(data, required_fields)
if missing_fields:
return missing_fields
try:
conversations_collection.update_one(
{"_id": ObjectId(data["conversation_id"]), f"queries.{data['question_index']}": {"$exists": True}},
{
"$set": {
f"queries.{data['question_index']}.feedback": data["feedback"]
}
}
)
{
"_id": ObjectId(data["conversation_id"]),
f"queries.{data['question_index']}": {"$exists": True},
},
{
"$set": {
f"queries.{data['question_index']}.feedback": data["feedback"]
}
},
)
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
@@ -253,11 +261,9 @@ class DeleteOldIndexes(Resource):
jsonify({"success": False, "message": "Missing required fields"}), 400
)
doc = sources_collection.find_one(
{"_id": ObjectId(source_id), "user": "local"}
)
doc = sources_collection.find_one({"_id": ObjectId(source_id), "user": "local"})
if not doc:
return make_response(jsonify({"status": "not found"}), 404)
return make_response(jsonify({"status": "not found"}), 404)
try:
if settings.VECTOR_STORE == "faiss":
shutil.rmtree(os.path.join(current_dir, "indexes", str(doc["_id"])))
@@ -271,7 +277,7 @@ class DeleteOldIndexes(Resource):
pass
except Exception as err:
return make_response(jsonify({"success": False, "error": str(err)}), 400)
sources_collection.delete_one({"_id": ObjectId(source_id)})
return make_response(jsonify({"success": True}), 200)
@@ -498,7 +504,9 @@ class PaginatedSources(Resource):
total_documents = sources_collection.count_documents(query)
total_pages = max(1, math.ceil(total_documents / rows_per_page))
page = min(max(1, page), total_pages) # add this to make sure page inbound is within the range
page = min(
max(1, page), total_pages
) # add this to make sure page inbound is within the range
sort_order = 1 if sort_order == "asc" else -1
skip = (page - 1) * rows_per_page
@@ -2098,4 +2106,3 @@ class DeleteTool(Resource):
return {"success": False, "error": str(err)}, 400
return {"success": True}, 200

View File

@@ -19,7 +19,7 @@ gunicorn==23.0.0
html2text==2024.2.26
javalang==0.13.0
jinja2==3.1.5
jiter==0.5.0
jiter==0.8.2
jmespath==1.0.1
joblib==1.4.2
jsonpatch==1.33
@@ -28,20 +28,20 @@ jsonschema==4.23.0
jsonschema-spec==0.2.4
jsonschema-specifications==2023.7.1
kombu==5.4.2
langchain==0.3.13
langchain-community==0.3.13
langchain-core==0.3.28
langchain==0.3.14
langchain-community==0.3.14
langchain-core==0.3.29
langchain-openai==0.2.14
langchain-text-splitters==0.3.4
langsmith==0.2.6
lazy-object-proxy==1.10.0
lxml==5.3.0
markupsafe==2.1.5
markupsafe==3.0.2
marshmallow==3.23.2
mpmath==1.3.0
multidict==6.1.0
mypy-extensions==1.0.0
networkx==3.3
networkx==3.4.2
numpy==2.2.1
openai==1.58.1
openapi-schema-validator==0.6.2
@@ -55,14 +55,14 @@ pathable==0.4.3
pillow==10.4.0
portalocker==2.10.1
prance==23.6.21.0
primp==0.6.3
primp==0.9.3
prompt-toolkit==3.0.47
protobuf==5.28.2
py==1.11.0
pydantic==2.9.2
pydantic-core==2.23.4
pydantic-settings==2.4.0
pymongo==4.8.0
pymongo==4.10.1
pypdf2==3.0.1
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
@@ -70,15 +70,15 @@ python-pptx==1.0.2
qdrant-client==1.11.0
redis==5.2.1
referencing==0.30.2
regex==2024.9.11
regex==2024.11.6
requests==2.32.3
retry==0.9.2
sentence-transformers==3.3.1
tiktoken==0.8.0
tokenizers==0.21.0
torch==2.4.1
torch==2.5.1
tqdm==4.66.5
transformers==4.47.0
transformers==4.47.1
typing-extensions==4.12.2
typing-inspect==0.9.0
tzdata==2024.2