Gurudev commited on
Commit
24ec173
·
1 Parent(s): 6cad417

cleaner key display

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import streamlit as st
2
  import pandas as pd
3
  from langchain.prompts import FewShotPromptTemplate, PromptTemplate
4
- from langchain.llms import OpenAIChat
5
  from langchain.callbacks import get_openai_callback
6
  from langchain.chains import LLMChain
7
 
@@ -23,7 +23,7 @@ selected_model = st.sidebar.selectbox(
23
  selected_dataset = st.sidebar.selectbox(
24
  "Select Dataset", ["Regulatory Changes", "Dealer Risk", "Custom"]
25
  )
26
- openai_api_key = st.sidebar.text_input("OpenAI API Key", value="xxx", type="password")
27
 
28
 
29
  prompt_prefix = """You are a news recommender and your job is to look at an article and decide if I would find it useful or not.
@@ -188,7 +188,9 @@ for index, row in predictions_data.iterrows():
188
  st.markdown("---")
189
 
190
 
191
- llm = OpenAIChat(temperature=0.0, openai_api_key=openai_api_key)
 
 
192
  example_prompt = PromptTemplate(
193
  input_variables=["headline", "publisher", "answer"],
194
  template="Headline: {headline}\nPublisher: {publisher}\nAnswer: {answer}",
 
1
  import streamlit as st
2
  import pandas as pd
3
  from langchain.prompts import FewShotPromptTemplate, PromptTemplate
4
+ from langchain.chat_models import ChatOpenAI
5
  from langchain.callbacks import get_openai_callback
6
  from langchain.chains import LLMChain
7
 
 
23
  selected_dataset = st.sidebar.selectbox(
24
  "Select Dataset", ["Regulatory Changes", "Dealer Risk", "Custom"]
25
  )
26
+ openai_api_key = st.sidebar.text_input("OpenAI API Key", value="", type="password")
27
 
28
 
29
  prompt_prefix = """You are a news recommender and your job is to look at an article and decide if I would find it useful or not.
 
188
  st.markdown("---")
189
 
190
 
191
+ llm = ChatOpenAI(
192
+ temperature=0.0, openai_api_key=openai_api_key if openai_api_key != "" else " "
193
+ )
194
  example_prompt = PromptTemplate(
195
  input_variables=["headline", "publisher", "answer"],
196
  template="Headline: {headline}\nPublisher: {publisher}\nAnswer: {answer}",