File size: 1,189 Bytes
3abee27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dc4b86a
 
3abee27
dc4b86a
 
 
 
3abee27
 
 
 
 
dc4b86a
3abee27
 
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
# from z_utils import get_dataframe
# import numpy as np

# # CONST
# SUMMARY_VECTORS = "app_cache/summary_vectors.npy"
# BOOKS_CSV = "clean_books_summary.csv"

# def get_recommendation(book_title: str) -> str:
#     return book_title


# def sanity_check():
#     '''Validates whether the vectors count is of same as summaries present else RAISES Error
#     '''
#     global BOOKS_CSV, SUMMARY_VECTORS
#     df = get_dataframe(BOOKS_CSV)
#     vectors = np.load(SUMMARY_VECTORS)
#     assert df.shape[0] == vectors.shape[0]
    

# Reference: https://huggingface.co/learn/nlp-course/en/chapter9/2

import gradio as gr
from z_similarity import computes_similarity_w_hypothetical
from z_hypothetical_summary import generate_summaries

def get_recommendation(book_title: str):
    # Generate hypothetical summary
    fake_summaries = generate_summaries(book_title=book_title, n_samples=5) # other parameters are set to default in the function
    return fake_summaries[0]

# We instantiate the Textbox class
textbox = gr.Textbox(label="Write truth you wana Know:", placeholder="John Doe", lines=2)


demo = gr.Interface(fn=get_recommendation, inputs=textbox, outputs="text")

demo.launch()