Public
Edited
Nov 10, 2023
Insert cell
Insert cell
gr = import("@gradio/client")
Insert cell
Insert cell
hello = gr.client("gradio/hello_blocks")
Insert cell
Insert cell
Insert cell
helloResult = hello.predict("/greet", ["This is me from Observable"])
Insert cell
Insert cell
helloResult.data
Insert cell
Insert cell
Insert cell
sd = gr.client("stabilityai/stable-diffusion")
Insert cell
lcm = gr.client("latent-consistency/Real-Time-LCM-ControlNet-Lora-SD1.5")
Insert cell
lcm.view_api()
Insert cell
Insert cell
sd.view_api()
Insert cell
Insert cell
Insert cell
result = sd.predict(1, [
sd_values.prompt,
sd_values.negative_prompt,
sd_values.guidance_scale
])
Insert cell
Insert cell
Insert cell
Insert cell
captioning = gr.client("nielsr/comparing-captioning-models")
Insert cell
captioningApi = captioning.view_api()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
imgtxt = imgfile === null ? "sample" : "uploaded"
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
imageCaptions = captioning.predict("/predict", [blob])
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
eleven = gr.client("elevenlabs/tts")
Insert cell
eleven.view_api()
Insert cell
Insert cell
elevenResult = eleven.predict(0, [
tts_values.text,
tts_values.voice,
"eleven_multilingual_v1"
])
Insert cell
Insert cell
html`
<audio controls>
<source src="${elevenResult.data[0].data}" type="audio/x-wav">
</audio>`
Insert cell
Insert cell
Insert cell
chatStreaming = gr.client("ysharma/RedPajama-Chat-3B")
Insert cell
chatStreaming.view_api()
Insert cell
Insert cell
chatStreamingResult = {
// status: "pending" | "error" | "complete" | "generating";
let status = "";
let data = null;
yield { status, data };
chatStreaming
.submit(3, [[[chatQuestion, ""]], 0.95, 500, 1])
.on("status", (evt) => (status = evt.stage))
.on("data", (evt) => (data = evt.data[0]));

while (status !== "error" && status !== "complete") {
yield { status, data };
}
yield { status, data };
}
Insert cell
Insert cell
import { guard } from "@mootari/inputs-submit"
Insert cell
import { imageInput } from "@mbostock/file-input"
Insert cell
import { list } from "@stwind/input-list"
Insert cell
import { loading as spinner } from "@cadasa/voice-to-text-image"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more