mirror of
https://github.com/arc53/DocsGPT.git
synced 2026-02-21 11:51:24 +00:00
Merge branch 'main' of https://github.com/utin-francis-peter/DocsGPT into fix/traning-progress
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from flask import Blueprint, request, Response
|
from flask import Blueprint, request, Response
|
||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
@@ -198,6 +199,7 @@ def complete_stream(question, retriever, conversation_id, user_api_key):
|
|||||||
data = json.dumps({"type": "end"})
|
data = json.dumps({"type": "end"})
|
||||||
yield f"data: {data}\n\n"
|
yield f"data: {data}\n\n"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print("\033[91merr", str(e), file=sys.stderr)
|
||||||
data = json.dumps({"type": "error","error":"Please try again later. We apologize for any inconvenience.",
|
data = json.dumps({"type": "error","error":"Please try again later. We apologize for any inconvenience.",
|
||||||
"error_exception": str(e)})
|
"error_exception": str(e)})
|
||||||
yield f"data: {data}\n\n"
|
yield f"data: {data}\n\n"
|
||||||
@@ -282,13 +284,14 @@ def stream():
|
|||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
message = "Malformed request body"
|
message = "Malformed request body"
|
||||||
|
print("\033[91merr", str(message), file=sys.stderr)
|
||||||
return Response(
|
return Response(
|
||||||
error_stream_generate(message),
|
error_stream_generate(message),
|
||||||
status=400,
|
status=400,
|
||||||
mimetype="text/event-stream",
|
mimetype="text/event-stream",
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("err",str(e))
|
print("\033[91merr", str(e), file=sys.stderr)
|
||||||
message = e.args[0]
|
message = e.args[0]
|
||||||
status_code = 400
|
status_code = 400
|
||||||
# # Custom exceptions with two arguments, index 1 as status code
|
# # Custom exceptions with two arguments, index 1 as status code
|
||||||
|
|||||||
Reference in New Issue
Block a user