Skip to content

Nebula t0-003 Integration #147

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
merged 1 commit into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 57 additions & 100 deletions Thirdweb.Tests/Thirdweb.AI/Thirdweb.AI.Tests.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// using System.Numerics;
using System.Numerics;
using Thirdweb.AI;

namespace Thirdweb.Tests.AI;

public class NebulaTests : BaseTests
{
// private const string NEBULA_TEST_CONTRACT = "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8";
// private const string NEBULA_TEST_USDC_ADDRESS = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238";
// private const int NEBULA_TEST_CHAIN = 11155111;
private const string NEBULA_TEST_USDC_ADDRESS = "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238";

private const string NEBULA_TEST_CONTRACT = "0xe2cb0eb5147b42095c2FfA6F7ec953bb0bE347D8";

private const int NEBULA_TEST_CHAIN = 11155111;

public NebulaTests(ITestOutputHelper output)
: base(output) { }
Expand All @@ -33,104 +36,58 @@ public async Task Create_ResumesSession()
Assert.Equal(sessionId, nebula.SessionId);
}

// [Fact(Timeout = 120000)]
// public async Task Chat_Single_ReturnsResponse()
// {
// var nebula = await ThirdwebNebula.Create(this.Client);
// var response = await nebula.Chat(
// message: "What's the symbol of this contract?",
// context: new NebulaContext(contractAddresses: new List<string> { NEBULA_TEST_CONTRACT }, chainIds: new List<BigInteger> { NEBULA_TEST_CHAIN })
// );
// Assert.NotNull(response);
// Assert.NotNull(response.Message);
// Assert.Contains("CAT", response.Message);
// }

// [Fact(Timeout = 120000)]
// public async Task Chat_Single_NoContext_ReturnsResponse()
// {
// var nebula = await ThirdwebNebula.Create(this.Client);
// var response = await nebula.Chat(message: $"What's the symbol of this contract: {NEBULA_TEST_CONTRACT} (Sepolia)?");
// Assert.NotNull(response);
// Assert.NotNull(response.Message);
// Assert.Contains("CAT", response.Message);
// }

// [Fact(Timeout = 120000)]
// public async Task Chat_Multiple_ReturnsResponse()
// {
// var nebula = await ThirdwebNebula.Create(this.Client);
// var response = await nebula.Chat(
// messages: new List<NebulaChatMessage>
// {
// new("What's the symbol of this contract?", NebulaChatRole.User),
// new("The symbol is CAT", NebulaChatRole.Assistant),
// new("What's the name of this contract?", NebulaChatRole.User),
// },
// context: new NebulaContext(contractAddresses: new List<string> { NEBULA_TEST_CONTRACT }, chainIds: new List<BigInteger> { NEBULA_TEST_CHAIN })
// );
// Assert.NotNull(response);
// Assert.NotNull(response.Message);
// Assert.Contains("CatDrop", response.Message, StringComparison.OrdinalIgnoreCase);
// }
[Fact(Timeout = 120000)]
public async Task Chat_Single_ReturnsResponse()
{
var nebula = await ThirdwebNebula.Create(this.Client);
var response = await nebula.Chat(message: $"What's the symbol of this contract {NEBULA_TEST_CONTRACT}?", context: new NebulaContext(chainIds: new List<BigInteger>() { NEBULA_TEST_CHAIN }));
Assert.NotNull(response);
Assert.NotNull(response.Message);
Assert.Contains("CAT", response.Message);
}

// [Fact(Timeout = 120000)]
// public async Task Chat_UnderstandsWalletContext()
// {
// var wallet = await PrivateKeyWallet.Generate(this.Client);
// var expectedAddress = await wallet.GetAddress();
// var nebula = await ThirdwebNebula.Create(this.Client);
// var response = await nebula.Chat(message: "What is my wallet address?", wallet: wallet);
// Assert.NotNull(response);
// Assert.NotNull(response.Message);
// Assert.Contains(expectedAddress, response.Message);
// }
[Fact(Timeout = 120000)]
public async Task Chat_Single_NoContext_ReturnsResponse()
{
var nebula = await ThirdwebNebula.Create(this.Client);
var response = await nebula.Chat(message: $"What's the symbol of this contract: {NEBULA_TEST_CONTRACT} (Sepolia)?");
Assert.NotNull(response);
Assert.NotNull(response.Message);
Assert.Contains("CAT", response.Message);
}

// [Fact(Timeout = 120000)]
// public async Task Execute_ReturnsMessageAndReceipt()
// {
// var signer = await PrivateKeyWallet.Generate(this.Client);
// var wallet = await SmartWallet.Create(signer, NEBULA_TEST_CHAIN);
// var nebula = await ThirdwebNebula.Create(this.Client);
// var response = await nebula.Execute(
// new List<NebulaChatMessage>
// {
// new("What's the address of vitalik.eth", NebulaChatRole.User),
// new("The address of vitalik.eth is 0xd8dA6BF26964aF8E437eEa5e3616511D7G3a3298", NebulaChatRole.Assistant),
// new("Approve 1 USDC to them", NebulaChatRole.User),
// },
// wallet: wallet,
// context: new NebulaContext(contractAddresses: new List<string>() { NEBULA_TEST_USDC_ADDRESS })
// );
// Assert.NotNull(response);
// Assert.NotNull(response.Message);
// Assert.NotNull(response.TransactionReceipts);
// Assert.NotEmpty(response.TransactionReceipts);
// Assert.NotNull(response.TransactionReceipts[0].TransactionHash);
// Assert.True(response.TransactionReceipts[0].TransactionHash.Length == 66);
// }
[Fact(Timeout = 120000)]
public async Task Chat_UnderstandsWalletContext()
{
var wallet = await PrivateKeyWallet.Generate(this.Client);
var expectedAddress = await wallet.GetAddress();
var nebula = await ThirdwebNebula.Create(this.Client);
var response = await nebula.Chat(message: "What is my wallet address?", wallet: wallet);
Assert.NotNull(response);
Assert.NotNull(response.Message);
Assert.Contains(expectedAddress, response.Message);
}

// [Fact(Timeout = 120000)]
// public async Task Execute_ReturnsMessageAndReceipts()
// {
// var signer = await PrivateKeyWallet.Generate(this.Client);
// var wallet = await SmartWallet.Create(signer, NEBULA_TEST_CHAIN);
// var nebula = await ThirdwebNebula.Create(this.Client);
// var response = await nebula.Execute(
// new List<NebulaChatMessage>
// {
// new("What's the address of vitalik.eth", NebulaChatRole.User),
// new("The address of vitalik.eth is 0xd8dA6BF26964aF8E437eEa5e3616511D7G3a3298", NebulaChatRole.Assistant),
// new("Approve 1 USDC to them", NebulaChatRole.User),
// },
// wallet: wallet,
// context: new NebulaContext(contractAddresses: new List<string>() { NEBULA_TEST_USDC_ADDRESS })
// );
// Assert.NotNull(response);
// Assert.NotNull(response.Message);
// Assert.NotNull(response.TransactionReceipts);
// Assert.NotEmpty(response.TransactionReceipts);
// Assert.NotNull(response.TransactionReceipts[0].TransactionHash);
// Assert.True(response.TransactionReceipts[0].TransactionHash.Length == 66);
// }
[Fact(Timeout = 120000)]
public async Task Execute_ReturnsMessageAndReceipt()
{
var signer = await PrivateKeyWallet.Generate(this.Client);
var wallet = await SmartWallet.Create(signer, NEBULA_TEST_CHAIN);
var nebula = await ThirdwebNebula.Create(this.Client);
var response = await nebula.Execute(
new List<NebulaChatMessage>
{
new("What's the address of vitalik.eth", NebulaChatRole.User),
new("The address of vitalik.eth is 0xd8dA6BF26964aF8E437eEa5e3616511D7G3a3298", NebulaChatRole.Assistant),
new($"Approve 1 USDC (this contract: {NEBULA_TEST_USDC_ADDRESS}) to them", NebulaChatRole.User),
},
wallet: wallet
);
Assert.NotNull(response);
Assert.NotNull(response.Message);
Assert.NotNull(response.TransactionReceipts);
Assert.NotEmpty(response.TransactionReceipts);
Assert.NotNull(response.TransactionReceipts[0].TransactionHash);
Assert.True(response.TransactionReceipts[0].TransactionHash.Length == 66);
}
}
28 changes: 0 additions & 28 deletions Thirdweb/Thirdweb.AI/FeedbackClient.cs

This file was deleted.

Loading