Skip to content

Instantly share code, notes, and snippets.

View tazarov's full-sized avatar
🚀
Work

Trayan Azarov tazarov

🚀
Work
View GitHub Profile
@tazarov
tazarov / chroma_no_docs.py
Created August 15, 2023 13:43
This gist illustrates how to store vectors of your documents in chroma without providing your actual text documents:
import uuid
from chromadb.utils import embedding_functions
import chromadb
ef = embedding_functions.DefaultEmbeddingFunction()
docs = ["Article by john", "Article by Jack", "Article by Jill"]
client = chromadb.Client()
embeddings = ef(docs)
collection = client.get_or_create_collection("test-where-list")
@tazarov
tazarov / test_chunking_chroma.py
Last active June 24, 2024 13:56
An example of how one can chunk texts from large documents in chroma using langchain.
import uuid
from chromadb.utils import embedding_functions
from langchain.schema import Document
from langchain.text_splitter import RecursiveCharacterTextSplitter
long_text = """
The Downsides of LLMs (Logical Language Models)
In the age of artificial intelligence, Logical Language Models (LLMs) represent a significant leap forward in the field of natural language processing. These models are capable of comprehending, generating, and reasoning about human languages in a way that mimics human-like understanding. While the benefits of LLMs are numerous, it's essential to also recognize the downsides that accompany these advancements. This essay will explore the negative aspects of LLMs in terms of ethics, job displacement, security, and potential biases.
@tazarov
tazarov / chroma-openapi.yaml
Last active August 6, 2023 08:29
OpenAPI 3.0 spec for Chroma vector databaseThis could be useful in generating clients for chroma
openapi: 3.0.2
info:
title: FastAPI
version: 0.1.0
paths:
/api/v1:
get:
summary: Root
operationId: root
responses:

Simplifying the process of utilizing OpenAI models' function calling capabilities, a new approach involves creating a meticulously structured JSON list. Consider the following example:

{
        "name": "get_current_weather",
        "description": "Get the current weather",
        "parameters": {
            "type": "object",
 "properties": {

This is a one-liner command to list and add a user as a reviewer to all pull requests in a github repo.

for pr in $(gh pr list --json number -q '.[].number'); do gh pr edit $pr --add-reviewer <user_id>; done

Note: The above works only in bash

kubectl get pods --all-namespaces -o jsonpath="{.items[*].spec.containers[*].image}" |\
tr -s '[[:space:]]' '\n' |\
sort |\
uniq -c

Installation

Check release in https://github.com/WireGuard/wireguard-vyatta-ubnt/releases

#https://github.com/WireGuard/wireguard-vyatta-ubnt/releases/download/1.0.20220627-1/ugw4-v1-v1.0.20220627-v1.0.20210914.deb

curl -OL https://github.com/WireGuard/wireguard-vyatta-ubnt/releases/download/1.0.20220627-1/ugw4-v1-v1.0.20220627-v1.0.20210914.deb
@tazarov
tazarov / my-admin-checker-mapper.js
Created February 23, 2023 15:27 — forked from Videl/my-admin-checker-mapper.js
JS for script mapper in Keycloak
// https://stackoverflow.com/questions/52518298/how-to-create-a-script-mapper-in-keycloak
// https://stackoverflow.com/questions/48199539/best-way-to-test-debug-javascript-mappers-policies-in-keycloak
// https://docs.oracle.com/javase/10/nashorn/nashorn-java-api.htm#JSNUG119
var client = keycloakSession.getContext().getClient();
var forEach = Array.prototype.forEach;
// print(user.getRealmRoleMappings());
var isAdmin = false;
@tazarov
tazarov / test_email.py
Last active January 25, 2023 21:19
Send email using AWS SES
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def test_send_mail():
# Replace [email protected] with your "From" address.
# This address must be verified with Amazon SES.
SENDER = "admin@org"
@tazarov
tazarov / kubernetes_service_session_affinity.md
Created January 20, 2023 17:15 — forked from fjudith/kubernetes_service_session_affinity.md
Enable Session Affinity (a.k.a Sticky Session) to Kubernetes service