Gigishot commited on
Commit
c486e29
·
verified ·
1 Parent(s): a9fb58c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -8
app.py CHANGED
@@ -15,12 +15,17 @@ client = Groq(
15
 
16
  def generate_blog(topic):
17
 
18
- prompt = f"Write a short blog about {topic}"
 
19
 
20
- try:
 
 
 
 
 
21
 
22
- print("Generating blog...")
23
- print("API KEY EXISTS:", os.getenv("GROQ_API_KEY") is not None)
24
 
25
  completion = client.chat.completions.create(
26
  model="llama-3.1-8b-instant",
@@ -31,16 +36,20 @@ def generate_blog(topic):
31
  }
32
  ],
33
  temperature=0.7,
34
- max_tokens=300,
35
  )
36
 
37
- print("SUCCESS")
 
 
 
38
 
39
- return completion.choices[0].message.content
40
 
41
  except Exception as e:
42
 
43
- print("FULL ERROR:", str(e))
 
44
 
45
  return f"Error: {str(e)}"
46
 
 
15
 
16
  def generate_blog(topic):
17
 
18
+ prompt = f"""
19
+ Write a detailed blog article about: {topic}
20
 
21
+ Include:
22
+ 1. Title
23
+ 2. Introduction
24
+ 3. Main Content
25
+ 4. Conclusion
26
+ """
27
 
28
+ try:
 
29
 
30
  completion = client.chat.completions.create(
31
  model="llama-3.1-8b-instant",
 
36
  }
37
  ],
38
  temperature=0.7,
39
+ max_tokens=700,
40
  )
41
 
42
+ generated_text = completion.choices[0].message.content
43
+
44
+ print("GENERATED:")
45
+ print(generated_text)
46
 
47
+ return generated_text
48
 
49
  except Exception as e:
50
 
51
+ print("ERROR:")
52
+ print(str(e))
53
 
54
  return f"Error: {str(e)}"
55