Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate FixieCorpus to the new (beta) corpus API. (#246)
The new corpus service is currently only deployed on beta.fixie.ai, however, it should be more reliable and useful than the existing app.fixie.ai API. Hence this PR updates AI.JSX's `FixieCorpus` component to use the new API surface. I've also added a little demo program for the component. If we want to retain support for the old API, I'm happy to rename this component to something like `FixieCorpusNew` or add a flag or something to use the new API instead - feedback welcome! --------- Co-authored-by: Nick Heiner <NickHeiner@users.noreply.github.com>
- Loading branch information
1 parent
b758fe6
commit 44e7702
Showing
9 changed files
with
114 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
*.map | ||
build |
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,32 @@ | ||
/** | ||
* This is a simple demo showing how to query a corpus of documents through the Fixie service. | ||
* The app only sends a single query to a corpus, and dumps out the raw text of the top 4 chunks. | ||
*/ | ||
|
||
import { ScoredChunk, FixieCorpus } from 'ai-jsx/batteries/docs'; | ||
import { showInspector } from 'ai-jsx/core/inspector'; | ||
|
||
import promptly from 'promptly'; | ||
const { prompt } = promptly; | ||
|
||
function ChunkFormatter({ doc }: { doc: ScoredChunk<any> }) { | ||
return ( | ||
<> | ||
{'\n'}```chunk{'\n'} | ||
{doc.chunk.content.replaceAll('```', '\\`\\`\\`')} | ||
{'\n'}```{'\n'} | ||
</> | ||
); | ||
} | ||
|
||
async function App({ corpusId }: { corpusId: string }) { | ||
const corpus = new FixieCorpus(corpusId); | ||
|
||
const query = 'How do I write a chatbot in AI.JSX?'; | ||
const results = await corpus.search(query, { limit: 4 }); | ||
|
||
return results.map((chunk) => <ChunkFormatter doc={chunk} />); | ||
} | ||
|
||
const corpusId = await prompt('Fixie Corpus ID: '); | ||
showInspector(<App corpusId={corpusId} />); |
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
44e7702
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-fixie-ai.vercel.app
docs.ai-jsx.com
ai-jsx-docs-git-main-fixie-ai.vercel.app
ai-jsx-docs.vercel.app
44e7702
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.vercel.app
ai-jsx-tutorial-nextjs-fixie-ai.vercel.app
ai-jsx-tutorial-nextjs-git-main-fixie-ai.vercel.app
44e7702
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-git-main-fixie-ai.vercel.app
ai-jsx-nextjs-demo-fixie-ai.vercel.app
ai-jsx-nextjs-demo.vercel.app