Skip to content

Commit

Permalink
fix diagram and chat history
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jun 6, 2024
1 parent 2a4dad8 commit 323171f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
5 changes: 4 additions & 1 deletion components/prebuilt/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function Chat() {
if (selectedFile) {
base64File = await convertFileToBase64(selectedFile);
}
console.log(history);
const element = await actions.agent({
input,
chat_history: history,
Expand All @@ -73,12 +74,14 @@ export default function Chat() {
// after which we can append to our chat history state
(async () => {
let lastEvent = await element.lastEvent;
if (typeof lastEvent === "string") {
if (typeof lastEvent === "string" && lastEvent !== "") {
setHistory((prev) => [
...prev,
["user", input],
["assistant", lastEvent],
]);
} else {
setHistory((prev) => [...prev, ["user", input]]);
}
})();

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"format": "yarn prettier --write ./app ./ai ./components ./utils ./lib"
},
"dependencies": {
"@langchain/core": "^0.2.2",
"@langchain/core": "^0.2.6",
"@langchain/langgraph": "^0.0.22",
"@langchain/openai": "^0.0.34",
"@radix-ui/react-avatar": "^1.0.4",
Expand Down Expand Up @@ -56,6 +56,6 @@
"typescript": "^5"
},
"resolutions": {
"@langchain/core": "0.2.2"
"@langchain/core": "0.2.6"
}
}
Binary file modified public/gen_ui_diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion utils/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function streamRunnableUI<RunInput, RunOutput>(

// resolve the promise, which will be sent
// to the client thanks to RSC
resolve(lastEventValue?.data.output);
resolve(lastEventValue?.data.output["invokeModel"]["result"] ?? "");

Object.values(callbacks).forEach((cb) => cb.done());
ui.done();
Expand Down
21 changes: 16 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,16 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"

"@langchain/[email protected].2", "@langchain/core@>0.1.0 <0.3.0", "@langchain/core@>0.1.56 <0.3.0", "@langchain/core@>0.1.61 <0.3.0", "@langchain/core@^0.2.2", "@langchain/core@~0.2.0":
version "0.2.2"
resolved "https://registry.yarnpkg.com/@langchain/core/-/core-0.2.2.tgz#1e691cb2124a28b60b88a3500ab79413cff183f8"
integrity sha512-pVsaXfKu8EH010pC2dL/NL1XWnCY46X7FRvg/ScnZ9UiALC153Irb4/Hukjh2H5K0osJws1jza/f3BLruh7jUQ==
"@langchain/[email protected].6", "@langchain/core@>0.1.0 <0.3.0", "@langchain/core@>0.1.56 <0.3.0", "@langchain/core@>0.1.61 <0.3.0", "@langchain/core@^0.2.6", "@langchain/core@~0.2.0":
version "0.2.6"
resolved "https://registry.yarnpkg.com/@langchain/core/-/core-0.2.6.tgz#7b57ff88d4b5ae75bafbe689cd8878e9fbad7de6"
integrity sha512-YB9F0vdi/PcgBLSKtDwQ3gV6w4xVfk4ph0U43Okz2dAapKfBkVVB0rzr/afYUt/WHs864MuaO8uLN64egSDtIA==
dependencies:
ansi-styles "^5.0.0"
camelcase "6"
decamelize "1.2.0"
js-tiktoken "^1.0.12"
langsmith "~0.1.7"
langsmith "~0.1.30"
ml-distance "^4.0.0"
mustache "^4.2.0"
p-queue "^6.6.2"
Expand Down Expand Up @@ -2857,6 +2857,17 @@ langchainhub@~0.0.8:
resolved "https://registry.yarnpkg.com/langchainhub/-/langchainhub-0.0.11.tgz#2ce22def9c84699dcbd4fd4b78270d34bd2a9ae9"
integrity sha512-WnKI4g9kU2bHQP136orXr2bcRdgz9iiTBpTN0jWt9IlScUKnJBoD0aa2HOzHURQKeQDnt2JwqVmQ6Depf5uDLQ==

langsmith@~0.1.30:
version "0.1.30"
resolved "https://registry.yarnpkg.com/langsmith/-/langsmith-0.1.30.tgz#3000e441605b26e15a87fb991a3929c944edbc0a"
integrity sha512-g8f10H1iiRjCweXJjgM3Y9xl6ApCa1OThDvc0BlSDLVrGVPy1on9wT39vAzYkeadC7oG48p7gfpGlYH3kLkJ9Q==
dependencies:
"@types/uuid" "^9.0.1"
commander "^10.0.1"
p-queue "^6.6.2"
p-retry "4"
uuid "^9.0.0"

langsmith@~0.1.7:
version "0.1.28"
resolved "https://registry.yarnpkg.com/langsmith/-/langsmith-0.1.28.tgz#fbe01352d0b993fd11d4085dd337b1cec17ef28d"
Expand Down

0 comments on commit 323171f

Please sign in to comment.