CoolFace
Apppublic

emraangi/LLMInroduction

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
app.py42 linesDownload Raw Back to root
1#Hello! It seems like you want to import the Streamlit library in Python. Streamlit is a powerful open-source framework used for building web applications with interactive data visualizations and machine learning models. To import Streamlit, you'll need to ensure that you have it installed in your Python environment.2#Once you have Streamlit installed, you can import it into your Python script using the import statement,3 4import streamlit as st5 6from langchain.llms import OpenAI7 8#When deployed on huggingface spaces, this values has to be passed using Variables & Secrets setting, as shown in the video :)9#import os10#os.environ["OPENAI_API_KEY"] = "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"11 12#Function to return the response13def load_answer(question):14    # "text-davinci-003" model is depreciated, so using the latest one https://platform.openai.com/docs/deprecations15    llm = OpenAI(model_name="gpt-3.5-turbo-instruct",temperature=0)16    answer=llm(question)17    return answer18 19 20#App UI starts here21st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")22st.header("LangChain Demo")23 24#Gets the user input25def get_text():26    input_text = st.text_input("You: ", key="input")27    return input_text28 29 30user_input=get_text()31response = load_answer(user_input)32 33submit = st.button('Generate')  34 35#If generate button is clicked36if submit:37 38    st.subheader("Answer:")39 40    st.write(response)41 42