Towniequeries.tsx6 matches
7// but in the meantime, we can cache user info in memory
8const userIdCache: { [key: string]: any } = {};
9export async function getUser(bearerToken: string) {
10if (userIdCache[bearerToken]) return userIdCache[bearerToken];
1116}
1718async function last24Hours(userId: string) {
19const usage = await sqlite.execute(
20`SELECT
40"devto": 100, // hardcoded limit of $100 per day for dev.to, billed later
41};
42export async function overLimit(bearerToken: string) {
43const user = await getUser(bearerToken);
44const last24HourUsage = await last24Hours(user.id);
49}
5051export async function insertInferenceCall({
52usage_id,
53input_tokens,
103}
104105export async function startTrackingUsage({
106bearerToken,
107val_id,
145}
146147export async function finishTrackingUsage({
148rowid,
149input_tokens,
acdctest_loading.html4 matches
65let errorResources = 0;
66
67// Function to update loading status
68function updateLoadingStatus() {
69const loadedPercentage = Math.round((loadedResources / totalResources) * 100);
70document.getElementById('loading-time').textContent =
72}
73
74// Function to extract filename from URL for display
75function getFilenameFromUrl(url) {
76const parts = url.split('/');
77let filename = parts[parts.length - 1];
excel_to_roadmaproadmap.ts25 matches
1export default async function (req: Request) {
2// Parse the roadmap data
3const roadmapData = [
586];
587
588// Helper function to determine which quarter a date falls into
589function getQuarter(dateStr) {
590const date = new Date(dateStr);
591for (let i = 0; i < quarters.length; i++) {
655
656// Generate task cards
657function generateTaskCards() {
658const taskCardsContainer = document.getElementById('task-cards');
659taskCardsContainer.innerHTML = '';
711}
712
713// Function to update visible tasks based on filters
714function updateVisibleTasks() {
715document.querySelectorAll('#task-cards .task-card').forEach(card => {
716if (activeCategories.includes(card.dataset.category)) {
723
724// Timeline Chart
725function createTimelineChart() {
726const ctx = document.getElementById('timeline-chart').getContext('2d');
727
774},
775ticks: {
776callback: function(value, index, values) {
777const date = new Date(value);
778const month = date.getMonth();
796tooltip: {
797callbacks: {
798label: function(context) {
799const task = context.raw.task;
800const startDate = new Date(task.startDate).toLocaleDateString();
826}
827
828// Function to update chart theme
829function updateChartTheme() {
830if (window.timelineChart) {
831// Update colors
847}
848
849// Function to add quarter dividers and labels
850function addQuarterMarkings() {
851const markersContainer = document.getElementById('quarter-markers');
852markersContainer.innerHTML = '';
884}
885
886// Function to add milestone markers
887function addMilestoneMarkers() {
888const milestones = roadmapData.filter(task => task.type === 'Milestone');
889const markersContainer = document.getElementById('milestone-markers');
928}
929
930// Function to update chart based on filters
931function updateChart() {
932// Update dataset visibility
933window.timelineChart.data.datasets.forEach(dataset => {
948}
949
950// Function to update chart data
951function updateChartData() {
952// Recreate datasets
953const datasets = categories.map(category => {
982}
983
984// Tooltip functions
985const tooltip = document.getElementById('tooltip');
986
987function showTooltip(element, task) {
988const rect = element.getBoundingClientRect();
989const startDate = new Date(task.startDate).toLocaleDateString();
1006}
1007
1008function hideTooltip() {
1009tooltip.style.opacity = '0';
1010}
1011
1012// Edit modal functions
1013const editModal = document.getElementById('edit-modal');
1014const closeModalBtn = document.getElementById('close-modal');
1017const editForm = document.getElementById('edit-task-form');
1018
1019function openEditModal(index) {
1020const task = roadmapData[index];
1021
1033}
1034
1035function closeEditModal() {
1036editModal.classList.remove('active');
1037}
IdkbasicAgent.ts1 match
3* This is useful for testing if the Val Town HTTP endpoints are working
4*/
5export default function(req: Request): Response {
6// Get current timestamp
7const timestamp = new Date().toISOString();
IdkdeepResearchAgent.ts7 matches
15* 3. Compiling findings into a comprehensive report
16*/
17export default async function(req: Request): Promise<Response> {
18console.log("Received request:", req.method, req.url);
19
101}
102103// Only accept POST requests for API functionality
104if (req.method !== "POST") {
105return new Response(JSON.stringify({ error: "Method not allowed" }), {
169* Conducts comprehensive research on a topic
170*/
171async function conductResearch(topic: string, depth: "light" | "medium" | "deep" = "medium"): Promise<ResearchReport> {
172// Step 1: Break down the topic into subtopics
173const subtopics = await generateSubtopics(topic, depth);
194* Generates a list of subtopics for the main research topic
195*/
196async function generateSubtopics(topic: string, depth: string): Promise<string[]> {
197const depthMap = {
198"light": 3,
263* Generates default subtopics if the AI-generated ones fail
264*/
265function generateDefaultSubtopics(topic: string, count: number): string[] {
266const defaultSubtopics = [
267`Overview of ${topic}`,
283* Researches a specific subtopic in detail
284*/
285async function researchSubtopic(mainTopic: string, subtopic: string, depth: string): Promise<SubtopicResearch> {
286const depthMap = {
287"light": 300,
327* Generates an executive summary based on all the research
328*/
329async function generateExecutiveSummary(topic: string, subtopicResearch: SubtopicResearch[]): Promise<string> {
330try {
331// Create a condensed version of the research to fit within token limits
IdksimpleTest.ts1 match
2* Simple test to verify that HTTP endpoints are working
3*/
4export default function(req: Request): Response {
5const html = `<!DOCTYPE html>
6<html lang="en">
IdktestAgent.ts1 match
3* This will make a simple request to the agent and log the results
4*/
5export default async function(req: Request): Promise<Response> {
6try {
7// Get the URL of the current request to determine the agent URL
1016. **Check Response Format**: If you're calling the API directly, ensure your request format is correct.
1021037. **Run the Test Endpoint**: Use the test endpoint to verify basic functionality.
104105## Customization
107You can modify the agent to suit your specific research needs:
108109- Adjust the number of subtopics based on depth in the `generateSubtopics` function
110- Change the word count for each subtopic in the `researchSubtopic` function
111- Modify the system prompts to focus on specific aspects of research
112
IdkresearchInterface.ts2 matches
4* A simple web interface to interact with the Deep Research Agent
5*/
6export default function(req: Request): Response {
7// Get the current URL to determine the agent URL
8const url = new URL(req.url);
113<script>
114// Simple markdown parser
115function parseMarkdown(text) {
116if (!text) return '';
117
New-Tweet-Alertmain.tsx3 matches
70}
7172export default async function(req: Request): Promise<Response> {
73if (req.method !== "POST") {
74return new Response("This Val can only process POST requests from SocialData", {
104}
105106async function sendEventToTelegram(event: NewTweetEvent): Promise<void> {
107const tweet = event.data;
108const user = tweet.user;
169}
170171async function sendPhotoToTelegram(photoUrl: string): Promise<void> {
172const telegramApiUrl = `https://api.telegram.org/bot${telegramBotApiToken}/sendPhoto`;
173