Chat is working with new api
This commit is contained in:
parent
4919da84d6
commit
3fc6b1ab4d
@ -819,6 +819,7 @@ class ApiClient {
|
|||||||
|
|
||||||
const promise = new Promise<Types.ChatMessage[]>(async (resolve, reject) => {
|
const promise = new Promise<Types.ChatMessage[]>(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
|
const request = formatApiRequest(chatMessage);
|
||||||
const response = await fetch(`${this.baseUrl}/chat/sessions/${chatMessage.sessionId}/messages/stream`, {
|
const response = await fetch(`${this.baseUrl}/chat/sessions/${chatMessage.sessionId}/messages/stream`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@ -826,7 +827,7 @@ class ApiClient {
|
|||||||
'Accept': 'text/event-stream',
|
'Accept': 'text/event-stream',
|
||||||
'Cache-Control': 'no-cache'
|
'Cache-Control': 'no-cache'
|
||||||
},
|
},
|
||||||
body: JSON.stringify(formatApiRequest({ chatMessage })),
|
body: JSON.stringify(request),
|
||||||
signal
|
signal
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1933,21 +1933,12 @@ async def create_chat_session(
|
|||||||
|
|
||||||
@api_router.post("/chat/sessions/{session_id}/messages/stream")
|
@api_router.post("/chat/sessions/{session_id}/messages/stream")
|
||||||
async def post_chat_session_message_stream(
|
async def post_chat_session_message_stream(
|
||||||
data: Dict[str, Any] = Body(...),
|
user_message: ChatMessageUser = Body(...),
|
||||||
current_user = Depends(get_current_user),
|
current_user = Depends(get_current_user),
|
||||||
database: RedisDatabase = Depends(get_database),
|
database: RedisDatabase = Depends(get_database)
|
||||||
request: Request = Request,
|
|
||||||
):
|
):
|
||||||
"""Post a message to a chat session and stream the response with persistence"""
|
"""Post a message to a chat session and stream the response with persistence"""
|
||||||
try:
|
try:
|
||||||
user_message_data = data.get("chatMessage")
|
|
||||||
if not user_message_data:
|
|
||||||
return JSONResponse(
|
|
||||||
status_code=400,
|
|
||||||
content=create_error_response("INVALID_CHAT_MESSAGE", "chatMessage cannot be empty")
|
|
||||||
)
|
|
||||||
user_message = ChatMessageUser.model_validate(user_message_data)
|
|
||||||
|
|
||||||
chat_session_data = await database.get_chat_session(user_message.session_id)
|
chat_session_data = await database.get_chat_session(user_message.session_id)
|
||||||
if not chat_session_data:
|
if not chat_session_data:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user