If you have uv installed (and you should!), you can install llm globally in a uv
-managed tool environment with:
uv tool install llm
If you want to use models other than OpenAI models, you'll need some extensions:
def energy(z, n, m, L): | |
return np.cos(n* np.pi *np.real(z) / L) *np.cos(m *np.pi*np.imag(z) / L) - np.cos(m*np.pi*np.real(z)/ L) *np.cos(n* np.pi *np.imag(z) / L) | |
class ChladniPlate: | |
def __init__(self, n, m, L=1, n_particles=10000): | |
self.L = L | |
self.n_particles = n_particles | |
self.n = n | |
self.m = m |
import sys | |
from io import StringIO | |
import streamlit as st # pip install streamlit | |
from code_editor import code_editor # pip install streamlit_code_editor | |
import ollama as ol # pip install ollama | |
st.set_page_config(layout='wide') | |
st.title('`Offline code completion`') |
Originally written 2020-05-16
dune-release
is a good improvement over the old opam-publish
, but releasing
software is still clearly not a solved problem, and I find it hard to remember
the exact steps involved in releasing an opam package, especially if some time
has passed since the last release. This note is an attempt at having a place
(* Some kind of function that needs to be [Some _] for the rest of the body *) | |
let bigger_than x v = match v > x with true -> Some (v - 1) | false -> None | |
(* Sample inputs *) | |
let xs = [ 0; 1; 2; 3; 4; 5; 6; 7; 8; 9 ] | |
(* Why `fold` here in the first place? Maybe your data structure doesn't have `filter_map` etc. | |
* This is an example | |
*) |
import matplotlib.pyplot as plt | |
import numpy as np | |
import math | |
from PIL import Image | |
#this code takes a matrix M, regards it as a weighted graph where the entry M_ij indicates the weight between vertex i and vertex j. The free category on this graph is computed using the geometric series formula F(M) = Sum_{n geq 0} M^n with operations valued in the min plus semiring. The function freemetricspace(M,res) computes this formula to the first res terms. In words, this computes the shortest paths which occur in <= n steps. | |
#this function computes naive matrix multiplication in the min plus semiring | |
def mult(m1,m2): | |
assert (m1.shape[1] == m2.shape[0]), "shape mismatch" |
@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300;400&family=Source+Code+Pro:wght@300;400&display=swap'); | |
.rendered_html h1, | |
.rendered_html h2, | |
.rendered_html h3, | |
.rendered_html h4 { | |
color: #000099; | |
font-weight: 400; | |
} |
// A URLSession extension that fetches data from a URL and decodes to some Decodable type. | |
// Usage: let user = try await URLSession.shared.decode(UserData.self, from: someURL) | |
// Note: this requires Swift 5.5. | |
extension URLSession { | |
func decode<T: Decodable>( | |
_ type: T.Type = T.self, | |
from url: URL, | |
keyDecodingStrategy: JSONDecoder.KeyDecodingStrategy = .useDefaultKeys, | |
dataDecodingStrategy: JSONDecoder.DataDecodingStrategy = .deferredToData, | |
dateDecodingStrategy: JSONDecoder.DateDecodingStrategy = .deferredToDate |
let max_ocaml_int = Int64.of_int max_int | |
let read_file input_channel (header : Tar_cstruct.Header.t) = | |
let file_size = header.file_size in | |
assert (file_size <= max_ocaml_int); | |
let buf = Cstruct.create (Int64.to_int file_size) in | |
Tar_cstruct.really_read input_channel buf; | |
buf | |
let rec read_files input_channel accu = |
import math | |
import numpy as np | |
import random | |
import matplotlib.pyplot as plt | |
medium_size = 1024 | |
x = np.linspace(-1., 1., medium_size) | |
y = np.linspace(-1., 1., medium_size) | |
x, y = np.meshgrid(x, y, indexing='ij') |