Skip to content

Commit

Permalink
fix: state
Browse files Browse the repository at this point in the history
  • Loading branch information
grutt committed Feb 6, 2024
1 parent ada3c8d commit 1a1b460
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions python-examples/fast-api-react/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const API_URL = "http://localhost:8000";

function App() {
const [openRequest, setOpenRequest] = useState<string>();
const [message, setMessage] = useState<string>("");

const [messages, setMessages] = useState<Messages[]>([
{ role: "assistant", content: "How can I help you?" },
Expand Down Expand Up @@ -40,6 +41,7 @@ function App() {
hatchetRunId: data.workflowRunId,
},
]);
setOpenRequest(undefined);
}
}

Expand Down Expand Up @@ -93,7 +95,7 @@ function App() {
<div className="Messages">
{messages.map(({ role, content, hatchetRunId }, i) => (
<p key={i}>
<b>{role === "assistant" ? "Agent" : "You"}</b>: {content}.{" "}
<b>{role === "assistant" ? "Agent" : "You"}</b>: {content}
{hatchetRunId && (
<a
target="_blank"
Expand All @@ -118,8 +120,11 @@ function App() {
</div>

<div className="Input">
<textarea></textarea>
<button onClick={() => sendMessage("Your message")}>Ask</button>
<textarea
value={message}
onChange={(e) => setMessage(e.target.value)}
></textarea>
<button onClick={() => sendMessage(message)}>Ask</button>
</div>
</div>
);
Expand Down

0 comments on commit 1a1b460

Please sign in to comment.