Spaces:
Runtime error
Runtime error
File size: 1,429 Bytes
5466e09 c50f774 5466e09 c50f774 5466e09 c50f774 5466e09 c50f774 5466e09 c50f774 5466e09 c50f774 5466e09 c50f774 5466e09 c50f774 5466e09 c50f774 5466e09 c50f774 5466e09 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # 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()
|