flowxo-http-bot-samplescript.js7 matches
9const userName = "Some User";
1011function makeMessage(messageText) {
12return {
13channel: {
25}
2627function sendNewMessage(message) {
28const payload = makeMessage(message);
29const opts = {
37}
3839function formatMessage(payload, from) {
40const message = JSON.stringify(payload.message.text || payload.message)
41.replace(/(\\n)+/, "<br/>");
49}
5051function appendNewMessage(data) {
52const message = data.message;
53if (!message.message || message.message_type === "action") {
59}
6061function resetMessages() {
62return fetch("/reset");
63}
6465function getMessages() {
66return fetch("/messages")
67.then((response) => response.json())
69}
7071function displayMessages(messages) {
72messageList.innerHTML = "";
73messages.forEach(appendNewMessage);
Gemini-2-5-Pro-O-01main.tsx17 matches
83].filter(Boolean);
8485function authenticateRequest(req: Request): { isValid: boolean; error?: string } {
86if (!BOT_ACCESS_KEY) {
87console.warn("Warning: BOT_ACCESS_KEY is not set in environment variables");
110}
111112function createPoeClient(apiKey: string): OpenAI {
113return new OpenAI({
114apiKey: apiKey || "YOUR_POE_API_KEY",
117}
118119function selectOptimalTokens(contentLength: number, taskType: string): number {
120if (taskType === "Image Generation") return 1024;
121if (contentLength < 100) return 1024; // Short queries
124}
125126async function callSinglePoeModel(
127model: string,
128prompt: string,
169}
170171async function callPoeModelParallel(
172models: string[],
173prompt: string,
260}
261262async function imageToBase64(imageUrl: string): Promise<{ data: string; mimeType: string }> {
263try {
264const response = await fetch(imageUrl, { timeout: 8000 });
276}
277278async function callGeminiApi(
279config: ModelConfig,
280prompt: string,
338}
339340async function generateImage(prompt: string, send: SendEventFn): Promise<void> {
341let cleanPrompt = prompt;
342if (cleanPrompt.endsWith('--image')) {
364}
365366async function generateText(prompt: string, send: SendEventFn, useClaudeModels: boolean = false): Promise<void> {
367send("text", { text: `💬 Processing...` });
368391}
392393async function analyzeFile(fileContent: string, fileName: string, userPrompt: string, send: SendEventFn): Promise<void> {
394if (!fileContent || fileContent.trim().length === 0) {
395send("error", {
436}
437438async function analyzeImage(imageUrl: string, userPrompt: string, send: SendEventFn): Promise<void> {
439let analysisPrompt: string;
440if (!userPrompt || userPrompt.trim().length === 0) {
468}
469470async function performSearch(query: string, send: SendEventFn): Promise<void> {
471const searchPrompt = `Search for comprehensive, current information about: ${query}\n\nProvide detailed, accurate information with sources and references where available. Focus on the most recent and relevant information.`;
472494}
495496function detectIntent(content: string, hasAttachments: boolean): { intent: string; useClaudeModels: boolean } {
497const lowerContent = content.toLowerCase();
498let useClaudeModels = false;
541}
542543async function getResponse(req: Query, send: SendEventFn) {
544send("meta", { content_type: "text/markdown" });
545649}
650651async function getBotSettings(): Promise<BotSettings> {
652const rateCard = "| Task Type | Price |\n" +
653"|-----------|-------|\n" +
716) => void;
717718function encodeEvent(event: string, data: any = {}) {
719return new TextEncoder().encode(
720`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`,
722}
723724export default async function (req: Request): Promise<Response> {
725if (req.method !== "OPTIONS") {
726const authResult = authenticateRequest(req);
SonarMiniAppScreen.tsx6 matches
8import { fetchMiniApp } from '../util/neynar.ts'
910export function MiniAppScreen() {
11const { data: miniapp, isLoading } = useMiniAppFromParams()
1229}
3031function MiniAppNav() {
32const { url } = useParams()
33const encodedUrl = encodeURIComponent(url)
40}
4142export function MiniAppManifest() {
43const { data: miniapp } = useMiniAppFromParams()
44if (!miniapp) return null
46}
4748export function MiniAppEmbed() {
49const { data: miniapp } = useMiniAppFromParams()
50if (!miniapp) return null
52}
5354export function MiniAppDebug() {
55const { data: miniapp } = useMiniAppFromParams()
56if (!miniapp) return null
58}
5960function useMiniAppFromParams() {
61const { url } = useParams()
62return useQuery({ queryKey: ['mini-app', url], queryFn: () => fetchMiniApp(url), staleTime: 1000 * 60 * 5 })
Gemini-2-5-Pro-O-02main.tsx17 matches
83].filter(Boolean);
8485function authenticateRequest(req: Request): { isValid: boolean; error?: string } {
86if (!BOT_ACCESS_KEY) {
87console.warn("Warning: BOT_ACCESS_KEY is not set in environment variables");
110}
111112function createPoeClient(apiKey: string): OpenAI {
113return new OpenAI({
114apiKey: apiKey || "YOUR_POE_API_KEY",
117}
118119function selectOptimalTokens(contentLength: number, taskType: string): number {
120if (taskType === "Image Generation") return 1024;
121if (contentLength < 100) return 1024; // Short queries
124}
125126async function callSinglePoeModel(
127model: string,
128prompt: string,
169}
170171async function callPoeModelParallel(
172models: string[],
173prompt: string,
260}
261262async function imageToBase64(imageUrl: string): Promise<{ data: string; mimeType: string }> {
263try {
264const response = await fetch(imageUrl, { timeout: 8000 });
276}
277278async function callGeminiApi(
279config: ModelConfig,
280prompt: string,
338}
339340async function generateImage(prompt: string, send: SendEventFn): Promise<void> {
341let cleanPrompt = prompt;
342if (cleanPrompt.endsWith('--image')) {
364}
365366async function generateText(prompt: string, send: SendEventFn, useClaudeModels: boolean = false): Promise<void> {
367send("text", { text: `💬 Processing...` });
368391}
392393async function analyzeFile(fileContent: string, fileName: string, userPrompt: string, send: SendEventFn): Promise<void> {
394if (!fileContent || fileContent.trim().length === 0) {
395send("error", {
436}
437438async function analyzeImage(imageUrl: string, userPrompt: string, send: SendEventFn): Promise<void> {
439let analysisPrompt: string;
440if (!userPrompt || userPrompt.trim().length === 0) {
468}
469470async function performSearch(query: string, send: SendEventFn): Promise<void> {
471const searchPrompt = `Search for comprehensive, current information about: ${query}\n\nProvide detailed, accurate information with sources and references where available. Focus on the most recent and relevant information.`;
472494}
495496function detectIntent(content: string, hasAttachments: boolean): { intent: string; useClaudeModels: boolean } {
497const lowerContent = content.toLowerCase();
498let useClaudeModels = false;
541}
542543async function getResponse(req: Query, send: SendEventFn) {
544send("meta", { content_type: "text/markdown" });
545649}
650651async function getBotSettings(): Promise<BotSettings> {
652const rateCard = "| Task Type | Price |\n" +
653"|-----------|-------|\n" +
716) => void;
717718function encodeEvent(event: string, data: any = {}) {
719return new TextEncoder().encode(
720`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`,
722}
723724export default async function (req: Request): Promise<Response> {
725if (req.method !== "OPTIONS") {
726const authResult = authenticateRequest(req);
22import { UsersScreen } from './screens/UsersScreen.tsx'
2324export function App() {
25const navigate = useNavigate()
2693}
9495function About() {
96return (
97<Section className="flex flex-col items-start gap-3 m-5">
flowxo-http-bot-samplebot.ts4 matches
27});
2829app.get("/messages", function async(c) {
30return c.json({ messages });
31});
3233//Clear messages
34app.get("/reset", function (request, response) {
35messages = [];
36});
3738//Receive a message from Flow XO
39app.post("/out", async function (c) {
40const msg = await c.req.json();
41console.log("RECEIVED A MESSAGE", JSON.stringify(msg, null, 2));
4546//Send a message to Flow XO
47app.post("/in", async function (c) {
48const message = await c.req.json();
49const url = BOT_URL;
10import module_path from "./module_path.tsx"
1112async function main() {
13const grid_shader = await (await fetch(`${module_path}/grid.wgsl`)).text();
14210let depth_texture: GPUTexture;
211212function render() {
213const fov = 60 * Math.PI / 180;
214const aspect = canvas.width / canvas.height;
292}
293294function fail(msg: string) {
295alert(msg);
296}
1export default function () {
2const body = `<!doctype html>
3<html lang="en">
101102/************************************************************************
103* State: raw variables & functions, and evaluated variables
104************************************************************************/
105const rawVars = new Map(); // name -> rhs string (raw)
106const functions = new Map(); // name -> { params: [], body: "..." }
107const computedVars = new Map(); // name -> evaluated value (primitive, array, string, etc)
108110* Helpers
111************************************************************************/
112function isQuotedString(s) {
113return (s.length >= 2) && ((s[0] === '"' && s[s.length-1] === '"') || (s[0] === "'" && s[s.length-1] === "'"));
114}
115116function toObj(map) {
117const o = Object.create(null);
118for (const [k,v] of map.entries()) o[k] = v;
122// Evaluate an expression string in a sandbox that includes:
123// - current computedVars
124// - user functions (as JS functions that evaluate their bodies with the same sandbox + parameters)
125// - builtins
126function evalWithScope(expr) {
127// Build base scope
128const scope = Object.assign({}, builtins, toObj(computedVars));
129// attach user functions into scope as callables
130for (const [name, def] of functions.entries()) {
131scope[name] = (...args) => {
132// local scope that includes current computedVars and builtins, plus params
135try {
136// Use with(scope) { return (body) } to allow body to reference names
137return Function('scope', 'with(scope){ return (' + def.body + ') }')(local);
138} catch (e) {
139// propagate error
145// Now evaluate expression in the scope
146try {
147return Function('scope', 'with(scope){ return (' + expr + ') }')(scope);
148} catch (e) {
149throw e;
153/************************************************************************
154* Parse the document top-down:
155* - function defs f(a,b)=...
156* - variable defs name = rhs (rhs may be quoted string OR an expression)
157*
158* We evaluate variables in document order so earlier defs are available to later ones.
159************************************************************************/
160function parseDocument(doc) {
161rawVars.clear();
162functions.clear();
163computedVars.clear();
164168if (!line) continue;
169170// function: name(arg1, arg2) = body
171const fm = line.match(/^([A-Za-z_][\\w]*)\\s*\\(([^)]*)\\)\\s*=\\s*(.+)$/);
172if (fm) {
174const params = fm[2].split(',').map(s=>s.trim()).filter(Boolean);
175const body = fm[3].trim();
176functions.set(name, { params, body });
177continue;
178}
185rawVars.set(name, rhs);
186187// attempt to evaluate using current environment (earlier vars + functions)
188try {
189let value;
280}, { decorations: v => v.decorations });
281282function stringifyValue(v) {
283if (v === null || v === undefined) return String(v);
284if (typeof v === 'number') {
SonarMiniAppsScreen.tsx3 matches
8import { Feed } from '../components/Post.tsx'
910export function MiniAppsScreen() {
11return (
12<div>
22}
2324function MiniAppsList() {
25return (
26<Feed
33}
3435function MiniApp({ miniapp }) {
36const { fcsdk, context } = useFarcasterMiniApp()
37const navigate = useNavigate()