Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
|
|
3 |
from groq import Groq
|
4 |
|
5 |
groq_client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
@@ -20,14 +21,14 @@ def call_groq_api(specific, measurable, achievable, relevant, time_bound):
|
|
20 |
|
21 |
chat_completion = groq_client.chat.completions.create(
|
22 |
messages=[{"role": "user", "content": prompt}],
|
23 |
-
model="
|
24 |
)
|
25 |
|
26 |
if chat_completion.choices:
|
27 |
generated_text = chat_completion.choices[0].message.content
|
28 |
print("LLM Response:", generated_text)
|
29 |
-
options =
|
30 |
-
formatted_options = [opt for opt in options if opt.strip().startswith('Option')]
|
31 |
return '\n\n'.join(formatted_options)
|
32 |
else:
|
33 |
print("Error: No response from Groq API or API returned an unexpected format.")
|
@@ -85,7 +86,7 @@ interface = gr.Interface(
|
|
85 |
outputs=[
|
86 |
gr.Textbox(label="Generated SMART Goals", lines=10, placeholder="Generated content will appear here...")
|
87 |
],
|
88 |
-
title="SMART Goals Builder powered by
|
89 |
description="Fill out each field to generate SMART goals."
|
90 |
)
|
91 |
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
import re
|
4 |
from groq import Groq
|
5 |
|
6 |
groq_client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
|
|
21 |
|
22 |
chat_completion = groq_client.chat.completions.create(
|
23 |
messages=[{"role": "user", "content": prompt}],
|
24 |
+
model="llama3-70b-8192",
|
25 |
)
|
26 |
|
27 |
if chat_completion.choices:
|
28 |
generated_text = chat_completion.choices[0].message.content
|
29 |
print("LLM Response:", generated_text)
|
30 |
+
options = re.split(r'\n\s*\n', generated_text)
|
31 |
+
formatted_options = [opt for opt in options if opt.strip().startswith('**Option')]
|
32 |
return '\n\n'.join(formatted_options)
|
33 |
else:
|
34 |
print("Error: No response from Groq API or API returned an unexpected format.")
|
|
|
86 |
outputs=[
|
87 |
gr.Textbox(label="Generated SMART Goals", lines=10, placeholder="Generated content will appear here...")
|
88 |
],
|
89 |
+
title="SMART Goals Builder powered by Llama3 and Groq",
|
90 |
description="Fill out each field to generate SMART goals."
|
91 |
)
|
92 |
|