Skip to content

Commit

Permalink
Iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
serefyarar committed Jun 21, 2024
1 parent aa71b04 commit 2855e70
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 46 deletions.
2 changes: 1 addition & 1 deletion api/src/controllers/conversation.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export const refreshSummary = async (req, res, next) => {
},
prompt: `Given the following conversation titles, generate one and unique title.
The title should be clear, descriptive, and relevant to the topic at hand.
Write title from the chat_history in maximum 10 words.
Write title from the chat_history in maximum 10 words. Dont add "title" prefixes.
Chat_history: {chat_history}
`,
},
Expand Down
89 changes: 48 additions & 41 deletions web-app/src/components/sections/History/HistoryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { useApp } from "@/context/AppContext";
import Button from "components/base/Button";
import moment from "moment";
import { useRouter } from "next/navigation";
import Row from "@/components/layout/base/Grid/Row";
import Col from "@/components/layout/base/Grid/Col";
import Flex from "@/components/layout/base/Grid/Flex";
import Text from "@/components/base/Text";
import FlexRow from "@/components/layout/base/Grid/FlexRow";
import HistoryItemOpsPopup from "./HistoryItemOpsPopup";

type HistoryItemProps = {
Expand All @@ -24,25 +29,48 @@ const HistoryItem = ({ item }: { item: HistoryItemProps }) => {
onClick={() => {
router.push(`/conversation/${item.id}`);
}}
style={{
cursor: "pointer",
}}
className="card-item p-6"
>
<div
style={{
borderRadius: "4px",
padding: "12px",
border: "1px solid var(--gray-2)",
height: "fit-content",
display: "flex",
flexDirection: "column",
gap: "4px",
cursor: "pointer",
}}
>
<div
style={{
alignSelf: "flex-end",
position: "absolute",
}}
>
<FlexRow justify={"between"} fullWidth>
<Col xs={10}>
<Flex
className={"idxflex-nowrap"}
alignitems={"top"}
flexdirection={"column"}
>
<Row>
<Text
style={{
fontSize: "14px",
fontWeight: "bold",
margin: 0,
}}
>
{item.summary}
</Text>
</Row>
<Row className={"mt-3"}>
<Flex alignitems={"left"}>
<Col>
<Text
style={{
fontSize: "12px",
margin: 0,
}}
>
{item?.createdAt
? `Updated ${moment(new Date(item.createdAt)).fromNow()}`
: ""}
</Text>
</Col>
</Flex>
</Row>
</Flex>
</Col>
<Col pullRight>
<Button
onClick={(e: any) => {
e.stopPropagation();
Expand All @@ -57,29 +85,8 @@ const HistoryItem = ({ item }: { item: HistoryItemProps }) => {
}}
/>
</Button>
</div>
<h2
style={{
fontSize: "14px",
fontWeight: "bold",
margin: 0,
}}
>
{item.summary}
</h2>

<p
style={{
fontSize: "12px",
margin: 0,
}}
>
{/* Last message 10 days ago */}
{item?.createdAt
? `Updated ${moment(new Date(item.createdAt)).fromNow()}`
: ""}
</p>
</div>
</Col>
</FlexRow>
</div>
);
};
Expand Down
9 changes: 6 additions & 3 deletions web-app/src/components/site/indexes/AskIndexes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,10 +292,13 @@ const AskIndexes: FC<AskIndexesProps> = ({ sources }) => {
console.log("Received message from server", payload);

if (payload.channel === "end") {
if (viewedConversation && viewedConversation.summary === `New Chat`) {
if (viewedConversation && viewedConversation.summary === `New chat`) {
api!.getConversationWithSummary(viewedConversation.id).then((c) => {
viewedConversation.summary = c.summary;
setViewedConversation(viewedConversation);
setConversations(
conversations.map((i: any) =>
i.id === c.id ? { ...c, summary: c.summary } : i,
),
);
});
}

Expand Down
2 changes: 1 addition & 1 deletion web-app/src/services/api-service-new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const API_ENDPOINTS = {
LIST_CONVERSATIONS: "/conversations",
CREATE_CONVERSATION: "/conversations",
GET_CONVERSATION: "/conversations/:conversationId",
GET_CONVERSATION_WITH_SUMMARY: "/conversations/:conversationId",
GET_CONVERSATION_WITH_SUMMARY: "/conversations/:conversationId/summary",
DELETE_CONVERSATION: "/conversations/:conversationId",
SEND_MESSAGE: "/conversations/:conversationId/messages",
UPDATE_MESSAGE: "/conversations/:conversationId/messages/:messageId",
Expand Down

0 comments on commit 2855e70

Please sign in to comment.