Skip to content

feat: Add Nebula AI chat and transaction execution API #5948

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

Merged

Conversation

joaquim-verges
Copy link
Member

@joaquim-verges joaquim-verges commented Jan 14, 2025

Fixes TOOL-3063

How to test

pnpm test:dev chat.test.ts
pnpm test:dev execute.test.ts


PR-Codex overview

This PR introduces the Nebula API, enabling users to interact with it for chat and transaction execution functionalities. It enhances the thirdweb package with new methods and updates documentation for better usage examples.

Detailed summary

  • Added Nebula export in packages/thirdweb/src/exports/ai.ts.
  • Implemented chat and execute functions in packages/thirdweb/src/ai/chat.ts and packages/thirdweb/src/ai/execute.ts.
  • Updated packages/thirdweb/src/ai/common.ts with Input and Output types.
  • Enhanced tests for chat and execute in packages/thirdweb/src/ai/chat.test.ts and packages/thirdweb/src/ai/execute.test.ts.
  • Updated typedoc.mjs to include the new src/ai/index.ts.
  • Modified packages/thirdweb/package.json to include ai types and imports.
  • Added documentation for Nebula API usage examples in changeset/warm-dodos-destroy.md.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Jan 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 1:44am
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 1:44am
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 1:44am
wallet-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 1:44am

Copy link

changeset-bot bot commented Jan 14, 2025

🦋 Changeset detected

Latest commit: 19cbb18

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
thirdweb Minor
@thirdweb-dev/wagmi-adapter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added packages SDK Involves changes to the thirdweb SDK labels Jan 14, 2025
Copy link
Member Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

import { getContract } from "../contract/contract.js";
import * as Nebula from "./index.js";

describe("chat", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The test file execute.test.ts has a describe block labeled as "chat", but since these tests are validating the execute functionality, the block should be labeled as "execute" to accurately reflect its purpose.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines 86 to 93
transactions = data.actions.map((action) => {
const tx = JSON.parse(action.data) as {
chainId: number;
to: Address | undefined;
value: Hex;
data: Hex;
};
return prepareTransaction({
Copy link
Contributor

Choose a reason for hiding this comment

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

The action.type check is missing before parsing transaction data. Since action.type can be 'init', 'presence', or 'sign_transaction', and each type may have different data structures, add a guard to ensure only 'sign_transaction' actions are processed as transactions. This will prevent potential runtime errors from parsing incompatible data formats.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

@joaquim-verges joaquim-verges force-pushed the feat_Add_Nebula_AI_chat_and_transaction_execution_API branch from 543f9ec to 07a59a2 Compare January 14, 2025 09:14
Copy link

linear bot commented Jan 14, 2025

@joaquim-verges joaquim-verges marked this pull request as ready for review January 14, 2025 09:15
@joaquim-verges joaquim-verges requested review from jnsdls and a team as code owners January 14, 2025 09:15
@joaquim-verges joaquim-verges force-pushed the feat_Add_Nebula_AI_chat_and_transaction_execution_API branch from 07a59a2 to 1017315 Compare January 14, 2025 09:15
Copy link
Contributor

github-actions bot commented Jan 14, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 46.68 KB (0%) 934 ms (0%) 256 ms (+6.64% 🔺) 1.2 s
thirdweb (cjs) 116.72 KB (0%) 2.4 s (0%) 488 ms (+6.46% 🔺) 2.9 s
thirdweb (minimal + tree-shaking) 5.59 KB (0%) 112 ms (0%) 141 ms (+294.33% 🔺) 253 ms
thirdweb/chains (tree-shaking) 506 B (0%) 10 ms (0%) 6 ms (-32.81% 🔽) 16 ms
thirdweb/react (minimal + tree-shaking) 19.24 KB (0%) 385 ms (0%) 117 ms (+164.89% 🔺) 501 ms

@joaquim-verges joaquim-verges force-pushed the feat_Add_Nebula_AI_chat_and_transaction_execution_API branch from 1017315 to 19cbb18 Compare January 15, 2025 01:35
@github-actions github-actions bot added the Portal Involves changes to the Portal (docs) codebase. label Jan 15, 2025
@joaquim-verges joaquim-verges merged commit b10f306 into main Jan 15, 2025
28 of 29 checks passed
@joaquim-verges joaquim-verges deleted the feat_Add_Nebula_AI_chat_and_transaction_execution_API branch January 15, 2025 01:50
@jnsdls jnsdls mentioned this pull request Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages Portal Involves changes to the Portal (docs) codebase. SDK Involves changes to the thirdweb SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant