File size: 1,183 Bytes
6bdc75d
 
 
 
 
fdcd91c
 
6bdc75d
 
95e2ab5
 
 
efbfd3b
fc10cd6
52b4066
 
 
 
 
 
 
 
 
 
6bdc75d
52b4066
 
 
 
964c1fd
52b4066
 
 
 
6bdc75d
 
 
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
from flask import Flask, jsonify, render_template, request, send_file
from langchain import OpenAI
from langchain.docstore.document import Document
from langchain.text_splitter import CharacterTextSplitter
from langchain.chains.summarize import load_summarize_chain
from langchain_g4f import G4FLLM
from g4f import Provider, models

app = Flask(__name__)
@app.route("/")
def index():
    return jsonify({"output": ""})
@app.route("/<text>",methods=["GET"])
def t5(text):
    # prompt_template = """Write a concise summary around 450 words of the following :
    # "{text}"
    # CONCISE SUMMARY:"""
    # prompt = PromptTemplate.from_template(prompt_template)
    # # Instantiate the LLM model
    # llm = G4FLLM(
    #     model=models.gpt_35_turbo,
    #     provider=Provider.FreeGpt,
    # )
    # llm_chain = LLMChain(llm=llm, prompt=prompt)

    # # Define StuffDocumentsChain
    # stuff_chain = StuffDocumentsChain(
    #     llm_chain=llm_chain, document_variable_name="text"
    # )
    
    # docs = loader.load()
    output = stuff_chain.run(docs)
    output = text
    return jsonify({"output": output})

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=7860)