Skip to content

Instantly share code, notes, and snippets.

View raphael2692's full-sized avatar
🎯
Focusing

Raffaele Spataro raphael2692

🎯
Focusing
View GitHub Profile
@jvelezmagic
jvelezmagic / main.py
Created May 17, 2023 12:05
Langchain FastAPI stream with simple memory
# The goal of this file is to provide a FastAPI application for handling
# chat requests amd generation AI-powered responses using conversation chains.
# The application uses the LangChaing library, which includes a chatOpenAI model
# for natural language processing.
# The `StreamingConversationChain` class is responsible for creating and storing
# conversation memories and generating responses. It utilizes the `ChatOpenAI` model
# and a callback handler to stream responses as they're generated.
# The application defines a `ChatRequest` model for handling chat requests,
@ninely
ninely / main.py
Last active April 19, 2024 11:04
Langchain with fastapi stream example
"""This is an example of how to use async langchain with fastapi and return a streaming response.
The latest version of Langchain has improved its compatibility with asynchronous FastAPI,
making it easier to implement streaming functionality in your applications.
"""
import asyncio
import os
from typing import AsyncIterable, Awaitable
import uvicorn
from dotenv import load_dotenv
@crscheid
crscheid / prefect_2.0_rename_flows.py
Last active May 25, 2023 16:20
Sample code for renaming flows in Prefect 2.0 at runtime
import prefect
from prefect import flow, task, get_run_logger
import requests
import json
import time
from random import randint, random
def rename_flow_run(new_name: str):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@AruniRC
AruniRC / ms_coco_classnames.txt
Created March 5, 2018 20:37
Class Names of MS-COCO classes in order of Detectron dict
{0: u'__background__',
1: u'person',
2: u'bicycle',
3: u'car',
4: u'motorcycle',
5: u'airplane',
6: u'bus',
7: u'train',
8: u'truck',
9: u'boat',
anonymous
anonymous / index.html
Created May 27, 2017 21:39
Minimal BootStrap 3 Template
<html>
<head>
<title>Hello World!</title>
<meta charset="utf-8"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<link href='https://fonts.googleapis.com/css?family=Roboto:300,400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="main.css">
@jasonhinkle
jasonhinkle / ajax.js
Last active February 20, 2023 17:42
jQuery AJAX Snippet
$.ajax({
url: 'api/url',
method: 'POST',
data: {var:'val'},
// data: JSON.stringify({var:'val'}), // send data in the request body
// contentType: "application/json; charset=utf-8", // if sending in the request body
dataType: 'json'
}).done(function(data, textStatus, jqXHR) {
// because dataType is json 'data' is guaranteed to be an object
console.log('done');
@danfinlay
danfinlay / How to download streaming video.md
Last active March 23, 2024 03:32
How to download a streaming video with Google Chrome

How to download streaming video

Streaming just means a download that they don't want you to keep. But Chrome's developer tools make it easy to access what's really going on under the hood.

Open Developer Tools

From the page where you want to download some things, go into your chrome menu to open the developer tools. You can either:

1.  (On a mac): Command-option-J
2. (On a PC): Control-alt-J