Spaces:
Sleeping
Sleeping
Update app.py
Browse files1 unmodified line23456789101112133 unmodified lines171819202122232425262728293031323334351 unmodified lineimport osfrom groq import Groq # Ensure Groq library supports this usagefrom dotenv import load_dotenvload_dotenv()os.getenv("GROQ_API_KEY")def fetch_response(user_input):client = Groq(api_key=os.getenv("GROQ_API_KEY"))chat_completion = client.chat.completions.create(messages=[{"role": "system", "content": "you are a helpful assistant. Take the input from the users and try to provide as detailed response as possible. Provide proper expamples to help the user. Try to mention references or provide citations to make it more detail oriented."},3 unmodified linesstream=False)return chat_completion.choices[0].message.content# for each in chat_completion:# yield (each.choices[0].delta.content)# #end=""def fetch_response(text_input):# Implement your function to fetch response herereturn "Response: " + text_input # For demonstration purposesst.title("Fastest AI Chatbot By DL Titan")st.write("Ask a question and get a response.")text_input = st.text_input("Enter your question here:")if st.button("Submit"):response = fetch_response(text_input)st.write(response)1 unmodified line2345678910111213141516173 unmodified lines212223242526272829303132333435361 unmodified lineimport osfrom groq import Groq # Ensure Groq library supports this usagefrom dotenv import load_dotenv# Load environment variables from .env fileload_dotenv()# Retrieve Groq API key from environment variablesGROQ_API_KEY = os.getenv("GROQ_API_KEY")# Define function to fetch responsedef fetch_response(user_input):client = Groq(api_key=GROQ_API_KEY)chat_completion = client.chat.completions.create(messages=[{"role": "system", "content": "you are a helpful assistant. Take the input from the users and try to provide as detailed response as possible. Provide proper expamples to help the user. Try to mention references or provide citations to make it more detail oriented."},3 unmodified linesstream=False)return chat_completion.choices[0].message.content# Streamlit appst.title("Fastest AI Chatbot By DL Titans")st.write("Ask a question and get a response.")# Text input for user's questionuser_input = st.text_input("Enter your question here:")# Button to trigger responseif st.button("Get Response"):# Fetch and display responseresponse = fetch_response(user_input)st.write("Response:", response)
app.py+16-15