# Trying to execute script from text inside a streamlit chat

**URL:** <https://discuss.streamlit.io/t/trying-to-execute-script-from-text-inside-a-streamlit-chat/77578>\
**Category:** LLMs and AI\
**Tags:** discussion\
**Created:** [August 6, 2024, 8:50pm UTC](https://discuss.streamlit.io/t/trying-to-execute-script-from-text-inside-a-streamlit-chat/77578 "2024-08-06T20:50:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rabi320](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/rabi320/32/47279_2.png) [@rabi320](https://discuss.streamlit.io/u/rabi320)\
**Post date:** [August 6, 2024, 8:50pm UTC](https://discuss.streamlit.io/t/trying-to-execute-script-from-text-inside-a-streamlit-chat/77578/1 "2024-08-06T20:50:39Z")

</div>

Hi! I am currently trying to execute a code that the openAI GPT LLM is writing for me, then executing this code and lastly using a variable in that script named answer as the chat response, unfortunately it is not working using exec() as i did in a regular python script, and i am having difficulty finding an alternative for it, any way in making this functionality another way in the streamlit app?
