Spaces:
Runtime error
Runtime error
from fastapi import FastAPI | |
import os | |
from langchain.document_loaders import DirectoryLoader | |
import wandb | |
import huggingface_hub | |
from scripts.summarization import falcon_summ | |
from scripts.decision_clf import seq_clf | |
from scripts.path_gen import paths_gen | |
from scripts.text_gen import story_gen | |
app = FastAPI() | |
wandb.login(key = os.getenv('wandb_key')) | |
huggingface_hub.login(token = os.getenv('hf_key')) | |
os.environ['OPENAI_API_KEY'] = os.getenv('openapi_key') | |
summarizer = falcon_summ.prep_pipeline() | |
token_path= 'models/dec_clf/tokenizer.pkl' | |
model_path = 'models/dec_clf/nlp.h5' | |
chunks = paths_gen.get_chunks("data/dune.pdf") | |
db = paths_gen.get_vectordb(chunks) | |
def hello(): | |
return {"message": "Hello World"} | |
def summ(text: str): | |
return { "summary": falcon_summ.gen_summary(summarizer, text)} | |
def clf(text: str): | |
return {"decision": seq_clf.predict(text, model_path, token_path)} | |
def gen_path(text: str): | |
return paths_gen.gen_sample(text, db) | |
def gen_story(text: str, decision: str): | |
return story_gen.gen_sample(text, decision, db) | |