File size: 1,269 Bytes
18f5c04
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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")
    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 = get_response(question, rerank_type, llm_type)
    print(response)
    print(links)
    print(titles)
    print(domains)