cryogenic22 commited on
Commit
ac46df8
·
verified ·
1 Parent(s): 635af7a

Update agents.py

Browse files
Files changed (1) hide show
  1. agents.py +17 -12
agents.py CHANGED
@@ -3,13 +3,18 @@ import anthropic
3
  import json
4
  import os
5
 
6
- # Initialize the Claude client with API key from environment or Streamlit secrets
7
- api_key = os.environ.get("ANTHROPIC_API_KEY")
8
- if not api_key and hasattr(st, "secrets") and "ANTHROPIC_API_KEY" in st.secrets:
9
- api_key = st.secrets["ANTHROPIC_API_KEY"]
10
-
11
- # Create the client
12
- client = anthropic.Anthropic(api_key=api_key)
 
 
 
 
 
13
 
14
  def enhance_slide_component(slide, component, instruction=None):
15
  """Enhance a specific component of a slide using Claude API"""
@@ -47,7 +52,7 @@ def enhance_title(slide, instruction=None):
47
 
48
  try:
49
  response = client.messages.create(
50
- model="claude-3-sonnet-20240229",
51
  max_tokens=100,
52
  temperature=0.7,
53
  system="You are an expert presentation title specialist. Respond only with the revised title.",
@@ -91,7 +96,7 @@ def enhance_content(slide, instruction=None):
91
 
92
  try:
93
  response = client.messages.create(
94
- model="claude-3-sonnet-20240229",
95
  max_tokens=500,
96
  temperature=0.7,
97
  system="You are an expert presentation content specialist. Respond with a JSON array of bullet points.",
@@ -146,7 +151,7 @@ def enhance_visuals(slide, instruction=None):
146
 
147
  try:
148
  response = client.messages.create(
149
- model="claude-3-sonnet-20240229",
150
  max_tokens=300,
151
  temperature=0.7,
152
  system="You are an expert presentation visual designer. Respond with a JSON array of visual element recommendations.",
@@ -200,7 +205,7 @@ def enhance_notes(slide, instruction=None):
200
 
201
  try:
202
  response = client.messages.create(
203
- model="claude-3-sonnet-20240229",
204
  max_tokens=500,
205
  temperature=0.7,
206
  system="You are an expert presentation coach. Provide comprehensive presenter notes.",
@@ -247,7 +252,7 @@ def enhance_structure(slide, instruction=None):
247
 
248
  try:
249
  response = client.messages.create(
250
- model="claude-3-sonnet-20240229",
251
  max_tokens=400,
252
  temperature=0.7,
253
  system="You are an expert presentation structure specialist. Respond with a JSON object containing layout recommendations.",
 
3
  import json
4
  import os
5
 
6
+ # Initialize the Claude client with API key from environment (Huggingface secrets)
7
+ api_key = os.getenv("ANTHROPIC_API_KEY")
8
+ if not api_key:
9
+ st.sidebar.error("ANTHROPIC_API_KEY not found in environment variables")
10
+ client = None
11
+ else:
12
+ # Create the client
13
+ try:
14
+ client = anthropic.Anthropic(api_key=api_key)
15
+ except Exception as e:
16
+ st.sidebar.error(f"Error initializing Anthropic API: {str(e)}")
17
+ client = None
18
 
19
  def enhance_slide_component(slide, component, instruction=None):
20
  """Enhance a specific component of a slide using Claude API"""
 
52
 
53
  try:
54
  response = client.messages.create(
55
+ model="claude-3-7-sonnet-20250219",
56
  max_tokens=100,
57
  temperature=0.7,
58
  system="You are an expert presentation title specialist. Respond only with the revised title.",
 
96
 
97
  try:
98
  response = client.messages.create(
99
+ model="claude-3-7-sonnet-20250219",
100
  max_tokens=500,
101
  temperature=0.7,
102
  system="You are an expert presentation content specialist. Respond with a JSON array of bullet points.",
 
151
 
152
  try:
153
  response = client.messages.create(
154
+ model="claude-3-7-sonnet-20250219",
155
  max_tokens=300,
156
  temperature=0.7,
157
  system="You are an expert presentation visual designer. Respond with a JSON array of visual element recommendations.",
 
205
 
206
  try:
207
  response = client.messages.create(
208
+ model="claude-3-7-sonnet-20250219",
209
  max_tokens=500,
210
  temperature=0.7,
211
  system="You are an expert presentation coach. Provide comprehensive presenter notes.",
 
252
 
253
  try:
254
  response = client.messages.create(
255
+ model="claude-3-7-sonnet-20250219",
256
  max_tokens=400,
257
  temperature=0.7,
258
  system="You are an expert presentation structure specialist. Respond with a JSON object containing layout recommendations.",