-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: make non-streaming chat as /chat/request route #20
Conversation
templates/types/streaming/express/src/controllers/chat.middleware.ts
Outdated
Show resolved
Hide resolved
|
||
``` | ||
curl --location 'localhost:8000/api/chat/request' \ | ||
--header 'Content-Type: text/plain' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thucpn we don't support application/json?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be application/json
questions.ts
Outdated
@@ -370,7 +370,6 @@ export const askQuestions = async ( | |||
name: "template", | |||
message: "Which template would you like to use?", | |||
choices: [ | |||
{ title: "Chat without streaming", value: "simple" }, | |||
{ title: "Chat with streaming", value: "streaming" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ title: "Chat with streaming", value: "streaming" }, | |
{ title: "Chat", value: "streaming" }, |
result: _Message | ||
|
||
|
||
async def preprocess_request(data: _ChatData) -> tuple: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async def preprocess_request(data: _ChatData) -> tuple: | |
from typing import List, Tuple | |
# parses _ChatData to be used by LlamaIndex chat | |
async def parse_chat_data(data: _ChatData) -> Tuple[str, List[ChatMessage]]: |
@@ -44,16 +42,36 @@ async def chat( | |||
) | |||
for m in data.messages | |||
] | |||
return last_message, messages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we're a bit in a pickle as last_message is a different message type than messages, to be consistent we could either return:
return last_message, messages | |
return last_message.content, messages |
or
return last_message, messages | |
return ChatMessage(role=last_message.role, | |
content=last_message.content), messages |
I think the first one is easier to understand
61871fb
to
e5137d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thucpn thanks looks great
No description provided.