Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- 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-
|
|
|
399 |
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
|
411 |
-
|
412 |
-
|
413 |
</div>
|
414 |
<div class="example-panel">
|
415 |
-
<pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-
|
|
|
416 |
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
{
|
426 |
-
role: "user",
|
427 |
-
content: [
|
428 |
-
{ type: "input_text", text: "what is in this image?" },
|
429 |
{
|
430 |
-
|
431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
}
|
433 |
-
|
434 |
-
|
435 |
-
]
|
436 |
-
});
|
437 |
|
438 |
-
|
439 |
-
|
440 |
</div>
|
441 |
<div class="example-panel">
|
442 |
-
<pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-
|
|
|
443 |
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
|
|
461 |
|
462 |
-
|
463 |
-
|
464 |
</div>
|
465 |
<div class="example-panel">
|
466 |
-
<pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-
|
467 |
-
|
468 |
-
baseURL: "${baseUrl}",
|
469 |
-
apiKey: "YOUR_API_KEY_HERE", // visit https://huggingface.co/settings/tokens
|
470 |
-
});
|
471 |
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
|
|
|
|
|
|
|
|
|
|
482 |
|
483 |
-
for
|
484 |
-
|
485 |
-
}</code></pre>
|
486 |
</div>
|
487 |
<div class="example-panel">
|
488 |
-
<pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-
|
|
|
489 |
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
]
|
510 |
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
|
518 |
-
|
519 |
</div>
|
520 |
<div class="example-panel">
|
521 |
-
<pre><button class="copy-btn" onclick="copyCode(this)">Copy</button><code class="language-
|
522 |
-
|
523 |
-
import
|
524 |
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
}
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
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 |
-
|
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">
|