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
{ | |
"MarineWeatherAPI": { | |
"description": "Hourly and daily marine weather forecasts with 5 km resolution", | |
"inputs": { | |
"location": { | |
"type": "object", | |
"properties": { | |
"latitude": "float", | |
"longitude": "float", | |
"bbox": "array<float> (optional)", |
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 sentence_transformers import SentenceTransformer, util | |
import fitz # PyMuPDF | |
def extract_text_from_pdf(path): | |
doc = fitz.open(path) | |
text = "" | |
for page in doc: | |
text += page.get_text() | |
return text |
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 json | |
from serp_maritime import run_search | |
academies = [ | |
"Maine Maritime Academy mission statement", | |
"Massachusetts Maritime Academy mission statement", | |
"SUNY Maritime College mission statement", | |
"Texas A&M Maritime Academy mission statement", | |
"California State University Maritime Academy mission statement", | |
"Great Lakes Maritime Academy mission statement" |
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
# STEP 1 | |
import os | |
import fitz # PyMuPDF | |
pdf_dir = "[PDF DIR]" # the PDF directory | |
out_dir = os.path.join(pdf_dir, "chunks") | |
os.makedirs(out_dir, exist_ok=True) | |
for pdf_file in os.listdir(pdf_dir): |
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 json | |
import os | |
import tempfile | |
from langchain_community.document_loaders import TextLoader | |
from langchain.indexes import VectorstoreIndexCreator | |
from langchain_openai import OpenAIEmbeddings | |
# Function to load and index the document text in chunks | |
def load_and_index(file_path, chunk_size=1000, overlap=100): | |
with open(file_path, 'r', encoding='utf-8') as file: |