Skip to content

Commit

Permalink
fix: properly pass initialMessages to LocalRuntime (#1090)
Browse files Browse the repository at this point in the history
Co-Authored-By: igo <[email protected]>
  • Loading branch information
Yonom and igo authored Oct 26, 2024
1 parent 006ff20 commit 5d43e55
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 11 deletions.
11 changes: 11 additions & 0 deletions apps/docs/app/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,17 @@ export type AssistantProps = {
const MyRuntimeProvider = ({ children }: { children: React.ReactNode }) => {
const runtime = useEdgeRuntime({
api: "/api/chat",
initialMessages: [
{
role: "system",
content: [{ type: "text", text: "You are weather assistant" }],
},
{
role: "user",
content: [{ type: "text", text: "What's the weather in Paris?" }],
},
{ role: "assistant", content: [{ type: "text", text: "It's sunny." }] },
],
adapters: {
attachments: new CompositeAttachmentAdapter([
new SimpleImageAttachmentAdapter(),
Expand Down
2 changes: 1 addition & 1 deletion packages/react-ai-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"zustand": "^5.0.0"
},
"peerDependencies": {
"@assistant-ui/react": "^0.5.95",
"@assistant-ui/react": "^0.5.96",
"@types/react": "*",
"react": "^18 || ^19"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-hook-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"zod": "^3.23.8"
},
"peerDependencies": {
"@assistant-ui/react": "^0.5.95",
"@assistant-ui/react": "^0.5.96",
"@types/react": "*",
"react": "^18 || ^19",
"react-hook-form": "^7"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-langgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"zod": "^3.23.8"
},
"peerDependencies": {
"@assistant-ui/react": "^0.5.95",
"@assistant-ui/react": "^0.5.96",
"@types/react": "*",
"react": "^18 || ^19"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-markdown/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"react-markdown": "^9.0.1"
},
"peerDependencies": {
"@assistant-ui/react": "^0.5.95",
"@assistant-ui/react": "^0.5.96",
"@types/react": "*",
"react": "^18 || ^19",
"tailwindcss": "^3.4.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"zustand": "^5.0.0"
},
"peerDependencies": {
"@assistant-ui/react": "^0.5.95",
"@assistant-ui/react": "^0.5.96",
"@types/react": "*",
"react": "^18 || ^19",
"tailwindcss": "^3.4.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-syntax-highlighter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"build": "tsup src/index.ts --format cjs,esm --dts --sourcemap --clean"
},
"peerDependencies": {
"@assistant-ui/react": "^0.5.95",
"@assistant-ui/react": "^0.5.96",
"@assistant-ui/react-markdown": "^0.2.25",
"@types/react": "*",
"@types/react-syntax-highlighter": "*",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-trieve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"unist-util-visit": "^5.0.0"
},
"peerDependencies": {
"@assistant-ui/react": "^0.5.95",
"@assistant-ui/react": "^0.5.96",
"@assistant-ui/react-markdown": "^0.2.25",
"trieve-ts-sdk": "^0.0.13",
"@types/react": "*",
Expand Down
6 changes: 6 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @assistant-ui/react

## 0.5.96

### Patch Changes

- fix: properly pass initialMessages to LocalRuntime

## 0.5.95

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"conversational-ui",
"conversational-ai"
],
"version": "0.5.95",
"version": "0.5.96",
"license": "MIT",
"exports": {
".": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/runtimes/local/LocalRuntimeCore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class LocalRuntimeCore extends BaseAssistantRuntimeCore {

constructor(
options: LocalRuntimeOptionsBase,
initialMessages?: CoreMessage[],
initialMessages: readonly CoreMessage[] | undefined,
) {
super();

Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/runtimes/local/useLocalRuntime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LocalRuntimeImpl extends AssistantRuntimeImpl implements LocalRuntime {

export const useLocalRuntime = (
adapter: ChatModelAdapter,
options: LocalRuntimeOptions = {},
{ initialMessages, ...options }: LocalRuntimeOptions = {},
) => {
const opt = {
...options,
Expand All @@ -47,7 +47,7 @@ export const useLocalRuntime = (
},
};

const [runtime] = useState(() => new LocalRuntimeCore(opt));
const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));

useEffect(() => {
runtime.setOptions(opt);
Expand Down

0 comments on commit 5d43e55

Please sign in to comment.