adinarayana commited on
Commit
3858f1c
·
verified ·
1 Parent(s): a9ed5cd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -44
app.py CHANGED
@@ -1,46 +1,3 @@
1
- """
2
- from langchain.llms import OpenAI
3
-
4
- # from dotenv import load_dotenv
5
- import os
6
-
7
- # take environment variables from .env
8
- # load_dotenv()
9
-
10
- import streamlit as st
11
-
12
- # load OpenAI model and get a response
13
-
14
-
15
- def get_openai_response(question):
16
- llm = OpenAI(
17
- openai_api_key=os.getenv("OPEN_API_KEY"),
18
- model_name="gpt-3.5-turbo-instruct",
19
- temperature=0.6,
20
- )
21
- response = llm(question)
22
- return response
23
- # modify with chain and other stuff
24
-
25
-
26
- ## streamlit app
27
-
28
- st.set_page_config(page_title="QandA Demo")
29
- st.header("Langchain Application")
30
-
31
- input = st.text_input("Input: ", key=input)
32
- response = get_openai_response(input)
33
-
34
-
35
- submit = st.button("Generate")
36
- if submit:
37
- st.subheader("The response is")
38
- st.write(response)
39
- """
40
-
41
-
42
-
43
-
44
  import os
45
  import re
46
  import pdfminer
@@ -68,7 +25,7 @@ def preprocess_text(element):
68
 
69
  def get_openai_response(text, length=100, model="gpt-3.5-turbo-instruct"):
70
  summarizer = pipeline("summarization", model=model)
71
- return summarizer(text, max_length=length)
72
 
73
  ## Streamlit app
74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
  import re
3
  import pdfminer
 
25
 
26
  def get_openai_response(text, length=100, model="gpt-3.5-turbo-instruct"):
27
  summarizer = pipeline("summarization", model=model)
28
+ return summarizer(text, min_length = length)
29
 
30
  ## Streamlit app
31