Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously, the Sidekick would always emit GenUI components (e.g. `<Card>`). This can present a challenge for integrators, because using this output requires you to do MDX compilation. Now, we introduce three options: * GenUI * Plain Markdown * Plain text The latter option offers the lowest barrier to entry for integrators. Also adds option to disable recommended next steps
- Loading branch information
1 parent
095764c
commit 956ce57
Showing
7 changed files
with
152 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import * as AI from 'ai-jsx'; | ||
import { Sidekick, SidekickProps } from 'ai-jsx/sidekick'; | ||
import { ConversationHistoryContext, SystemMessage, UserMessage } from 'ai-jsx/core/conversation'; | ||
|
||
const mySystemMessage = ( | ||
<SystemMessage> | ||
You can do anything a flight assistant can do, including looking up user information and booking new flights. Here | ||
is information about the user's upcoming flight: | ||
{`{ | ||
"flightNumber": "UA 123", | ||
"departureTime": "2021-10-31T12:00:00Z", | ||
"arrivalTime": "2021-10-31T13:00:00Z", | ||
"departureAirport": "SFO", | ||
"arrivalAirport": "LAX" | ||
}`} | ||
</SystemMessage> | ||
); | ||
|
||
function MySidekick({ | ||
contentType, | ||
includeNextStepsRecommendations, | ||
}: { | ||
contentType: SidekickProps['outputFormat']; | ||
includeNextStepsRecommendations?: boolean; | ||
}) { | ||
return ( | ||
// I don't feel like making the types line up. | ||
// @ts-expect-error | ||
<Sidekick | ||
role="Flight assistant" | ||
outputFormat={contentType} | ||
systemMessage={mySystemMessage} | ||
includeNextStepsRecommendations={includeNextStepsRecommendations} | ||
/> | ||
); | ||
} | ||
|
||
const conversation = [ | ||
<UserMessage>Tell me about my flight. Also, give me a list of cities near my destination.</UserMessage>, | ||
]; | ||
|
||
console.log( | ||
await AI.createRenderContext().render( | ||
<> | ||
<ConversationHistoryContext.Provider value={conversation}> | ||
{/* Unfortunately, I couldn't get this to actually output next steps buttons, but I confirmed that the prompt | ||
is being passed. | ||
*/} | ||
GenUI output:{'\n'} | ||
<MySidekick contentType="text/mdx" /> | ||
{'\n\n'} | ||
GenUI output no next steps:{'\n'} | ||
<MySidekick contentType="text/mdx" includeNextStepsRecommendations={false} /> | ||
{'\n\n'} | ||
Markdown output:{'\n'} | ||
<MySidekick contentType="text/markdown" /> | ||
{'\n\n'} | ||
Plain text output:{'\n'} | ||
<MySidekick contentType="text/plain" /> | ||
</ConversationHistoryContext.Provider> | ||
</> | ||
) | ||
); |
956ce57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ai-jsx-docs – ./packages/docs
ai-jsx-docs.vercel.app
docs.ai-jsx.com
ai-jsx-docs-fixie-ai.vercel.app
ai-jsx-docs-git-main-fixie-ai.vercel.app
956ce57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ai-jsx-tutorial-nextjs – ./packages/tutorial-nextjs
ai-jsx-tutorial-nextjs-git-main-fixie-ai.vercel.app
ai-jsx-tutorial-nextjs-fixie-ai.vercel.app
ai-jsx-tutorial-nextjs.vercel.app
956ce57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ai-jsx-nextjs-demo – ./packages/nextjs-demo
ai-jsx-nextjs-demo-fixie-ai.vercel.app
ai-jsx-nextjs-demo.vercel.app
ai-jsx-nextjs-demo-git-main-fixie-ai.vercel.app