const Octokit = createOctokit.plugin(throttling); const octokit = new Octokit({ auth:…
- User
const Octokit = createOctokit.plugin(throttling);
const octokit = new Octokit({ auth: import.meta.env.GITHUB_TOKEN, throttle: { onRateLimit: (retryAfter: number, options: ThrottleOptions) => { console.warn(
Request quota exhausted for request ${options.method} ${options.url}. Retrying after ${retryAfter} seconds.);codereturn true; }, onAbuseLimit: (_: number, options: ThrottleOptions) => { octokit.log.warn( `Abuse detected for request ${options.method} ${options.url}` ); },}, });
위 코드는 octokit 옛날 버전의 세팅인데, 최신 버전으로 바꿔줘
Assistant
제공된 컨텍스트를 바탕으로, 최신 Octokit REST.js 버전의 설정 코드로 변환해드리겠습니다:
typescriptimport { Octokit } from "@octokit/rest"; import { throttling } from "@octokit/plugin-throttling"; const MyOctokit = Octokit.plugin(throttling); const octokit = new MyOctokit({ auth: import.meta.env.GITHUB_TOKEN, throttle: { onRateLimit: (retryAfter, options) => { console.warn( `Request quota exhausted for request ${options.method} ${options.url}` ); // only retries once if (options.request.retryCount === 0) { console.info(`Retrying after ${retryAfter} seconds!`); return true; } }, onSecondaryRateLimit: (retryAfter, options, octokit) => { // does not retry, only logs a warning octokit.log.warn( `Secondary quota detected for request ${options.method} ${options.url}` ); }, } });- User
타입스크립트로 작성해줘
Assistant
네, TypeScript로 작성된 최신 버전의 Octokit 설정 코드입니다:
typescript- User
ThrottlingOptions 는 뭐지?
Assistant
ThrottlingOptions는@octokit/plugin-throttling패키지에서 제공하는 타입으로, throttling 플러그인의 설정 옵션들의 타입을 정의합니다.아래와 같이 직접 정의해서 사용할 수도 있습니다:
typescript
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.