vtiyyal1's picture
Upload full_chain.py
5c69ef0 verified
raw
history blame
1.43 kB
import os
import pandas as pd
from get_keywords import get_keywords
from get_articles import save_solr_articles_full
from rerank import langchain_rerank_answer, langchain_with_sources, crossencoder_rerank_answer, \
crossencoder_rerank_sentencewise, crossencoder_rerank_sentencewise_articles, no_rerank
#from feed_to_llm import feed_articles_to_gpt_with_links
from feed_to_llm_v2 import feed_articles_to_gpt_with_links
def get_response(question, rerank_type="crossencoder", llm_type="chat"):
csv_path = save_solr_articles_full(question, keyword_type="rake", num_articles=10)
reranked_out = crossencoder_rerank_answer(csv_path, question)
return feed_articles_to_gpt_with_links(reranked_out, question)
# save_path = save_solr_articles_full(question)
# information = crossencoder_rerank_answer(save_path, question)
# response, links, titles = feed_articles_to_gpt_with_links(information, question)
#
# return response, links, titles
if __name__ == "__main__":
question = "How is United States fighting against tobacco addiction?"
rerank_type = "crossencoder"
llm_type = "chat"
response, links, titles, domains, published_dates = get_response(question, rerank_type, llm_type)
print("Response:", response)
print("Links:", links)
print("Titles:", titles)
print("Domains:", domains)
print("Published Dates:", published_dates)