clickbaitbotgetContent1 match
190</style>
191<script>
192function handleSubmit(event) {
193event.preventDefault();
194const urlInput = document.getElementById('url-input');
perplexityAPIREADME.md3 matches
1# Perplexity API Wrapper
23This val exports a function `pplx` that provides an interface to the Perplexity AI chat completions API.
456You'll need a Perplexity AI API key, see [their documentation](https://docs.perplexity.ai/) for how to get started with getting a key. By default, the function will use `PERPLEXITY_API_KEY` in your val town env variables unless overridden by setting `apiKey` in the function.
78## pplx
19You can also specify an `apiKey` to override the default `Deno.env.get("PERPLEXITY_API_KEY")`.
2021The function returns an object of types `PplxResponse`, see below.
2223## Types
remark-frontmatter-starterlayout.ts3 matches
1export function buildSidebarToggle(): string {
2return `<button class="sidebar-toggle" id="sidebar-toggle" aria-controls="sidebar toc-sidebar" aria-expanded="false">☰ Menu</button>`;
3}
45export function buildSidebarContainer(sidebarHtml: string): string {
6return `<div class="sidebar" id="sidebar" aria-hidden="true">${sidebarHtml}</div>`;
7}
89export function buildLayoutWrapper(innerHtml: string): string {
10return `<div class="layout-wrapper">${innerHtml}</div>`;
11}
remark-frontmatter-starterscripts.ts13 matches
8* @returns {string} The JavaScript code as a string
9*/
10export function buildScripts(): string {
11return `
12<script>
13document.addEventListener('DOMContentLoaded', function() {
14// Setup code blocks with copy buttons
15setupCodeBlocks();
16
17// Setup sidebar toggle functionality
18setupSidebar();
19
20// Setup accordion functionality
21setupAccordions();
22
23// Setup tabs functionality
24setupTabs();
25});
26
27// Add copy buttons to code blocks and enable syntax highlighting
28function setupCodeBlocks() {
29document.querySelectorAll('pre code').forEach((codeBlock) => {
30const pre = codeBlock.parentElement;
41copyBtn.setAttribute('aria-label', 'Copy code block');
42
43// Add copy functionality
44copyBtn.addEventListener('click', () => {
45navigator.clipboard.writeText(codeBlock.textContent || '').then(() => {
61}
62
63// Setup sidebar toggle functionality
64function setupSidebar() {
65const sidebarToggle = document.getElementById('sidebar-toggle');
66const sidebar = document.getElementById('sidebar');
103}
104
105// Setup accordion functionality
106function setupAccordions() {
107document.querySelectorAll('.accordion-header').forEach((header) => {
108header.addEventListener('click', () => {
140}
141
142// Setup tabs functionality
143function setupTabs() {
144// Setup tab button click handlers
145document.querySelectorAll('.tab-button').forEach((button) => {
13* @returns Object containing HTML content and metadata
14*/
15export async function renderDoc(docPath: string): Promise<{ html: string, meta: Record<string, any> }> {
16let html = "";
17let meta: Record<string, any> = {};
4142/**
43* Main handler function to process requests and generate HTML response
44* @param req Request object
45* @returns Response object with HTML content
46*/
47export async function appHandler(req: Request): Promise<Response> {
48const url = new URL(req.url);
49const defaultDoc = docs[0]?.path || "README.md";
7* @returns HTML string for navigation links
8*/
9export function buildNav(nodes: DocTreeNode[], current: string): string {
10if (!nodes?.length) return '';
11
27* @returns HTML string for sidebar
28*/
29export function buildSidebar(groups: NestedGroupedDocs, current: string): string {
30let html = '';
31
gptToolsdraftReadme6 matches
9}
1011function createPrompt(code: string, userPrompt?: string) {
12return `
13You are an AI assistant that writes documentation for code. You output readmes
23}
2425async function getVal(username: string, valName: string) {
26try {
27const res = await fetch(`https://api.val.town/v1/alias/${username}/${valName}`, {
40}
4142async function performOpenAICall(prompt: string, model: string, openaiOptions: ClientOptions) {
43const openai = new OpenAI(openaiOptions);
4465}
6667async function updateReadme(id: string, readme: string) {
68try {
69const res = await fetch(`https://api.val.town/v1/vals/${id}`, {
82}
8384async function draftReadme(options: WriterOptions) {
85const { username, valName, model = "gpt-3.5-turbo", userPrompt, ...openaiOptions } = options;
86const { id, code } = await getVal(username, valName);
90}
9192async function writeReadme(options: WriterOptions) {
93const { username, valName, model = "gpt-3.5-turbo", userPrompt, ...openaiOptions } = options;
94const { id, code } = await getVal(username, valName);
openaiPricingusageDB1 match
3const usage = await blob.getJSON("usageDB");
45export default async function(req: Request): Promise<Response> {
6const path = new URL(req.url).pathname;
7if (path === "/usage") {
openaiPricingopenAiPricing2 matches
1// This approach standardizes all prices to be in terms of 1_000_000 tokens
2// We'll use Decimal.js for precise calculations and adjust the createPricing function
34import Decimal from "npm:decimal.js";
56// Helper function to create pricing object, now standardized to 1_000_000 tokens
7const createPricing = (inPrice: number, outPrice: number = inPrice) => ({
8in: new Decimal(inPrice).div(1_000_000),
openaiPricingdeftAmberSwallow2 matches
23mode: "chat" | "embedding" | "completion" | "image_generation" | "audio_transcription" | "audio_speech";
2425supports_function_calling: boolean;
26supports_parallel_function_calling: boolean;
27supports_vision: boolean;
28supports_audio_input: boolean;