vickyy07 commited on
Commit
32feff8
·
verified ·
1 Parent(s): 84962b0

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -38
app.py DELETED
@@ -1,38 +0,0 @@
1
- ## Q&A Chatbot
2
- from langchain.llms import OpenAI # Updated import for OpenAI
3
- from dotenv import load_dotenv
4
-
5
- load_dotenv() # take environment variables from .env.
6
-
7
- import streamlit as st
8
- import os
9
- import openai # Import the OpenAI library
10
-
11
- # Set the OpenAI API key globally
12
- openai.api_key = os.getenv("OPENAI_API_KEY")
13
- if not openai.api_key:
14
- raise ValueError("OpenAI API key is not set. Please set the OPENAI_API_KEY environment variable.")
15
-
16
- # Function to load OpenAI model and get response
17
- def get_openai_response(question):
18
- # Create an instance of the OpenAI model
19
- llm = OpenAI(model_name="gpt-3.5-turbo", temperature=0.5)
20
- response = llm(question)
21
- return response
22
-
23
- # Initialize our Streamlit app
24
- st.set_page_config(page_title="Q&A Demo")
25
-
26
- st.header("Langchain Application")
27
-
28
- input_text = st.text_input("Input:", key="input")
29
- submit = st.button("Ask the question")
30
-
31
- # If ask button is clicked
32
- if submit and input_text:
33
- try:
34
- response = get_openai_response(input_text)
35
- st.subheader("The Response is:")
36
- st.write(response)
37
- except Exception as e:
38
- st.error(f"An error occurred: {e}")