Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add useChat() hook and ChatProvider context #822

Merged
merged 2 commits into from
Feb 15, 2025
Merged

Conversation

humphd
Copy link
Collaborator

@humphd humphd commented Feb 9, 2025

Fixes #818, adding a new <ChatProvider /> context and associated useChat() hook. We can use this to access the current chat anywhere in the React tree without props.

After this lands, it would be nice to refactor our code to not bother passing the chat via props all the time.

You can test this by trying to have the LLM write SQL that references one of the files or tables in DuckDB (e.g., select * from chatcraft.chats) and then clicking the run button to execute it.

Copy link
Collaborator

@mulla028 mulla028 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small fix required. Overall, LGTM!

src/components/CodeHeader.tsx Show resolved Hide resolved
@humphd humphd force-pushed the humphd/issue-818/use-chat branch from a238382 to f054b9f Compare February 15, 2025 15:15
Copy link

cloudflare-workers-and-pages bot commented Feb 15, 2025

Deploying chatcraft-org with  Cloudflare Pages  Cloudflare Pages

Latest commit: f054b9f
Status: ✅  Deploy successful!
Preview URL: https://755f503d.console-overthinker-dev.pages.dev
Branch Preview URL: https://humphd-issue-818-use-chat.console-overthinker-dev.pages.dev

View logs

@humphd
Copy link
Collaborator Author

humphd commented Feb 15, 2025

Thanks for catching that, @mulla028, fixed.

@humphd humphd merged commit c590327 into main Feb 15, 2025
4 checks passed
@humphd humphd deleted the humphd/issue-818/use-chat branch February 15, 2025 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add useChat() hook
2 participants