This file contains hidden or 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
from fastembed.embedding import TextEmbedding | |
def get_book_vector(book_data): | |
embedder = TextEmbedding(model_name="BAAI/bge-base-en") | |
text = f"{book_data['title']} {book_data['description']}" | |
vector = list(embedder.embed(text)) | |
return vector[0] # Since embed returns a generator, we convert it to a list and take the first item. | |
def get_query_vector(query_text): | |
embedder = TextEmbedding(model_name="BAAI/bge-base-en") |
This file contains hidden or 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
from config import COLLECTION_NAME | |
import os | |
import csv | |
from qdrant_client.http.models import VectorParams, PointStruct | |
from dotenv import load_dotenv | |
from generate_embedding import get_book_vector | |
from connect_qdrant import get_qdrant_client | |
load_dotenv() | |
qdrant_client = get_qdrant_client() |
This file contains hidden or 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
import os | |
import csv | |
from concurrent.futures import ThreadPoolExecutor | |
from qdrant_client import QdrantClient | |
from qdrant_client.http.models import PointStruct | |
from fastembed import TextEmbedding | |
from dotenv import load_dotenv | |
# Load environment variables from a .env file | |
load_dotenv() |
This file contains hidden or 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
import os | |
from qdrant_client import QdrantClient | |
from fastembed import TextEmbedding | |
from dotenv import load_dotenv | |
from qdrant_client.http.models import Distance, VectorParams | |
# Load environment variables from a .env file | |
load_dotenv() | |
# Access the environment variables |
This file contains hidden or 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
from query import search_books | |
def main(): | |
query_text = "carl sagan, cosmos" | |
results = search_books(query_text) | |
if not results: | |
print("No results found") | |
else: | |
for point in results: |
This file contains hidden or 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
[package] | |
name = "io_server" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
tokio = { version = "1", features = ["full"] } | |
io-uring = "0.5" | |
[[bin]] |
This file contains hidden or 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
#[tokio::main] | |
async fn main() -> Result<()> { | |
let addr = "127.0.0.1:8080".parse::<SocketAddr>().unwrap(); | |
let listener = TcpListener::bind(addr).await.unwrap(); | |
let mut ring = IoUring::new(256)?; | |
loop { | |
let (stream, _) = listener.accept().await?; | |
handle_client(stream, &mut ring).await?; | |
} |
This file contains hidden or 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
use io_uring::{IoUring, opcode, types::Fd}; | |
use std::net::SocketAddr; | |
use std::os::fd::AsRawFd; | |
use tokio::net::{TcpListener, TcpStream}; | |
use std::io::Result; | |
async fn handle_client(stream: TcpStream, ring: &mut IoUring) -> Result<()> { | |
let mut buf = [0; 1024]; | |
// Prepare a read operation |
This file contains hidden or 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
// Load user settings and apply them to the page | |
chrome.storage.sync.get(['fontSize', 'bgColor'], (settings) => { | |
if (settings.fontSize) { | |
document.body.style.fontSize = `${settings.fontSize}px`; | |
} | |
if (settings.bgColor) { | |
document.body.style.backgroundColor = settings.bgColor; | |
} | |
}); | |
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hyperfocus</title> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
width: 200px; | |
padding: 10px; |