Spaces:
Runtime error
Runtime error
File size: 1,179 Bytes
6c57304 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
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)
@app.get("/hello")
def hello():
return {"message": "Hello World"}
@app.post("/summ")
def summ(text: str):
return { "summary": falcon_summ.gen_summary(summarizer, text)}
@app.post("/clf")
def clf(text: str):
return {"decision": seq_clf.predict(text, model_path, token_path)}
@app.post("/gen_path")
def gen_path(text: str):
return paths_gen.gen_sample(text, db)
@app.post("/gen_story")
def gen_story(text: str, decision: str):
return story_gen.gen_sample(text, decision, db)
|