Skip to content

Instantly share code, notes, and snippets.

View mrxvt's full-sized avatar
💭
I may be slow to respond.

mrxvt

💭
I may be slow to respond.
View GitHub Profile
https://open.spotify.com/episode/33SKkqfXPCjvieNwBPxSpJ
@mrxvt
mrxvt / dspy_chain_of_thought_example.py
Created February 10, 2024 07:04 — forked from jrknox1977/dspy_chain_of_thought_example.py
DSPy example with chain of thought.
# install DSPy: pip install dspy
import dspy
# This sets up the language model for DSPy in this case we are using GPT-3.5-turbo
turbo = dspy.OpenAI(model='gpt-3.5-turbo')
# This sets the language model for DSPy. This must be set or you get an error that is not helpful:
# --> temperature = lm.kwargs['temperature'] if temperature is None else temperature
# --> AttributeError: 'NoneType' object has no attribute 'kwargs'
@mrxvt
mrxvt / dspy_tgi_mistral.py
Created February 10, 2024 07:04 — forked from jrknox1977/dspy_tgi_mistral.py
DSPy - using TGI for local model
# install DSPy: pip install dspy
import dspy
# This sets up the language model for DSPy in this case we are using mistral 7b through TGI (Text Generation Interface from HuggingFace)
mistral = dspy.HFClientTGI(model='mistralai/Mistral-7B-v0.1', port=8080, url='http://localhost')
# This sets the language model for DSPy.
dspy.settings.configure(lm=mistral)
# This is not required but it helps to understand what is happening
@mrxvt
mrxvt / ollama_dspy.py
Created February 10, 2024 07:03 — forked from jrknox1977/ollama_dspy.py
ollama+DSPy using OpenAI APIs.
# install DSPy: pip install dspy
import dspy
# Ollam is now compatible with OpenAI APIs
#
# To get this to work you must include `model_type='chat'` in the `dspy.OpenAI` call.
# If you do not include this you will get an error.
#
# I have also found that `stop='\n\n'` is required to get the model to stop generating text after the ansewr is complete.
# At least with mistral.
@mrxvt
mrxvt / rag-reranking-gpt-colbert.ipynb
Created January 22, 2024 02:18 — forked from virattt/rag-reranking-gpt-colbert.ipynb
rag-reranking-gpt-colBERT.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mrxvt
mrxvt / node-typescript-esm.md
Created November 21, 2023 11:55 — forked from khalidx/node-typescript-esm.md
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@mrxvt
mrxvt / rename.sh
Last active August 25, 2023 17:38
rename PDFs
#!/bin/bash
# Change the directory to the one containing PDF files
DIRECTORY=$HOME
cd $DIRECTORY
for filename in *.pdf; do
# Extract the title from the PDF metadata
title=$(pdfinfo "$filename" 2>/dev/null | awk '/^Title:/ { $1=""; print substr($0, 2) }')
@mrxvt
mrxvt / API Data to MongoDB using Mongoose and Axios.md
Created August 31, 2022 03:17 — forked from PowellTravis/API Data to MongoDB using Mongoose and Axios.md
Using Mongoose and Axios Together to Upload API Data

BANNER

Using Mongoose and AXIOS to upload APU data to MongoDB

Uploading data using Axios and Mongoose can be hard at first. But when you really understand what you are doing you will be glad you are not reaching out to the API each time someone loads your webpage.

Installing the Packages

  1. Make sure you have nodejs and NPM installed, NPM comes with nodejs

npm install axios mongoose

@mrxvt
mrxvt / minification.md
Created August 26, 2022 22:20 — forked from gaearon/minification.md
How to Set Up Minification

In production, it is recommended to minify any JavaScript code that is included with your application. Minification can help your website load several times faster, especially as the size of your JavaScript source code grows.

Here's one way to set it up:

  1. Install Node.js
  2. Run npm init -y in your project folder (don't skip this step!)
  3. Run npm install terser

Now, to minify a file called like_button.js, run in the terminal:

@mrxvt
mrxvt / mvvm.md
Created August 25, 2022 20:41 — forked from supahgreg/mvvm.md
MVVM

#MVVM For JavaScript Developers

MVVM (Model View ViewModel) is an architectural pattern based on MVC and MVP, which attempts to more clearly separate the development of user-interfaces (UI) from that of the business logic and behaviour in an application. To this end, many implementations of this pattern make use of declarative data bindings to allow a separation of work on Views from other layers.

This facilitates UI and development work occurring almost simultaneously within the same codebase. UI developers write bindings to the ViewModel within their document markup (HTML), where the Model and ViewModel are maintained by developers working on the logic for the application.

##History

MVVM was originally defined by Microsoft for use with Windows Presentation Foundation (WPF) and Silverlight, having been officially announced in 2005 by John Grossman in a blog p