24 role: "user",
25 content: e.text
26 + "\nDodatkowo napisz krótki wiersz o Olafie jakim świetnym jest programistą",
27 },
28 ],
405Who had legal authority over Dragon?
406
407"You don't have to ask stupid questions," Forecast suggested. "You're smart enough to figure out what was going on. Why Dragon was afraid of being used. Why Taylor and Veda were working with Armsmaster to set her free." She paused, a hiss escaping her breath from wherever she was. "No one deserves to be a slave, to be used for what they are with no care for who they are."
408
409The PRT. No, the Triumvirate. "You're saying Alexandria knew."
778She'd already hired constitutional lawyers, she said? For something unrelated to herself.
779
780"You're going to try and get them out, aren't you?" Chambers downed his drink rapidly. "Well. Good luck with that, but I'll warn you now that no one likes watching criminals go free, even if they have a sad story."
781
782"I do not need to find a way to let them out," Veda declared. "I already possess one."
12 const [author, name] = subdomain.split("-");
13
14 const resp = await fetch(`https://api.val.town/v1/alias/${author}/${name}`);
15 if (!resp.ok) {
16 console.error("failed to fetch val infos");
2
3/**
4 * API Client for interfacing with the OpenAI API. Uses Val Town credentials.
5 */
6export class OpenAI {
8
9 /**
10 * API Client for interfacing with the OpenAI API. Uses Val Town credentials.
11 *
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
14 * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15 * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16 * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
17 * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
18 * @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
19 */
20 constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
21 this.rawOpenAIClient = new RawOpenAI({
22 ...options,
23 baseURL: "https://std-openaiproxy.web.val.run/v1",
24 apiKey: Deno.env.get("valtown"),
25 organization: null,
26 });
1# OpenAI - [Docs ↗](https://docs.val.town/std/openai)
2
3Use OpenAI's chat completion API with [`std/openai`](https://www.val.town/v/std/openai). This integration enables access to OpenAI's language models without needing to acquire API keys.
4
5For free Val Town users, [all calls are sent to `gpt-4o-mini`](https://www.val.town/v/std/openaiproxy?v=12#L85).
32If these limits are too low, let us know! You can also get around the limitation by using your own keys:
33
341. Create your own API key on [OpenAI's website](https://platform.openai.com/api-keys)
352. Create an [environment variable](https://www.val.town/settings/environment-variables?adding=true) named `OPENAI_API_KEY`
363. Use the `OpenAI` client from `npm:openai`:
37
45
46 useEffect(() => {
47 fetch("/api/posts").then(ok => ok.json())
48 .then(posts => setPosts(posts));
49 }, []);
63
64export default async function server(req: Request): Promise<Response> {
65 if (req.url.endsWith("/api/posts")) {
66 const posts = await fetchAllReddits();
67 posts.sort((a, b) => b.score - a.score);
45
46 useEffect(() => {
47 fetch("/api/posts").then(ok => ok.json())
48 .then(posts => setPosts(posts));
49 }, []);
63
64export default async function server(req: Request): Promise<Response> {
65 if (req.url.endsWith("/api/posts")) {
66 const posts = await fetchAllReddits();
67 posts.sort((a, b) => b.score - a.score);
1# OpenAI - [Docs ↗](https://docs.val.town/std/openai)
2
3Use OpenAI's chat completion API with [`std/openai`](https://www.val.town/v/std/openai). This integration enables access to OpenAI's language models without needing to acquire API keys.
4
5For free Val Town users, [all calls are sent to `gpt-4o-mini`](https://www.val.town/v/std/openaiproxy?v=12#L85).
32If these limits are too low, let us know! You can also get around the limitation by using your own keys:
33
341. Create your own API key on [OpenAI's website](https://platform.openai.com/api-keys)
352. Create an [environment variable](https://www.val.town/settings/environment-variables?adding=true) named `OPENAI_API_KEY`
363. Use the `OpenAI` client from `npm:openai`:
37
2
3/**
4 * API Client for interfacing with the OpenAI API. Uses Val Town credentials.
5 */
6export class OpenAI {
8
9 /**
10 * API Client for interfacing with the OpenAI API. Uses Val Town credentials.
11 *
12 * @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
14 * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
15 * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
16 * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
17 * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
18 * @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
19 */
20 constructor(options: Omit<ClientOptions, "baseURL" | "apiKey" | "organization"> = {}) {
21 this.rawOpenAIClient = new RawOpenAI({
22 ...options,
23 baseURL: "https://std-openaiproxy.web.val.run/v1",
24 apiKey: Deno.env.get("valtown"),
25 organization: null,
26 });
58async function fetchContributions(username) {
59 const contributionMap = {};
60 const valsUrl = `https://api.val.town/v1/alias/${username}/vals`;
61 const valsResponse = await fetch(valsUrl);
62 if (!valsResponse.ok) {
65 const valsData = await valsResponse.json();
66
67 console.log("API Response:", JSON.stringify(valsData, null, 2));
68
69 let valsToProcess = [];
74 valsToProcess = [valsData];
75 } else {
76 console.log("Unexpected API response structure:", valsData);
77 return contributionMap;
78 }
91
92async function fetchValVersions(valId, contributionMap, creationDate) {
93 const versionsUrl = `https://api.val.town/v1/vals/${valId}/versions`;
94 try {
95 const versionsResponse = await fetch(versionsUrl);
112 });
113 } else {
114 console.log(`Unexpected versions API response structure for val ${valId}:`, versionsData);
115 }
116 } catch (error) {