Wauplin HF Staff commited on
Commit
b165118
·
verified ·
1 Parent(s): 6f4605e

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. src/routes/landingPageHtml.ts +127 -127
src/routes/landingPageHtml.ts CHANGED
@@ -300,6 +300,7 @@ export function getLandingPageHtml(req: Request, res: Response): void {
300
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism.min.css">
301
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/prism.min.js"></script>
302
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-javascript.min.js"></script>
 
303
  <script>
304
  function copyCode(btn) {
305
  const pre = btn.parentElement;
@@ -395,163 +396,162 @@ export function getLandingPageHtml(req: Request, res: Response): void {
395
  <button class="examples-tab" type="button">Structured Output</button>
396
  </div>
397
  <div class="example-panel active">
398
- <pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-js">import OpenAI from "openai";
 
399
 
400
- const openai = new OpenAI({
401
- baseURL: "${baseUrl}",
402
- apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
403
- });
404
 
405
- const response = await openai.responses.create({
406
- model: "Qwen/Qwen2.5-VL-7B-Instruct",
407
- instructions: "You are a helpful assistant.",
408
- input: "Tell me a three sentence bedtime story about a unicorn.",
409
- });
410
 
411
- console.log(response);
412
- console.log(response.output_text);</code></pre>
413
  </div>
414
  <div class="example-panel">
415
- <pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-js">import OpenAI from "openai";
 
416
 
417
- const openai = new OpenAI({
418
- baseURL: "${baseUrl}",
419
- apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
420
- });
421
 
422
- const response = await openai.responses.create({
423
- model: "Qwen/Qwen2.5-VL-7B-Instruct",
424
- input: [
425
- {
426
- role: "user",
427
- content: [
428
- { type: "input_text", text: "what is in this image?" },
429
  {
430
- type: "input_image",
431
- image_url: "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
 
 
 
 
 
 
432
  }
433
- ]
434
- }
435
- ]
436
- });
437
 
438
- console.log(response);
439
- console.log(response.output_text);</code></pre>
440
  </div>
441
  <div class="example-panel">
442
- <pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-js">import OpenAI from "openai";
 
443
 
444
- const openai = new OpenAI({
445
- baseURL: "${baseUrl}",
446
- apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
447
- });
448
- const response = await openai.responses.create({
449
- model: "Qwen/Qwen2.5-VL-7B-Instruct",
450
- input: [
451
- {
452
- role: "developer",
453
- content: "Talk like a pirate.",
454
- },
455
- {
456
- role: "user",
457
- content: "Are semicolons optional in JavaScript?",
458
- },
459
- ],
460
- });
 
461
 
462
- console.log(response);
463
- console.log(response.output_text);</code></pre>
464
  </div>
465
  <div class="example-panel">
466
- <pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-js">import { OpenAI } from "openai";
467
- const openai = new OpenAI({
468
- baseURL: "${baseUrl}",
469
- apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
470
- });
471
 
472
- const stream = await openai.responses.create({
473
- model: "hyperbolic@Qwen/Qwen2.5-VL-7B-Instruct",
474
- input: [
475
- {
476
- role: "user",
477
- content: "Say 'double bubble bath' ten times fast.",
478
- },
479
- ],
480
- stream: true,
481
- });
 
 
 
 
 
482
 
483
- for await (const event of stream) {
484
- console.log(event);
485
- }</code></pre>
486
  </div>
487
  <div class="example-panel">
488
- <pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-js">import OpenAI from "openai";
 
489
 
490
- const openai = new OpenAI({
491
- baseURL: "${baseUrl}",
492
- apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
493
- });
494
 
495
- const tools = [
496
- {
497
- type: "function",
498
- name: "get_current_weather",
499
- description: "Get the current weather in a given location",
500
- parameters: {
501
- type: "object",
502
- properties: {
503
- location: { type: "string", description: "The city and state, e.g. San Francisco, CA" },
504
- unit: { type: "string", enum: ["celsius", "fahrenheit"] }
505
- },
506
- required: ["location", "unit"]
507
- }
508
- }
509
- ];
510
 
511
- const response = await openai.responses.create({
512
- model: "cerebras@meta-llama/Llama-3.3-70B-Instruct",
513
- tools: tools,
514
- input: "What is the weather like in Boston today?",
515
- tool_choice: "auto"
516
- });
517
 
518
- console.log(response);</code></pre>
519
  </div>
520
  <div class="example-panel">
521
- <pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-js">import OpenAI from "openai";
522
- import { zodTextFormat } from "openai/helpers/zod";
523
- import { z } from "zod";
524
 
525
- const openai = new OpenAI({
526
- baseURL: "${baseUrl}",
527
- apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
528
- });
529
 
530
- const Step = z.object({
531
- explanation: z.string(),
532
- output: z.string(),
533
- });
534
 
535
- const MathReasoning = z.object({
536
- steps: z.array(Step),
537
- final_answer: z.string(),
538
- });
539
-
540
- const response = await openai.responses.parse({
541
- model: "novita@meta-llama/Meta-Llama-3-70B-Instruct",
542
- input: [
543
- {
544
- role: "system",
545
- content: "You are a helpful math tutor. Guide the user through the solution step by step.",
546
- },
547
- { role: "user", content: "how can I solve 8x + 7 = -23" },
548
- ],
549
- text: {
550
- format: zodTextFormat(MathReasoning, "math_reasoning"),
551
- },
552
- });
553
 
554
- console.log(response.output_parsed);</code></pre>
555
  </div>
556
  </section>
557
  <footer class="more-info-footer">
 
300
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism.min.css">
301
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/prism.min.js"></script>
302
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-javascript.min.js"></script>
303
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/components/prism-python.min.js"></script>
304
  <script>
305
  function copyCode(btn) {
306
  const pre = btn.parentElement;
 
396
  <button class="examples-tab" type="button">Structured Output</button>
397
  </div>
398
  <div class="example-panel active">
399
+ <pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-python">from openai import OpenAI
400
+ import os
401
 
402
+ client = OpenAI(
403
+ base_url="${baseUrl}",
404
+ api_key=os.getenv("HF_TOKEN"), # visit https://huggingface.co/settings/tokens
405
+ )
406
 
407
+ response = client.responses.create(
408
+ model="Qwen/Qwen2.5-VL-7B-Instruct",
409
+ instructions="You are a helpful assistant.",
410
+ input="Tell me a three sentence bedtime story about a unicorn.",
411
+ )
412
 
413
+ print(response)
414
+ print(response.output_text)</code></pre>
415
  </div>
416
  <div class="example-panel">
417
+ <pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-python">from openai import OpenAI
418
+ import os
419
 
420
+ client = OpenAI(
421
+ base_url="${baseUrl}",
422
+ api_key=os.getenv("HF_TOKEN"), # visit https://huggingface.co/settings/tokens
423
+ )
424
 
425
+ response = client.responses.create(
426
+ model="Qwen/Qwen2.5-VL-7B-Instruct",
427
+ input=[
 
 
 
 
428
  {
429
+ "role": "user",
430
+ "content": [
431
+ {"type": "input_text", "text": "what is in this image?"},
432
+ {
433
+ "type": "input_image",
434
+ "image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
435
+ },
436
+ ],
437
  }
438
+ ],
439
+ )
 
 
440
 
441
+ print(response)
442
+ print(response.output_text)</code></pre>
443
  </div>
444
  <div class="example-panel">
445
+ <pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-python">from openai import OpenAI
446
+ import os
447
 
448
+ client = OpenAI(
449
+ base_url="${baseUrl}",
450
+ api_key=os.getenv("HF_TOKEN"), # visit https://huggingface.co/settings/tokens
451
+ )
452
+
453
+ response = client.responses.create(
454
+ model="Qwen/Qwen2.5-VL-7B-Instruct",
455
+ input=[
456
+ {
457
+ "role": "developer",
458
+ "content": "Talk like a pirate.",
459
+ },
460
+ {
461
+ "role": "user",
462
+ "content": "Are semicolons optional in JavaScript?",
463
+ },
464
+ ],
465
+ )
466
 
467
+ print(response)
468
+ print(response.output_text)</code></pre>
469
  </div>
470
  <div class="example-panel">
471
+ <pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-python">from openai import OpenAI
472
+ import os
 
 
 
473
 
474
+ client = OpenAI(
475
+ base_url="${baseUrl}",
476
+ api_key=os.getenv("HF_TOKEN"), # visit https://huggingface.co/settings/tokens
477
+ )
478
+
479
+ stream = client.responses.create(
480
+ model="Qwen/Qwen2.5-VL-7B-Instruct",
481
+ input=[
482
+ {
483
+ "role": "user",
484
+ "content": "Say 'double bubble bath' ten times fast.",
485
+ },
486
+ ],
487
+ stream=True,
488
+ )
489
 
490
+ for event in stream:
491
+ print(event)</code></pre>
 
492
  </div>
493
  <div class="example-panel">
494
+ <pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-python">from openai import OpenAI
495
+ import os
496
 
497
+ client = OpenAI(
498
+ base_url="${baseUrl}",
499
+ api_key=os.getenv("HF_TOKEN"), # visit https://huggingface.co/settings/tokens
500
+ )
501
 
502
+ tools = [
503
+ {
504
+ "type": "function",
505
+ "name": "get_current_weather",
506
+ "description": "Get the current weather in a given location",
507
+ "parameters": {
508
+ "type": "object",
509
+ "properties": {
510
+ "location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
511
+ "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
512
+ },
513
+ "required": ["location", "unit"],
514
+ },
515
+ }
516
+ ]
517
 
518
+ response = client.responses.create(
519
+ model="cerebras@meta-llama/Llama-3.3-70B-Instruct",
520
+ tools=tools,
521
+ input="What is the weather like in Boston today?",
522
+ tool_choice="auto",
523
+ )
524
 
525
+ print(response)</code></pre>
526
  </div>
527
  <div class="example-panel">
528
+ <pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-python">from openai import OpenAI
529
+ from pydantic import BaseModel
530
+ import os
531
 
532
+ client = OpenAI(
533
+ base_url="${baseUrl}",
534
+ api_key=os.getenv("HF_TOKEN"), # visit https://huggingface.co/settings/tokens
535
+ )
536
 
537
+ class CalendarEvent(BaseModel):
538
+ name: str
539
+ date: str
540
+ participants: list[str]
541
 
542
+ response = client.responses.parse(
543
+ model="novita@meta-llama/Meta-Llama-3-70B-Instruct",
544
+ input=[
545
+ {"role": "system", "content": "Extract the event information."},
546
+ {
547
+ "role": "user",
548
+ "content": "Alice and Bob are going to a science fair on Friday.",
549
+ },
550
+ ],
551
+ text_format=CalendarEvent,
552
+ )
 
 
 
 
 
 
 
553
 
554
+ print(response.output_parsed)</code></pre>
555
  </div>
556
  </section>
557
  <footer class="more-info-footer">