Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -6,38 +6,36 @@ from groq import Groq
|
|
| 6 |
# Set up Groq client using the environment variable for API key.
|
| 7 |
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
| 8 |
|
| 9 |
-
|
|
|
|
| 10 |
speaker_options = {
|
| 11 |
"Liam": "A male voice",
|
| 12 |
"Dorothy": "A female voice",
|
| 13 |
}
|
| 14 |
|
| 15 |
-
# Build the Streamlit UI
|
| 16 |
st.title("Conversation Script Generator Using Groq API")
|
| 17 |
|
| 18 |
-
# Layout two columns for speaker selection.
|
| 19 |
col1, col2 = st.columns(2)
|
|
|
|
| 20 |
with col1:
|
| 21 |
-
left_speaker = st.
|
| 22 |
-
|
| 23 |
-
options=list(speaker_options.keys()),
|
| 24 |
-
format_func=lambda x: f"{x}: {speaker_options[x]}"
|
| 25 |
-
)
|
| 26 |
with col2:
|
| 27 |
-
right_speaker = st.
|
| 28 |
-
"Right Speaker",
|
| 29 |
-
options=list(speaker_options.keys()),
|
| 30 |
-
format_func=lambda x: f"{x}: {speaker_options[x]}"
|
| 31 |
-
)
|
| 32 |
|
| 33 |
-
# Text area for overall conversation theme
|
| 34 |
theme = st.text_area("Overall Theme of the Conversation", height=100)
|
| 35 |
|
| 36 |
-
# Optional additional details
|
| 37 |
additional_details = st.text_area("Additional Conversation Details (Optional)", height=100)
|
| 38 |
|
| 39 |
-
#
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
# Build the prompt message for Groq API.
|
| 42 |
prompt = (
|
| 43 |
f"""
|
|
@@ -194,7 +192,7 @@ Theme={theme}
|
|
| 194 |
]
|
| 195 |
|
| 196 |
# Model selection: adjust as needed.
|
| 197 |
-
model = "llama-
|
| 198 |
|
| 199 |
try:
|
| 200 |
# Make the chat completion call using Groq.
|
|
|
|
| 6 |
# Set up Groq client using the environment variable for API key.
|
| 7 |
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
| 8 |
|
| 9 |
+
|
| 10 |
+
# Speaker options
|
| 11 |
speaker_options = {
|
| 12 |
"Liam": "A male voice",
|
| 13 |
"Dorothy": "A female voice",
|
| 14 |
}
|
| 15 |
|
| 16 |
+
# Build the Streamlit UI
|
| 17 |
st.title("Conversation Script Generator Using Groq API")
|
| 18 |
|
|
|
|
| 19 |
col1, col2 = st.columns(2)
|
| 20 |
+
|
| 21 |
with col1:
|
| 22 |
+
left_speaker = st.text_input("Left Speaker", placeholder="Enter left speaker name")
|
| 23 |
+
|
|
|
|
|
|
|
|
|
|
| 24 |
with col2:
|
| 25 |
+
right_speaker = st.text_input("Right Speaker", placeholder="Enter right speaker name")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
+
# Text area for overall conversation theme
|
| 28 |
theme = st.text_area("Overall Theme of the Conversation", height=100)
|
| 29 |
|
| 30 |
+
# Optional additional details
|
| 31 |
additional_details = st.text_area("Additional Conversation Details (Optional)", height=100)
|
| 32 |
|
| 33 |
+
# Check if all required fields are filled
|
| 34 |
+
is_ready = bool(theme and left_speaker and right_speaker)
|
| 35 |
+
|
| 36 |
+
# Disable the button if required fields are not filled
|
| 37 |
+
if st.button("Generate Conversation", disabled=not is_ready):
|
| 38 |
+
|
| 39 |
# Build the prompt message for Groq API.
|
| 40 |
prompt = (
|
| 41 |
f"""
|
|
|
|
| 192 |
]
|
| 193 |
|
| 194 |
# Model selection: adjust as needed.
|
| 195 |
+
model = "deepseek-r1-distill-llama-70b"
|
| 196 |
|
| 197 |
try:
|
| 198 |
# Make the chat completion call using Groq.
|