Skip to content

Commit

Permalink
feat: Move initialPrompt from useRun to start
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjcsmith committed Dec 9, 2024
1 parent 202c8b4 commit a73f9a7
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 157 deletions.
27 changes: 9 additions & 18 deletions sdk-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,40 +50,31 @@ It can be used to interact with an existing run by specifying the `runId`:
const { messages, run, createMessage, start } = useRun({
clusterId: 'your-cluster-id',
customerProvidedSecret: 'your-customer-provided-secret',
runId: 'your-run-id',
// pollInterval: 1000, // Optional: defaults to 1000ms
});

start({
runId: 'your-run-id',
})
```


#### New Runs

It can be used to create a new run by specifying a `configId`:
It can be used to create a new run by specifying an `initialPrompt`:

```typescript
const { messages, run, createMessage, start } = useRun({
clusterId: 'your-cluster-id',
customerProvidedSecret: 'your-customer-provided-secret',
initialMessage: 'Hello!',
configId: 'your-run-config-id',
// configInput: {} // Optional: if the config has an inputSchema
// pollInterval: 1000, // Optional: defaults to 1000ms
});
```

#### Start

Once the hook is initialized, you can start the run by calling the `start` function:

```typescript
start()

// Access messages and run state
console.log(messages); // Array of messages in the run
console.log(run); // Current run status and metadata
start({
initialPrompt: 'Hello!',
})
```


#### Adding Messages

You can add messages to the run by calling the `createMessage` function:
Expand Down Expand Up @@ -124,7 +115,7 @@ const { messages } = useRun({

## Local Development

There is development server included in the repository at `./test-page`.
There is development server included in the repository at `./demo`.

1. Start the development server:
```bash
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from 'react';
import { useRun } from '../hooks/useRun';
import { useRun } from '../src';

type TestPageProps = {
baseUrl?: string;
Expand Down Expand Up @@ -33,7 +33,9 @@ export function TestPage(props: TestPageProps) {
<button
onClick={() => {
setStarted(true);
start();
start({
initialPrompt: props.initialPrompt
});
}}
style={{ padding: '8px 16px' }}
>
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a73f9a7

Please sign in to comment.