6/26 の YouTube Live の台本
- 話し手
- mizchi
- フロントエンド/JavaScript歴10年。マークアップは苦手
- mizchi
- 動画コンテンツで発信したい / 一人じゃ喋れなくて聞き手を探していた
import AnthropicAI from 'npm:@anthropic-ai/sdk@0.24.0'; | |
const client = new AnthropicAI({ | |
apiKey: Deno.env.get('ANTHROPIC_API_KEY')!, | |
}); | |
const write = (text: string) => { | |
Deno.stdout.write(new TextEncoder().encode(text)); | |
} | |
const stream = client.messages.stream({ |
services: | |
qdrant: | |
image: qdrant/qdrant:latest | |
restart: always | |
container_name: qdrant | |
ports: | |
- 6333:6333 | |
- 6334:6334 | |
expose: | |
- 6333 |
import Cloudflare from "npm:cloudflare@3.2.0"; | |
const cf = new Cloudflare({ | |
apiToken: Deno.env.get('CLOUDFLARE_API_TOKEN')!, | |
}); | |
const result = await cf.workers.ai.run('@cf/baai/bge-base-en-v1.5', { | |
account_id: Deno.env.get('CLOUDFLARE_ACCOUNT_ID')!, | |
text: ['This is a story about an orange cloud'], | |
}); | |
console.log(result); |
import type { } from "npm:@cloudflare/workers-types@4.20240524.0"; | |
const CF_API_TOKEN = Deno.env.get('CLOUDFLARE_AI_API_TOKEN')!; | |
const CF_ACCOUNT_ID = Deno.env.get('CLOUDFLARE_ACCOUNT_ID')!; | |
const INDEX_NAME = 'embeddings-index'; | |
interface EmbeddingResponse { | |
result: { | |
shape: number[]; | |
data: number[][]; |
type NodeId = number; | |
interface NodePath { | |
id: NodeId; | |
g: number; // Cost from start to this node | |
f: number; // Estimated cost from start to goal through this node | |
parent: NodeId | null; | |
} | |
export function findShortestPath( |
import { createGraph } from "jsr:@deno/graph@0.74.4"; | |
const g1 = await createGraph("jsr:@mizchi/tpl@0.0.3"); | |
console.log("g1", g1); | |
const g2 = await createGraph("npm:zod@3.23.6"); | |
console.log("g2", g2); | |
/** | |
g1 { |
trait Serializer { | |
serialize(Self) -> Bytes | |
} | |
impl Serializer for Int with serialize(self) { | |
Bytes::from_array([ | |
self.land(0xFF), | |
self.lsr(8).land(0xFF), | |
self.lsr(16).land(0xFF), | |
self.lsr(24).land(0xFF) |