Skip to content

Instantly share code, notes, and snippets.

View mrdjohnson's full-sized avatar

DJ Johnson mrdjohnson

View GitHub Profile
@mrdjohnson
mrdjohnson / Instructions.md
Last active June 25, 2024 14:59
Connecting to LM Studio via Open AI Api

Connecting to LM Studio via Open AI Api

Go to the server section, (button on left) change the port number or leave it as is, and click the "start server" button (you may need to turn on cors)

It should look like this:

image

assuming the port is 1234: You should be able to see the open api endpoint now: http://localhost:1234/v1/models

@mrdjohnson
mrdjohnson / BasicOllamaChatExample.tsx
Created March 14, 2024 06:07
Basic Ollama streaming example
// more info on message type can be found here: https://github.com/ollama/ollama/blob/main/docs/api.md#parameters-1
type Message = {
role: 'assistant' | 'user' | 'system'
content: string
images?: string[]
}
type OllamaResponse = {
model: string
created_at: string
@mrdjohnson
mrdjohnson / no_cigar.py
Last active October 16, 2016 08:22
A close win for finding the sum of the sum of all prime factors from 2-N the fastest
# @timeit
# the original one
def get_prime_factor_sum(row):
total = 0
primes = {}
for prime_number in range(2, row + 1):
if prime_number in primes:
continue
next_exponent = prime_number
for prime_multiple in range(prime_number, row + 1, prime_number):