Skip to content

Commit

Permalink
echo
Browse files Browse the repository at this point in the history
  • Loading branch information
Ataxia123 committed Apr 21, 2024
1 parent 200bab6 commit e226b27
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 20 deletions.
11 changes: 0 additions & 11 deletions packages/nextjs/app/api/inngest/inngest/route.ts

This file was deleted.

5 changes: 3 additions & 2 deletions packages/nextjs/app/api/inngest/route.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { inngest } from "../../inngest/client";
import { hello2World, hello3World, helloWorld } from "../../inngest/functions";
import { hello2World, hello3World, hello4World, helloWorld } from "../../inngest/functions";
import { serve } from "inngest/next";

export const { GET, POST, PUT } = serve({
client: inngest,
functions: [
helloWorld,
hello2World,
hello3World, // <-- This is where you'll always add all your functions
hello3World,
hello4World, // <-- This is where you'll always add all your functions
],
});
19 changes: 12 additions & 7 deletions packages/nextjs/app/frames/tx-success/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@ import Bonfire from "../../../components/assets/bonfireLogo";
import { frames } from "../frames";
import { Button } from "frames.js/next";
import { createPublicClient, http } from "viem";
import { parseAbiItem } from "viem";
import { hardhat } from "viem/chains";
import { inngest } from "~~/app/inngest/client";

export const publicClient = createPublicClient({
chain: hardhat,
transport: http(),
});

export const POST = frames(async ctx => {
const state = ctx.state;
const haiku = await fetch(`https://fworks.vercel.app/api/mongo/haiku?id=${state.id}&type=hash`);
const hk = await haiku.json();
const hkLength = hk.length;
const latestHaiku = hk[hkLength - 1];
console.log(ctx.message);

const wagmiAbi = [
Expand Down Expand Up @@ -76,13 +71,23 @@ export const POST = frames(async ctx => {
},
});

const latestLog = logs[logs.length - 1];

console.log(logs);

const data = await publicClient.readContract({
address: "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6",
abi: wagmiAbi,
functionName: "tribeStats",
args: [logs[logs.length - 1].args.tokenId],
args: [latestLog.args.tokenId],
});

await inngest.send({
name: "test/hello4.world",
data: {
prompt: data,
fid: latestLog.args.tokenId,
},
});

return {
Expand Down
60 changes: 60 additions & 0 deletions packages/nextjs/app/inngest/functions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,63 @@ export const hello3World = inngest.createFunction(
return { event, body: `"Message ${output}"` };
},
);

export const hello4World = inngest.createFunction(
{ id: "hello4-world" },
{ event: "test/hello4.world" },
async ({ event, step }) => {
// fetch a single cast
//const hash = event.data.castId;
// const options = {
// method: "GET",
// headers: { accept: "application/json", api_key: process.env.NEYNAR_API_KEY || "" },
//};

//const query = await fetch(`https://api.neynar.com/v2/farcaster/cast?identifier=${hash}&type=hash`, options);
// const response = await query.json();
//if (!response) {
//return { event, body: `"No response from cast ${hash}"` };
//}

const userPrompt = `"subject: ${event.data.prompt}"`;
const haikiput: Haikipu = {
title: "Trybe Haikus",
id: event.data.fid,
address: event.data.fid,
timestamp: Date.now().toString(),
type: "cast",
contextSummary:
"Create a narrative for the Using Trybe Haikus. Create a setting where a decision has to be made",
haiku: "",
explainer: "",
};
const hk = await hAIku(haikiput, systemPrompt, assistantPrompt, userPrompt);
//replicate

const output = await fetch("http://127.0.0.1:8000/generate/description-mode", {
method: "POST",
headers: {
accept: "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "Create a descriptive song setting a scene",
gpt_description_prompt: hk.haiku,
make_instrumental: false,
mv: "chirp-v3-0",
}),
})
.then(response => response.json())
.then(data => {
// Handle the response data
console.log(data);
})
.catch(error => {
// Handle any errors
console.error("Error:", error);
});
console.log(output);
//=> "https://replicate.delivery/pbxt/HuWYFtJyyH50BxruGu1XfUle...
return { event, body: `"Message ${output}"` };
},
);

0 comments on commit e226b27

Please sign in to comment.