Skip to content

Commit

Permalink
refactor conversation class
Browse files Browse the repository at this point in the history
- Create a new class `Conversation` in `api.ts` to handle conversations.
- Move the logic for getting messages and sending messages to the `Conversation` class.
- Add a constructor to initialize the `Conversation` with the appropriate API instance and conversation ID.
- Add a `getMessages` method to fetch messages for the conversation.
- Add a `chat` method to send a message in the conversation.
- Update the code to use the `Conversation` class instead of making API calls directly.
- Update the `Home` component to use the new `Conversation` class for fetching messages and sending messages.
- Remove unused imports and variables.
  • Loading branch information
hyusap committed Nov 12, 2023
1 parent e74bf2f commit fe15e1e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions www/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,7 @@ export default function Home() {
</p>
</section>
)}
<section
className="flex flex-col flex-1 overflow-y-auto lg:px-5"
ref={messageContainerRef}
>
<section className="flex flex-col flex-1 overflow-y-auto lg:px-5">
{messages.map((message, i) => (
<Message isUser={message.isUser} key={i}>
<MarkdownWrapper text={message.text} />
Expand All @@ -178,6 +175,9 @@ export default function Home() {
className={`flex-1 px-3 py-1 lg:px-5 lg:py-3 bg-gray-100 text-gray-400 rounded-2xl border-2 ${
canSend ? " border-green-200" : "border-red-200 opacity-50"
}`}
className={`flex-1 px-3 py-1 lg:px-5 lg:py-3 bg-gray-100 text-gray-400 rounded-2xl border-2 ${
canSend ? " border-green-200" : "border-red-200 opacity-50"
}`}
disabled={!canSend}
/>
<button
Expand All @@ -194,5 +194,12 @@ export default function Home() {
isThoughtsOpen={isThoughtsOpen}
/>
</main>
</div>
<Thoughts
thought={thought}
setIsThoughtsOpen={setIsThoughtsOpen}
isThoughtsOpen={isThoughtsOpen}
/>
</main>
);
}

0 comments on commit fe15e1e

Please sign in to comment.