Skip to content

Instantly share code, notes, and snippets.

View tommymalmqvist's full-sized avatar
👋
Hello, World!

Tommy Malmqvist tommymalmqvist

👋
Hello, World!
View GitHub Profile
@tommymalmqvist
tommymalmqvist / example.py
Created February 21, 2024 12:44
ollama function calling
import json
import requests
from langchain_community.llms.ollama import Ollama
from langchain_core.utils.function_calling import convert_to_openai_tool
from langchain_experimental.llms.ollama_functions import OllamaFunctions
def get_invoice_data(start_date: str, end_date: str):
"""Get the total amount invoiced between two dates.
<html lang="en" class="theme theme--mercado artdeco-spacers artdeco osx"><head>
<script type="application/javascript">!function(i,n){void 0!==i.addEventListener&&void 0!==i.hidden&&(n.liVisibilityChangeListener=function(){i.hidden&&(n.liHasWindowHidden=!0)},i.addEventListener("visibilitychange",n.liVisibilityChangeListener))}(document,window);</script>
<title>(1) Viktor Losciale | LinkedIn</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="asset-url" class="mercado-icons-sprite" id="artdeco-icons/static/images/sprite-asset" content="https://static.licdn.com/sc/h/lxvezhyg37pr01ya2napewka">
<meta name="description" content="">
<meta name="google" content="notranslate">
@tommymalmqvist
tommymalmqvist / weather_data.json
Created March 25, 2023 08:44
wheater data stockholm
{"approvedTime":"2023-03-25T08:05:12Z","referenceTime":"2023-03-25T08:00:00Z","geometry":{"type":"Point","coordinates":[[18.089437,59.339222]]},"timeSeries":[{"validTime":"2023-03-25T09:00:00Z","parameters":[{"name":"spp","levelType":"hl","level":0,"unit":"percent","values":[100]},{"name":"pcat","levelType":"hl","level":0,"unit":"category","values":[1]},{"name":"pmin","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.0]},{"name":"pmean","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.1]},{"name":"pmax","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.2]},{"name":"pmedian","levelType":"hl","level":0,"unit":"kg/m2/h","values":[0.1]},{"name":"tcc_mean","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"lcc_mean","levelType":"hl","level":0,"unit":"octas","values":[8]},{"name":"mcc_mean","levelType":"hl","level":0,"unit":"octas","values":[7]},{"name":"hcc_mean","levelType":"hl","level":0,"unit":"octas","values":[4]},{"name":"msl","levelType":"hmsl","level":0,"unit":"hPa","values"
import fs from 'fs';
import path from 'path';
import matter from 'gray-matter';
const postsDirectory = path.join(process.cwd(), 'posts');
export function getSortedPostsData() {
// Get file names under /posts
const fileNames = fs.readdirSync(postsDirectory);
const allPostsData = fileNames.map((fileName) => {
#[cfg(test)]
mod tests {
use serde_json;
#[test]
fn test_new() {
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)]
#[serde(rename_all = "camelCase", untagged)]
enum Kind {
@tommymalmqvist
tommymalmqvist / vigenere.c
Created September 25, 2014 11:38
vigenere.c
#include <stdio.h>
#include <cs50.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
if (argc != 2)
{