Project1 / app.py
amaanadeen's picture
Update app.py
5466e09
# Streamlit imports and setup
import streamlit as st
# OpenAI API setup
import openai
openai.api_key = "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"
def resolve_error(error_code, error_message):
# Combine the user inputs and formulate a prompt for the ChatGPT API
prompt = f"Given the error code:\n```{error_code}```\nand the error message:\n```{error_message}```\nPlease provide a resolution as you would do to a 15 year old along with a detailed review of what went wrong.\n"
# Get the response from the ChatGPT API
response = openai.Completion.create(
engine="text-davinci-002",
prompt=prompt,
max_tokens=500, # Adjust as needed based on the desired response length
stop=None, # Add stop sequences if needed
)
return response.choices[0].text
# Streamlit app code
def main():
st.title("Code Error Resolution by FULL STACK ACADEMY")
st.write("Enter the error code and error message below:")
error_code = st.text_area("Error Code")
error_message = st.text_area("Error Message")
if st.button("Resolve"):
if error_code and error_message:
resolution = resolve_error(error_code, error_message)
st.subheader("Resolution:")
st.code(resolution, language="python")
else:
st.warning("Please enter both the error code and the error message.")
if __name__ == "__main__":
main()