This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The most complex part of the modal system | |
// There are lot of small details heres | |
// I extracted this from a real project | |
// Notice: Hooks hide a lot of complexity | |
import { IModalOpen } from './types'; | |
import { closeModal } from './triggers'; | |
import { useEffect, useMemo, useRef, useState } from 'react'; | |
import { useEventBus } from '../eventBus'; | |
import { InsideModalProvider } from './context'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function termFreqMap(str) { | |
var words = str.split(' '); | |
var termFreq = {}; | |
words.forEach(function(w) { | |
termFreq[w] = (termFreq[w] || 0) + 1; | |
}); | |
return termFreq; | |
} | |
function addKeysToDict(map, dict) { |