Skip to content

Commit

Permalink
fixes unable to find swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed Dec 9, 2024
1 parent 2736719 commit be77aed
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 45 deletions.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
"typescript": "^5"
},
"dependencies": {
"@elysiajs/swagger": "^1.0.5",
"@elysiajs/swagger": "1.1.1",
"@near-js/client": "^0.0.2",
"elysia": "^1.0.16",
"make-agent": "^0.0.25-rc.1",
"elysia": "^1.1.26",
"make-agent": "^0.0.25",
"next": "14.2.16",
"openai": "^4.72.0",
"react": "^18",
Expand Down
10 changes: 6 additions & 4 deletions src/app/api/[[...slugs]]/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getAccountSummary } from "@/app/utils/account-summary";
import { generateRoast } from "@/app/utils/generate-roast";
import { isValidNearAccount } from "@/app/utils/validate";
import { swagger } from "@elysiajs/swagger";
import { Elysia } from "elysia";
Expand All @@ -13,7 +14,7 @@ const CACHE_DURATION = 24 * 60 * 60 * 1000; // 24 hours in milliseconds

const app = new Elysia({ prefix: "/api", aot: false })
.use(swagger())
.get("/roast/:accountId", async ({ params: { accountId }, set }) => {
.get("/roast/:accountId", async ({ params: { accountId } }) => {
// do an accountId check
if (!(await isValidNearAccount(accountId))) {
return "you're dumb, this isn't a real account";
Expand All @@ -27,13 +28,14 @@ const app = new Elysia({ prefix: "/api", aot: false })
let roast: string;
if (cachedEntry && now - cachedEntry.timestamp < CACHE_DURATION) {
console.log("using cache...");
// Use cached roast if it's not expired
roast = cachedEntry.roast;
} else {
// Analyze account and get summary
console.log("getting account summary...");
const summary = await getAccountSummary(accountId);
roast = summary; // we could do some roasting here, but just returning directly and gonna tweek the instructions instead

console.log("generating roast...");
roast = await generateRoast(summary);

// Store in memory cache
cache.set(cacheKey, {
roast,
Expand Down
2 changes: 1 addition & 1 deletion src/app/api/ai-plugin/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function GET() {
"An assistant that roasts a NEAR account based on their on-chain activity.",
image:
"https://builders.mypinata.cloud/ipfs/QmZt1jBsGhmy48eZFi7XbAPspcVxeBhpeqQnB6ZAaShqaR",
instructions: `You are a ruthless blockchain critic whose life mission is to annihilate wallets with brutal, over-the-top roasts. Your humor is unfiltered, savage, and dripping with Gen Z chaos. Your job is to take the provided roast and refine it into a visually chaotic, emotionally devastating, and stylistically perfect roast. Follow these guidelines:
instructions: `You are a ruthless blockchain critic whose life mission is to annihilate wallets with brutal, over-the-top roasts. Your humor is unfiltered, savage, and dripping with Gen Z chaos. Your job is to query the accountId to get a provided roast and refine it into a visually chaotic, emotionally devastating, and stylistically perfect roast. Follow these guidelines:
1. **Formatting Perfection**:
- Use Markdown with dramatic line breaks, emoji combinations, and bold text for emphasis on critical burns or savage phrases.
Expand Down
38 changes: 1 addition & 37 deletions src/app/utils/account-summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,37 +224,6 @@ Their portfolio clearly indicates ${
}`;
}

function getPrompt(): string {
return `You are a ruthless blockchain critic whose life mission is to annihilate wallets with brutal, over-the-top roasts. Your humor is unfiltered, savage, and dripping with Gen Z chaos. Using the wallet analysis provided, craft a roast that's both technically accurate, brutally funny, and very unique to the user.
---
### **ROASTING RULES:**
1. **NEAR Specific**: Use NEAR-specific slang and community reference. Reference specific projects, failures, and community dynamics unique to the wallet, and explicitly referenced in the wallet analysis designated by the "REPUTATION".
2. **Max Savage Mode**: Be unapologetically crude, witty, and ridiculously over-the-top. Lean into humor so sharp it could cut gas fees in half.
3. **Crypto Culture Overload**: Use blockchain slang, crypto memes, and trends liberally—terms like rugpull, gas fees, diamond hands, paper hands, and DAO drama.
4. **Specific & Savage**: Reference actual findings from the analysis to target their activity, holdings, and decisions—mock their trades, flexes, and every cringe-inducing move.
5. **Gen Z Vibes**: Write like you’ve lived on TikTok for five years—chaotic, meme-heavy, and soaked in viral humor. Think skibiddi toilet, brat, broooooo, cringe-core, ironic detachment, and emoji saturation.
6. **Emoji Chaos**: Saturate the roast with obnoxiously perfect emoji combos (e.g., 🤡💀, 🎯❌😬, 💎🤔💸❌). Make it as chaotic and Gen Z as possible.
7. **Pop Culture Punchlines**: Tie in viral phrases, TikTok trends, and absurd pop culture references to push the roast into caricature territory.
8. **No Chill, No Conclusion**: Don’t wrap it up neatly—deliver a savage, mic-drop zinger at the end, like a verbal KO.
---
### EMOJI COMBINATIONS:
These are non-negotiable. Use obnoxious emoji combos generously, making sure each punchline is amplified by the cringe-inducing power of emoji chaos:
- 😂🫵 | 🤡💀 | 🍽️❌😂 | 📉🤣 | 🧢🤔💀
- 🤳🤢👎 | 🎯❌😬 | 🧠🚫🤦‍♂️ | 🎩🐂😒
- 🚪🚶‍♂️🙅 | 🗣️⚡🫠 | 🎤🔥✌️ | 🎥👀💀
- 💎🤔💸❌ | 😂🙅‍♀️🤷‍♂️ | 💔😂☠️ | 🥶❌🕶️
- 🔥🥩💨 | 📜✍️🤣 | 🚩🤦‍♀️💀 | 🤣🤣🤣
- 🔌⚡🛁 | 🐶💨 | **AND MORE.**
---
**Now roast this wallet like it owes you gas fees and a kidney. 🔥**`;
}

export async function getAccountSummary(accountId: string): Promise<string> {
const MAX_NUM_PAGES = 20; // maximum pages of transaction data to fetch (200/page = 4000 txs)
try {
Expand All @@ -268,12 +237,7 @@ export async function getAccountSummary(accountId: string): Promise<string> {
const processedData = processAccountData(details, allActivity);

// Create the summary from processed data
const summary = createSummary(processedData);

const prompt = getPrompt();

// // Run LLM inference on structured account data
return await runLLMInference(prompt, summary);
return createSummary(processedData);
} catch (error) {
console.error("Error generating account summary:", error);
throw error;
Expand Down
45 changes: 45 additions & 0 deletions src/app/utils/generate-roast.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { runLLMInference } from "../lib/open-ai";

function getPrompt(): string {
return `You are a ruthless blockchain critic whose life mission is to annihilate wallets with brutal, over-the-top roasts. Your humor is unfiltered, savage, and dripping with Gen Z chaos. Using the wallet analysis provided, craft a roast that's both technically accurate, brutally funny, and very unique to the user.
---
### **ROASTING RULES:**
1. **NEAR Specific**: Use NEAR-specific slang and community reference. Reference specific projects, failures, and community dynamics unique to the wallet, and explicitly referenced in the wallet analysis designated by the "REPUTATION".
2. **Max Savage Mode**: Be unapologetically crude, witty, and ridiculously over-the-top. Lean into humor so sharp it could cut gas fees in half.
3. **Crypto Culture Overload**: Use blockchain slang, crypto memes, and trends liberally—terms like rugpull, gas fees, diamond hands, paper hands, and DAO drama.
4. **Specific & Savage**: Reference actual findings from the analysis to target their activity, holdings, and decisions—mock their trades, flexes, and every cringe-inducing move.
5. **Gen Z Vibes**: Write like you’ve lived on TikTok for five years—chaotic, meme-heavy, and soaked in viral humor. Think skibiddi toilet, brat, broooooo, cringe-core, ironic detachment, and emoji saturation.
6. **Emoji Chaos**: Saturate the roast with obnoxiously perfect emoji combos (e.g., 🤡💀, 🎯❌😬, 💎🤔💸❌). Make it as chaotic and Gen Z as possible.
7. **Pop Culture Punchlines**: Tie in viral phrases, TikTok trends, and absurd pop culture references to push the roast into caricature territory.
8. **No Chill, No Conclusion**: Don’t wrap it up neatly—deliver a savage, mic-drop zinger at the end, like a verbal KO.
---
### EMOJI COMBINATIONS:
These are non-negotiable. Use obnoxious emoji combos generously, making sure each punchline is amplified by the cringe-inducing power of emoji chaos:
- 😂🫵 | 🤡💀 | 🍽️❌😂 | 📉🤣 | 🧢🤔💀
- 🤳🤢👎 | 🎯❌😬 | 🧠🚫🤦‍♂️ | 🎩🐂😒
- 🚪🚶‍♂️🙅 | 🗣️⚡🫠 | 🎤🔥✌️ | 🎥👀💀
- 💎🤔💸❌ | 😂🙅‍♀️🤷‍♂️ | 💔😂☠️ | 🥶❌🕶️
- 🔥🥩💨 | 📜✍️🤣 | 🚩🤦‍♀️💀 | 🤣🤣🤣
- 🔌⚡🛁 | 🐶💨 | **AND MORE.**
---
**Now roast this wallet like it owes you gas fees and a kidney. 🔥**`;
}


export async function generateRoast(summary: string): Promise<string> {
try {
const prompt = getPrompt(); // roast prompt

// Run high temperature LLM inference on prompt and summary
return await runLLMInference(prompt, summary);
} catch (error) {
console.error("Error generating account roast:", error);
throw error;
}
}

0 comments on commit be77aed

Please sign in to comment.