### Install Just Prompt Source: https://github.com/disler/just-prompt/blob/main/README.md Installs the Just Prompt project by cloning the repository and synchronizing dependencies using 'uv sync'. This process sets up the necessary environment for running the MCP server. ```bash git clone https://github.com/yourusername/just-prompt.git cd just-prompt uv sync ``` -------------------------------- ### Install Google GenAI SDK Source: https://github.com/disler/just-prompt/blob/main/ai_docs/google-genai-api-update.md Installs the Google GenAI SDK using pip. This is the first step to integrate generative AI models into your Python applications. ```bash pip install google-genai ``` -------------------------------- ### List Ollama Models Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/diff.md Retrieves and prints a list of models available locally via Ollama. Requires the 'ollama' library to be installed. ```python import ollama def list_ollama_models(): print(ollama.list()) ``` -------------------------------- ### List OpenAI Models Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/diff.md Fetches and prints a list of available models from OpenAI using the OpenAI Python client. Ensure the 'openai' library is installed. ```python from openai import OpenAI def list_openai_models(): client = OpenAI() print(client.models.list()) ``` -------------------------------- ### Start Chat Session Source: https://github.com/disler/just-prompt/blob/main/ai_docs/google-genai-api-update.md Initiates a chat session with a specified Gemini model. Allows for conversational interactions by sending messages and receiving responses. ```python chat = client.chats.create(model='gemini-2.0-flash-001') response = chat.send_message('tell me a story') print(response.text) ``` -------------------------------- ### Example Usage of Prompt from File to File with Context Source: https://github.com/disler/just-prompt/blob/main/specs/prompt_from_file_to_file_w_context.md Demonstrates how to use the 'prompt_from_file_to_file_w_context' tool. It shows a sample prompt file content with the '{{context_files}}' placeholder and a Python code snippet illustrating a tool call with specific files and models. ```Python # Prompt file content (example.txt): """ Please analyze the following codebase files: {{context_files}} Based on the code above, suggest improvements for better performance. """ # Tool call: prompt_from_file_to_file_w_context( from_file="prompts/example.txt", context_files=[ "/absolute/path/to/src/main.py", "/absolute/path/to/src/utils.py", "/absolute/path/to/README.md" ], models_prefixed_by_provider=["openai:gpt-4o", "anthropic:claude-3-5-sonnet"], output_dir="analysis_results" ) ``` -------------------------------- ### cURL Request for Groq API Chat Completion Source: https://github.com/disler/just-prompt/blob/main/specs/init-just-prompt.md This example shows how to make a chat completion request to the Groq API using cURL. It includes the necessary headers for authentication and the request body with the model and messages. ```curl curl \ https://api.groq.com/openai/v1/chat/completions \ -H "Authorization: Bearer $GROQ_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "messages": [ { "role": "user", "content": "Explain the importance of fast language models" } ], "model": "llama-3.3-70b-versatile" }' ``` -------------------------------- ### React Timer with Refs for Interval and Start Time Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_groq_qwen-qwq-32b.md This example shows an alternative approach using `useRef` to manage the interval ID and the initial start time. This can help avoid stale closures within the interval callback, ensuring the most up-to-date state is used. ```jsx import React, { useState, useEffect, useRef } from 'react'; function Timer({ startTime, onFinished }) { const [remaining, setRemaining] = useState(startTime); const intervalIdRef = useRef(null); const startTimeRef = useRef(startTime); useEffect(() => { intervalIdRef.current = setInterval(() => { setRemaining(prev => { const newTime = prev - 1; if (newTime <= 0) { clearInterval(intervalIdRef.current); if (onFinished) { onFinished(); } } return newTime; }); }, 1000); return () => { if (intervalIdRef.current) { clearInterval(intervalIdRef.current); } }; }, []); return (
Time remaining: {remaining}
); } ``` -------------------------------- ### Configure LLM Provider API Keys Source: https://github.com/disler/just-prompt/blob/main/README.md Sets up environment variables for LLM provider API keys by copying a sample configuration file and editing it with actual API credentials. This is crucial for authenticating with services like OpenAI, Anthropic, and Gemini. ```bash cp .env.sample .env OPENAI_API_KEY=your_openai_api_key_here ANTHROPIC_API_KEY=your_anthropic_api_key_here GEMINI_API_KEY=your_gemini_api_key_here GROQ_API_KEY=your_groq_api_key_here DEEPSEEK_API_KEY=your_deepseek_api_key_here OLLAMA_HOST=http://localhost:11434 ``` -------------------------------- ### Server Serve Function Source: https://github.com/disler/just-prompt/blob/main/specs/init-just-prompt.md The 'serve' function in 'server.py' is responsible for initiating the server, optionally accepting a provider and model string to configure the default LLM. ```Python def serve(weak_provider_and_model: str = "o:gpt-4o-mini") -> None: # Implementation for starting the server pass ``` -------------------------------- ### Deriving 'Low' Status Based on Remaining Time Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_groq_qwen-qwq-32b.md This code demonstrates how to determine if the remaining time is below a certain threshold (10% of the initial start time). It uses a ref to store the initial start time and calculates the threshold for comparison. ```javascript const initialStartTimeRef = useRef(startTime); const threshold = 0.1 * initialStartTimeRef.current; const isLow = remaining < threshold; ``` -------------------------------- ### List Available LLM Providers Source: https://github.com/disler/just-prompt/blob/main/README.md Retrieves a list of all supported LLM providers that the Just Prompt server can interact with. This tool requires no parameters. ```python # Example usage of the 'list_providers' tool # client.call("list_providers") ``` -------------------------------- ### Python Function for CEO and Board Prompting Source: https://github.com/disler/just-prompt/blob/main/specs/new-tool-llm-as-a-ceo.md Defines the `ceo_and_board_prompt` function in Python. This function orchestrates the process of getting decisions from a 'board' of AI models and then using a CEO model to make a final decision. It utilizes `prompt_from_file_to_file` to get responses from the board and then constructs a CEO decision prompt with these responses. ```Python def ceo_and_board_prompt(from_file: str, output_dir: str = ., models_prefixed_by_provider: List[str] = None, ceo_model: str = DEFAULT_CEO_MODEL, ceo_decision_prompt: str = DEFAULT_CEO_DECISION_PROMPT) -> None: ``` -------------------------------- ### List Models for a Provider Source: https://github.com/disler/just-prompt/blob/main/README.md Fetches a list of available models for a specified LLM provider. Requires the provider name (e.g., 'openai' or 'ollama') as a parameter. ```python # Example usage of the 'list_models' tool # client.call("list_models", provider="openai") ``` -------------------------------- ### Create Vertex AI Client Source: https://github.com/disler/just-prompt/blob/main/ai_docs/google-genai-api-update.md Creates a client instance for Vertex AI. Requires project ID and location for authentication and service endpoint configuration. ```python from google import genai client = genai.Client( vertexai=True, project='your-project-id', location='us-central1' ) ``` -------------------------------- ### Calculate Low Threshold Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_groq_qwen-qwq-32b.md Calculates a threshold for indicating low time remaining based on a percentage of the initial start time. ```javascript const lowThreshold = 0.1 * startTime; ``` -------------------------------- ### Plan and Create Python Project with OpenAI Source: https://github.com/disler/just-prompt/blob/main/ai_docs/openai-reasoning-effort.md This snippet demonstrates using the OpenAI API to generate a plan for a Python application's file structure and then create the necessary files. The prompt outlines a use case for a question-answering app with a database and asks for a structured output. ```javascript import OpenAI from "openai"; const openai = new OpenAI(); const prompt = ` I want to build a Python app that takes user questions and looks them up in a database where they are mapped to answers. If there is close match, it retrieves the matched answer. If there isn't, it asks the user to provide an answer and stores the question/answer pair in the database. Make a plan for the directory structure you'll need, then return each file in full. Only supply your reasoning at the beginning and end, not throughout the code. `.trim(); const response = await openai.responses.create({ model: "o4-mini", input: [ { role: "user", content: prompt, }, ], }); console.log(response.output_text); ``` ```python from openai import OpenAI client = OpenAI() prompt = """ I want to build a Python app that takes user questions and looks them up in a database where they are mapped to answers. If there is close match, it retrieves the matched answer. If there isn't, it asks the user to provide an answer and stores the question/answer pair in the database. Make a plan for the directory structure you'll need, then return each file in full. Only supply your reasoning at the beginning and end, not throughout the code. """ response = client.responses.create( model="o4-mini", input=[ { "role": "user", "content": prompt } ] ) print(response.output_text); ``` -------------------------------- ### Python Chat Completion with Groq API Source: https://github.com/disler/just-prompt/blob/main/specs/init-just-prompt.md This Python code demonstrates how to use the Groq Python library to perform a chat completion. It initializes the client with the API key from the environment variable and sends a user message to the specified model. ```python import os from groq import Groq client = Groq( api_key=os.environ.get("GROQ_API_KEY"), ) chat_completion = client.chat.completions.create( messages=[ { "role": "user", "content": "Explain the importance of fast language models", } ], model="llama-3.3-70b-versatile", ) print(chat_completion.choices[0].message.content) ``` -------------------------------- ### Run Project Tests Source: https://github.com/disler/just-prompt/blob/main/README.md This command executes the project's tests using pytest. It's a standard command for ensuring the project's code quality and functionality. ```bash uv run pytest ``` -------------------------------- ### JavaScript Countdown Timer Class Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_groq_qwen-qwq-32b.md A class that manages a countdown timer. It handles time tracking, display updates, and emits an event when the timer finishes. The timer can be configured with a start time and a time format. ```javascript class CountdownTimer { constructor(el, startTime, format, onFinish ) { this.el = el; this.startTime = startTime; this.remaining = startTime; this.format = format; this.onFinish = onFinish; this.threshold = this.startTime *0.1; }; start() { const timer = this; this.timerInterval = setInterval(() => { if (timer.remaining >0) { timer.remaining--; timer.updateView(); } else { timer.stop(); timer.onFinish?.(); } }, 1000); } formatTime() { const pad = (n) => n.toString().padStart(2, '0'); if (this.format ===0) { const mins = Math.floor(this.remaining/60); return `${pad(min)}:${pad this.remaining%60`; } else { // HH:MM:SS const hours = this.remaining / 3600 |0; const mins = (this.remaining % 3600 /60 ) |0; const secs = this.remaining %60; return `${pad hours}:${pad mins}:${pad secs`; } } updateView() { this.el.textContent = this.formatTime(); this.checkLow(); } checkLow() { this.el.classList.toggle('low', this.remaining < this.threshold); } stop() { clearInterval(this.timerInterval); } } // Usage example: const countdown = new CountdownTimer(document.getElementById('countdown'), 120, 0, () => alert('Done!'); countdown.start(); ``` -------------------------------- ### Listing Available AI Providers Source: https://github.com/disler/just-prompt/blob/main/specs/init-just-prompt.md This function retrieves and returns a list of all supported AI providers that the system can interact with. It's essential for discovering which services are available for prompting. ```Python def list_providers() -> List[str]: # Implementation details for listing available AI providers pass ``` -------------------------------- ### Vue 3 Countdown Component Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_o_gpt-4.5-preview.md A countdown component for Vue 3 using the Composition API. It uses `ref` for reactive state, `onMounted` to start the interval, and `onUnmounted` for cleanup. The component accepts a `startTime` prop. ```vue ``` ```vue ``` -------------------------------- ### Groq LLM Provider Prompting Source: https://github.com/disler/just-prompt/blob/main/specs/init-just-prompt.md Facilitates communication with Groq's LLM services. It includes a 'prompt' function for text-based interactions and a 'list_models' function to enumerate supported models. ```Python def prompt(text, model) -> str: # Implementation for Groq prompting pass def list_models() -> List[str]: # Implementation to list Groq models pass ``` -------------------------------- ### Vue.js Countdown Timer Component Source: https://github.com/disler/just-prompt/blob/main/prompts/countdown_component.txt A Vue.js component that implements a countdown timer. It accepts start time and display format as props and emits a 'finished' event upon completion. Includes logic for low-time indication. ```Vue.js ``` -------------------------------- ### Configure Google Gemini Thinking Budget Source: https://github.com/disler/just-prompt/blob/main/README.md Utilize extended thinking capabilities for the Google Gemini model by setting a thinking budget. Suffixes like ':1k', ':4k', or specific token counts can be appended. The system adjusts values to fit within the supported range of 0 to 24576. ```python gemini:gemini-2.5-flash-preview-04-17:1k gemini:gemini-2.5-flash-preview-04-17:4k gemini:gemini-2.5-flash-preview-04-17:8000 ``` -------------------------------- ### Time Formatting Helper Function Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_groq_qwen-qwq-32b.md This example shows a helper function for formatting time, specifically converting seconds into a 'MM:SS' format. It handles padding with leading zeros for minutes and seconds to ensure a consistent display. ```javascript function formatMMSS(time) { const minutes = Math.floor(time / 60); const seconds = time % 60; return `${String(minutes).padStart(2, '0')}:${seconds.toString().padStart(2, '0')}` } ``` -------------------------------- ### Vanilla JavaScript Countdown Timer Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_q_deepseek-r1-distill-llama-70b-specdec.md A Vanilla JavaScript class for a countdown timer. It manages the countdown state, handles time formatting, allows for a callback on completion, and adds a 'low' class to the element when time is below 10% of the start time. ```JavaScript class CountdownTimer { constructor(elementId, startTime, format = 'MM:SS', onFinish) { this.element = document.getElementById(elementId); this.startTime = startTime; this.format = format; this.onFinish = onFinish; this.timeLeft = startTime; this.interval = null; this.isTimeLow = false; } start() { this.interval = setInterval(() => { this.timeLeft--; this.updateDisplay(); if (this.timeLeft === 0) { clearInterval(this.interval); if (this.onFinish) { this.onFinish(); } } }, 1000); } updateDisplay() { this.element.textContent = this.formatTime(this.timeLeft); this.isTimeLow = this.timeLeft <= this.startTime * 0.1; if (this.isTimeLow) { this.element.classList.add('low'); } else { this.element.classList.remove('low'); } } formatTime(totalSeconds) { let hours = 0; let minutes = 0; let seconds = totalSeconds; if (this.format === 'HH:MM:SS') { hours = Math.floor(totalSeconds / 3600); minutes = Math.floor((totalSeconds % 3600) / 60); seconds = totalSeconds % 60; } else { minutes = Math.floor(totalSeconds / 60); seconds = totalSeconds % 60; } const pad = (num) => String(num).padStart(2, '0'); if (this.format === 'HH:MM:SS') { return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`; } else { return `${pad(minutes)}:${pad(seconds)}`; } } stop() { clearInterval(this.interval); } } /* Sample Usage:
*/ ``` -------------------------------- ### Create Gemini Developer API Client Source: https://github.com/disler/just-prompt/blob/main/ai_docs/google-genai-api-update.md Creates a client instance for the Gemini Developer API. Requires an API key for authentication. ```python from google import genai client = genai.Client(api_key='GEMINI_API_KEY') ``` -------------------------------- ### React Countdown Timer Component Source: https://github.com/disler/just-prompt/blob/main/prompts/countdown_component.txt A React component for a countdown timer. It utilizes the `useState` and `useEffect` hooks to manage the timer state and side effects. Supports custom start time and display format, emitting a callback on completion. ```React import React, { useState, useEffect } from 'react'; function CountdownTimer({ startTime, format = 0, onFinished }) { const [remainingTime, setRemainingTime] = useState(startTime); useEffect(() => { const intervalId = setInterval(() => { setRemainingTime(prevTime => { if (prevTime <= 1) { clearInterval(intervalId); if (onFinished) { onFinished(); } return 0; } return prevTime - 1; }); }, 1000); return () => clearInterval(intervalId); }, [startTime, onFinished]); const formatTime = (totalSeconds) => { if (totalSeconds < 0) return '00:00'; let hours = Math.floor(totalSeconds / 3600); let minutes = Math.floor((totalSeconds % 3600) / 60); let seconds = totalSeconds % 60; if (format === 0) { hours = 0; } const paddedHours = hours.toString().padStart(2, '0'); const paddedMinutes = minutes.toString().padStart(2, '0'); const paddedSeconds = seconds.toString().padStart(2, '0'); if (format === 1) { return `${paddedHours}:${paddedMinutes}:${paddedSeconds}`; } else { return `${paddedMinutes}:${paddedSeconds}`; } }; const isLowTime = remainingTime > 0 && remainingTime < startTime * 0.1; return (
{formatTime(remainingTime)}
); } export default CountdownTimer; ``` -------------------------------- ### LLM Cost Comparison (May 2025 Prices) Source: https://github.com/disler/just-prompt/blob/main/example_outputs/decision_openai_vs_anthropic_vs_google/ceo_medium_decision_openai_vs_anthropic_vs_google_openai_o3_high.md Compares the on-demand cost per 1K tokens for leading LLM models from OpenAI, Anthropic, and Google. Prices are based on May 2025 estimates for prompt and completion, excluding discounts. ```Text Claude 3.5 Sonnet —— $3.00 (input $2.00, output $1.00) GPT-4o-mini —— $3.20 GPT-4o (full) —— $5.00 Gemini 2.5 Pro —— $4.20 (Vertex pay-as-you-go, before sustained-use discounts) ``` -------------------------------- ### Svelte Countdown Timer Component Source: https://github.com/disler/just-prompt/blob/main/prompts/countdown_component.txt A Svelte component for a countdown timer. It manages the countdown logic internally, accepts start time and format via props, and signals completion with a custom event. Includes styling for low-time indication. ```Svelte
{formattedTime}
``` -------------------------------- ### STEM Research Question with OpenAI Source: https://github.com/disler/just-prompt/blob/main/ai_docs/openai-reasoning-effort.md This snippet demonstrates how to use the OpenAI API to get answers to scientific research questions. It prompts the model to identify compounds for antibiotic research and provide justifications, showcasing its utility in STEM fields. ```javascript import OpenAI from "openai"; const openai = new OpenAI(); const prompt = ` What are three compounds we should consider investigating to advance research into new antibiotics? Why should we consider them? `; const response = await openai.responses.create({ model: "o4-mini", input: [ { role: "user", content: prompt, }, ], }); console.log(response.output_text); ``` ```python from openai import OpenAI client = OpenAI() prompt = """ What are three compounds we should consider investigating to advance research into new antibiotics? Why should we consider them? """ response = client.responses.create( model="o4-mini", input=[ { "role": "user", "content": prompt } ] ) print(response.output_text); ``` -------------------------------- ### Configure Default Models in .mcp.json Source: https://github.com/disler/just-prompt/blob/main/README.md This JSON configuration sets up the 'just-prompt' MCP server with default AI models. It specifies the command to run and includes a list of default models for various providers like OpenAI, Anthropic, and Gemini. ```json { "mcpServers": { "just-prompt": { "type": "stdio", "command": "uv", "args": [ "--directory", ".", "run", "just-prompt", "--default-models", "openai:o3:high,openai:o4-mini:high,anthropic:claude-opus-4-20250514,anthropic:claude-sonnet-4-20250514,gemini:gemini-2.5-pro-preview-03-25,gemini:gemini-2.5-flash-preview-04-17" ], "env": {} } } } ``` -------------------------------- ### Use Reasoning Model with Responses API (Python) Source: https://github.com/disler/just-prompt/blob/main/ai_docs/openai-reasoning-effort.md Shows how to interact with the OpenAI Responses API using a reasoning model (o4-mini) in Python. The example includes a prompt for generating a bash script and sets the reasoning effort to 'high'. ```python from openai import OpenAI client = OpenAI() prompt = """ Write a bash script that takes a matrix represented as a string with format '[1,2],[3,4],[5,6]' and prints the transpose in the same format. """ response = client.responses.create( model="o4-mini", reasoning={"effort": "high"}, input=[ { "role": "user", "content": prompt } ] ) print(response.output_text) ``` -------------------------------- ### Vue.js Countdown Timer Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_q_deepseek-r1-distill-llama-70b-specdec.md A Vue.js single-file component for a countdown timer. It accepts 'start-time' and 'format' props, manages the countdown state, handles time formatting, emits a 'finished' event, and applies a 'low' class when time is below 10% of the start time. ```Vue.js /* Sample Usage: */ ``` -------------------------------- ### List Providers Request Data Model Source: https://github.com/disler/just-prompt/blob/main/specs/init-just-prompt.md Defines the Pydantic data model 'ListProvidersRequest' for requesting a list of available LLM providers. ```Python class ListProvidersRequest(BaseModel): pass ``` -------------------------------- ### Gemini LLM Provider Prompting Source: https://github.com/disler/just-prompt/blob/main/specs/init-just-prompt.md Enables interaction with Gemini LLM models. The 'prompt' function handles text input and model responses, while 'list_models' retrieves a list of available Gemini models. ```Python def prompt(text, model) -> str: # Implementation for Gemini prompting pass def list_models() -> List[str]: # Implementation to list Gemini models pass ``` -------------------------------- ### Vue.js Countdown Timer Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_groq_qwen-qwq-32b.md A Vue.js 3 component that implements a countdown timer. It accepts startTime and format props, manages remaining time, formats it, and emits a 'finished' event. It also applies a 'low' class when the remaining time is below 10% of the start time. ```vue ``` -------------------------------- ### Configure Proxy and SSL Certificate Source: https://github.com/disler/just-prompt/blob/main/ai_docs/google-genai-api-update.md Sets environment variables for configuring HTTPS proxy and SSL certificate files, essential for network communication through proxies. ```bash export HTTPS_PROXY='http://username:password@proxy_uri:port' export SSL_CERT_FILE='client.pem' ``` -------------------------------- ### Vanilla JavaScript Countdown Timer Class Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_groq_qwen-qwq-32b.md A Vanilla JavaScript class for a countdown timer. It encapsulates the timer logic, including starting, ticking, stopping, updating the display, and formatting time. It also handles a low-threshold condition and an optional callback for when the timer finishes. ```javascript class CountdownTimer { constructor(el, startTime, format, onFinished) this.el this.startTime = startTime this.remaining = startTime this.format = format this.onFinished = onFinished this.element = el; this.running = false; this.timeUp() } start() { this.remaining = this.startTime this.update() this.running = true this.intervalId = setInterval(() => this.tick(), 1000) } tick() { this.remaining -= 1; this.updateDisplay(); if (this.remaining <0) this.remaining =0; if (this.remaining === 0) this.stop(); } stop() { clearInterval(this.intervalId; this.onFinished && this.onFinished(); } update() { this.render() } render() { // update DOM with formatted time const formatted = this.formatTime(); this.element.textContent = formatted // add classes for low condition... } formatTime() { // implementation similar to the other variants } // On low threshold condition: isLow() { return this.remaining < (this.startTime * 0.1); } } function createCountdown(target, props, onFinish) { const timer = new CountdownTimer(target, props.startTime, props.format, onFinish) timer.start(); return timer; } ``` -------------------------------- ### Prompt LLM Models from File to File Source: https://github.com/disler/just-prompt/blob/main/README.md Sends a prompt from a file to multiple LLM models and saves their responses as markdown files. Requires the absolute path to the prompt file and an optional absolute path to the output directory. ```python # Example usage of the 'prompt_from_file_to_file' tool # client.call("prompt_from_file_to_file", abs_file_path="/path/to/your/prompt.txt", abs_output_dir="/path/to/output", models_prefixed_by_provider=["l:llama3.1"]) ``` -------------------------------- ### Listing Models for a Specific Provider Source: https://github.com/disler/just-prompt/blob/main/specs/init-just-prompt.md This function queries a specific AI provider and returns a list of all available models offered by that provider. It's crucial for selecting the correct model for a given task. ```Python def list_models(provider: str) -> List[str]: # Implementation details for listing models for a given provider pass ``` -------------------------------- ### Vue 3 Options API Countdown Timer (Conceptual) Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_groq_qwen-qwq-32b.md A conceptual example of a countdown timer using Vue 3's Options API. It demonstrates using `data` for state, `mounted` for lifecycle hooks, and `methods` for logic like ticking and emitting events. ```vue export default { data() { return { remainingTime: this.startTime, }; }, mounted() { this.interval = setInterval( this.tick, 1000 ); }, methods: { tick() { if (this.remainingTime <=0) { this.remainingTime =0; this.$emit('finished'); clearInterval(this.interval); } else { this.remainingTime--; } }, // formatting functions, maybe computed. } } ``` -------------------------------- ### Vanilla JavaScript Countdown Timer Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_openai_o3-mini.md A plain JavaScript implementation of a countdown timer. This example demonstrates how to create a timer function that updates a DOM element, handles time formatting, and triggers a callback when the countdown finishes. It includes logic for visual feedback when the time is low. ```JavaScript // Assuming you have an HTML element with id='timer-display' // and potentially a class to toggle for low time indication. function createCountdownTimer(elementId, startTime, format, onFinished) { const timerDisplay = document.getElementById(elementId); if (!timerDisplay) { console.error(`Element with id '${elementId}' not found.`); return; } let remaining = startTime; let timer = null; function pad(num) { return String(num).padStart(2, "0"); } function formatTime(secs) { if (format === 0) { // MM:SS const minutes = Math.floor(secs / 60); const seconds = secs % 60; return `${pad(minutes)}:${pad(seconds)}`; } else { // HH:MM:SS const hours = Math.floor(secs / 3600); const minutes = Math.floor((secs % 3600) / 60); const seconds = secs % 60; return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`; } } function updateDisplay() { const isLow = remaining <= startTime * 0.1; timerDisplay.textContent = formatTime(remaining); if (isLow) { timerDisplay.style.color = 'red'; // Apply red color for low time } else { timerDisplay.style.color = 'black'; // Default color } } function startTimer() { updateDisplay(); // Initial display timer = setInterval(() => { if (remaining > 0) { remaining--; updateDisplay(); } else { clearInterval(timer); if (onFinished) onFinished(); } }, 1000); } // Start the timer when the function is called startTimer(); // Return a function to stop the timer if needed externally return () => { clearInterval(timer); }; } // Example Usage: // document.addEventListener('DOMContentLoaded', () => { // const stopTimer = createCountdownTimer('timer-display', 120, 0, () => { // console.log('Countdown finished!'); // }); // }); ``` -------------------------------- ### OpenAI LLM Provider Prompting Source: https://github.com/disler/just-prompt/blob/main/specs/init-just-prompt.md Defines the 'prompt' function for interacting with OpenAI models, taking text and a model name as input and returning a string response. It also includes a 'list_models' function to retrieve available models from the provider. ```Python def prompt(text, model) -> str: # Implementation for OpenAI prompting pass def list_models() -> List[str]: # Implementation to list OpenAI models pass ``` -------------------------------- ### Svelte Countdown Timer Source: https://github.com/disler/just-prompt/blob/main/example_outputs/countdown_component/countdown_component_q_deepseek-r1-distill-llama-70b-specdec.md A Svelte component for a countdown timer. It utilizes Svelte's reactivity, accepts 'startTime' and 'format' props, manages the countdown state, handles time formatting, emits a 'finished' event, and applies a 'low' class when time is below 10% of the start time. ```Svelte
{formatTime(timeLeft)}
/* Sample Usage: */ ``` -------------------------------- ### List Providers Response Data Model Source: https://github.com/disler/just-prompt/blob/main/specs/init-just-prompt.md Defines the Pydantic data model 'ListProvidersResponse' for returning a list of LLM providers, including both their full and short names. ```Python class ListProvidersResponse(BaseModel): providers: List[str] ```