Skip to content

Instantly share code, notes, and snippets.

@bauefikapa
bauefikapa / gist:8ca7eb34eeff9a421c941362b580796c
Last active September 25, 2023 12:52
Circle CI API reference 2.0
{
"openapi": "3.0.3",
"info": {
"version": "v2",
"title": "CircleCI API",
"description": "This describes the resources that make up the CircleCI API v2.\n\n# Authentication\n\n<!-- ReDoc-Inject: <security-definitions> -->",
"license": {
"name": "MIT"
}
},
const handleResponseErrors = (status: number, errorText: string) => {
if (status === 403 && errorText.toLowerCase().includes("recaptcha")) {
return "There was a verification error, please refresh the page and try asking your question again. If the issue persists please contact support.";
} else if (status === 429 && errorText.includes("User")) {
return "Question limit reached, please wait a few minutes and try again.";
} else if (status === 429 && errorText.includes("Global")) {
return "System capacity reached, please wait a few minutes and try again.";
} else if ([400, 403, 404, 429].includes(status)) {
return "Configuration issue detected, contact support if unresolved shortly.";
} else {
@bauefikapa
bauefikapa / app.js
Last active April 9, 2024 09:33
Example React Client Kapa AI Streaming
import React, { useState, useEffect } from 'react';
const App = () => {
const [relevantSources, setRelevantSources] = useState([]);
const [answer, setAnswer] = useState('');
const [identifiers, setIdentifiers] = useState(null);
const [error, setError] = useState(null);
const [feedback, setFeedback] = useState(null);
const process_stream = async (response) => {