tldr_crawlre / app.py
Defender117's picture
Upload 5 files
b6204d2 verified
raw
history blame contribute delete
992 Bytes
from fastapi import FastAPI
from transformers import pipeline
import crawl_archive
import GenerateAIPodcast
from llama_cpp import Llama
app = FastAPI()
llm = Llama.from_pretrained(
repo_id="hugging-quants/Llama-3.2-1B-Instruct-Q8_0-GGUF",
filename="llama-3.2-1b-instruct-q8_0.gguf",
)
@app.get("/")
def home():
return {"message":"Hello World"}
# Define a function to handle the GET request at `/generate`
@app.get("/generate")
def generate(link:str):
## use the pipeline to generate text from given input text
output= llm.create_chat_completion(
messages = [
{"role": "system",
"content": "Always answer short and most detailled and dont use * in your answers. It should be good to hear as a Podcast"},
{"role": "user", "content": f"Please summarize this website: {link}."}
]
)
## return the generate text in Json reposnfe
return output['choices'][0]['message']['content']
crawl_archive.run_tldr_crawler()