https://github.com/jaykaycodes/teleprompt
https://github.com/jaykaycodes/teleprompt
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/jaykaycodes/teleprompt
- Owner: jaykaycodes
- License: mit
- Created: 2023-05-05T18:10:15.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-05T18:35:53.000Z (about 3 years ago)
- Last Synced: 2025-04-19T17:24:18.479Z (about 1 year ago)
- Language: TypeScript
- Size: 68.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Teleprompt
Create, compose, and use a AI prompts like you would GraphQL queries.
## Quick Start
```sh
yarn install
yarn dev
```
Then, try it out:
```sh
yarn workspace example dev
```
## Example
Suppose you write a prompt template file like this:
`src/prompts/my-amazing-prompt.prompt`
````md
```ts
interface Props {
requestedAt: Date
}
interface Context {
adverb: string
}
export default function(props: Props): Context {
return {
time: requestedAt.toISOString(),
adverb: 'ease'
}
}
export const config: PromptConfig = {
model: 'gpt-3.5-turbo',
}
```
This is my prompt. I can interpolate variables with ${adverb}! The current time is ${time}.
````
Then, in your client code, you simply import and call it like so:
`src/App.tsx`
```ts
import MyAmazingPrompt from './prompts/my-amazing-prompt.prompt'
export default function App() {
useEffect(() => {
const output = await MyAmazingPrompt(
// the `Props` object
{ requestedAt: new Date() },
// Optional. Override the template config
{ model: 'gpt-4' }
)
// The AI model receives:
// "This is my prompt. I can interpolate variables with ease! The current time is 2023-05-05T18:31:04.740Z."
console.log(output)
// => The response from the AI model...
}, [])
return ...
}
```
## Development
You'll first want to [yarn link](https://classic.yarnpkg.com/lang/en/docs/cli/link/) the package dir to the `example/`:
```sh
cd teleprompt && yarn link
cd ../example && yarn link teleprompt
```
Next, watch for source file changes & rebuild with:
```sh
# At workspace root
yarn dev
```
Then, run the `example/` project
```sh
yarn workspace example dev
```
NOTE: Any changes to the vite plugin will require a restart of the `example/` project.