Skip to content

Instantly share code, notes, and snippets.

View rschwabco's full-sized avatar

Roie Schwaber-Cohen rschwabco

View GitHub Profile
Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[16], line 1
----> 1 from llama_index import (
2 GPTPineconeIndex,
3 GPTSimpleKeywordTableIndex,
4 SimpleDirectoryReader,
5 LLMPredictor,
6 ServiceContext
@rschwabco
rschwabco / qModified.ts
Last active March 20, 2023 21:43
qModified.ts
type Vector = {
id: string
values: number[]
}
const assertSameLength = (vectors: Vector[]): void => {
if (new Set(vectors.map(vector => vector.values.length)).size !== 1) {
throw new Error('All vectors must have the same length');
}
};
@rschwabco
rschwabco / unique.js
Created January 7, 2022 22:38
One liner for uniqifiying an array of objects by property
const uniqueObjectArray = [...new Map(objectArray.map((item) => [item["id"], item])).values()];
const sensitiveDataResponse = await fetch(sensitiveInformationURL, {
headers: {
Authorization: `Bearer ${accessToken}SOME_ROGUE_CHARACTERS`,
},
});
function App() {
const auth = useAuth();
const isAuthenticated = auth.userData?.id_token ? true : false;
import { AuthProvider } from "oidc-react";
//Aserto authorizer middleware function
const checkAuthz = jwtAuthz(authzOptions);
const { jwtAuthz } = require("express-jwt-aserto");
//Protected API endpoint
app.get("/api/protected", checkJwt, checkAuthz, function (req, res) {
//send the response
res.json({ secret: "Very sensitive information presented here" });
});
const authzOptions = {
authorizerServiceUrl: process.env.AUTHORIZER_SERVICE_URL,
policyId: process.env.POLICY_ID,
policyRoot: process.env.POLICY_ROOT,
authorizerApiKey: process.env.AUTHORIZER_API_KEY,
tenantId: process.env.TENANT_ID,
};