Skip to content

Instantly share code, notes, and snippets.

import os
from langchain.agents import Tool
from langchain.tools.retriever import create_retriever_tool
from langchain_openai import OpenAIEmbeddings
from indexclient import IndexChroma
from crewai import Agent, Task, Crew, Process
# TODO
# I had to install langchain_chroma seperately. It should be included in the requirements
@serefyarar
serefyarar / jsonSchemaToGraphQLFragment.js
Created May 17, 2024 16:36
JSON Schema to GraphQL Fragment
//Thank you ChatGPT
function jsonSchemaToGraphQLFragment(schema, typeName, setPrefix = false) {
// Helper function to resolve $ref references within the schema
function resolveRef(ref, defs) {
const refPath = ref.replace(/^#\/\$defs\//, '');
return defs[refPath];
}
// Helper function to process each field in the schema
type EmbeddingContext {
# context is the transformed representation of a node before obtaining embeddings.
# This can include the node's content with added context information for embedding tasks like summaries, etc.
# Raw document is used if it's null.
context: String @string(maxLength:100000000)
# contextDescription is a human-readable description of the context.
contextDescription: String! @string(maxLength:600)
# category is the category or namespace for the embedding.
@serefyarar
serefyarar / book.graphql
Created August 25, 2023 12:11
Book Draft
type Book {
name: String! @string(maxLength: 255)
editor: Person @relation
description: String! @string(maxLength: 1000)
inLanguage: String! @string(maxLength: 50)
keywords: [String!]! @list(maxLength: 20)
isbn: [String!]! @list(maxLength: 5)
publisher: Publisher @relation
datePublished: Date
locationCreated: Place @relation
apiVersion: v1
kind: ConfigMap
metadata:
name: ipfs-env
labels:
app: ipfs
data:
IPFS_ENABLE_S3: "true"
IPFS_S3_REGION: "us-east-1"
IPFS_S3_BUCKET_NAME: "**"
/**
*
* NAME: main
*
*/
"use strict";
(() => {
var __defProp = Object.defineProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
@serefyarar
serefyarar / main.action.ts
Last active May 23, 2023 07:34
Main Action
/**
* NAME: main
*/
import * as dagCBOR from '@ipld/dag-cbor';
import { sha256 } from 'multiformats/hashes/sha2';
import * as Block from 'multiformats/block';
const go = async () => {
@serefyarar
serefyarar / index.graphql
Created March 28, 2023 13:56
index schema 28
type Index @createModel(accountRelation: LIST, description: "A Simple Index"){
controller_did: DID! @documentAccount
title: String! @string(maxLength:1000)
version: CommitID! @documentVersion
collab_action: String @string(maxLength:150)
created_at: DateTime!
updated_at: DateTime!
deleted_at: DateTime
}
did:3:kjzl6cwe1jw149zw96t9xgvyurdk24zvx5eyyhaw61vmd08hk3tkx9dvlt21ans
@serefyarar
serefyarar / vpn-install.sh
Created March 9, 2022 14:43
Openconnect m1 mac install script
git clone https://gitlab.com/openconnect/openconnect.git
cd openconnect
brew install autoconf automake libtool pkg-config gettext openssl
./autogen.sh
sudo mkdir /etc/vpnc
sudo curl https://gitlab.com/openconnect/vpnc-scripts/raw/master/vpnc-script --output /etc/vpnc/vpnc-script
sudo chmod +x /etc/vpnc/vpnc-script
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
./configure