Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -105,7 +105,8 @@ elif st.session_state.step == 5:
|
|
| 105 |
|
| 106 |
with st.spinner("Generating your post... β¨"):
|
| 107 |
|
| 108 |
-
|
|
|
|
| 109 |
model="mixtral-8x7b-32768",
|
| 110 |
messages=[
|
| 111 |
{"role": "user", "content": user_input}
|
|
@@ -113,19 +114,14 @@ elif st.session_state.step == 5:
|
|
| 113 |
max_tokens=500
|
| 114 |
)
|
| 115 |
|
| 116 |
-
# β
Extract response properly
|
| 117 |
post = response.choices[0].message.content
|
| 118 |
|
| 119 |
-
# β
Show success
|
| 120 |
st.success("β
Your LinkedIn Post is Ready!")
|
| 121 |
-
|
| 122 |
-
# β
Display output
|
| 123 |
st.markdown("### π’ Generated Post")
|
| 124 |
st.write(post)
|
| 125 |
|
| 126 |
-
# β
Reset button
|
| 127 |
if st.button("π Create Another"):
|
| 128 |
st.session_state.step = 1
|
| 129 |
|
| 130 |
-
except Exception as e:
|
| 131 |
st.error(f"Error: {str(e)}")
|
|
|
|
| 105 |
|
| 106 |
with st.spinner("Generating your post... β¨"):
|
| 107 |
|
| 108 |
+
try:
|
| 109 |
+
response = client.chat.completions.create(
|
| 110 |
model="mixtral-8x7b-32768",
|
| 111 |
messages=[
|
| 112 |
{"role": "user", "content": user_input}
|
|
|
|
| 114 |
max_tokens=500
|
| 115 |
)
|
| 116 |
|
|
|
|
| 117 |
post = response.choices[0].message.content
|
| 118 |
|
|
|
|
| 119 |
st.success("β
Your LinkedIn Post is Ready!")
|
|
|
|
|
|
|
| 120 |
st.markdown("### π’ Generated Post")
|
| 121 |
st.write(post)
|
| 122 |
|
|
|
|
| 123 |
if st.button("π Create Another"):
|
| 124 |
st.session_state.step = 1
|
| 125 |
|
| 126 |
+
except Exception as e:
|
| 127 |
st.error(f"Error: {str(e)}")
|