CindyDelage commited on
Commit
eace5b7
·
verified ·
1 Parent(s): fbaa899

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -6
app.py CHANGED
@@ -11,8 +11,11 @@ from PIL import Image
11
  from tools import evaluate_consumption, evaluate_consumption_example
12
  from retriever import FrugalAI_methods
13
 
14
- HF_TOKEN = os.environ.get("HF_TOKEN")
15
- API_KEY = os.environ.get("API_KEY")
 
 
 
16
  # Initialize the Hugging Face model
17
  model = LiteLLMModel(
18
  model_id="anthropic/claude-3-5-sonnet-latest",
@@ -20,9 +23,9 @@ model = LiteLLMModel(
20
  api_key=os.environ["API_KEY"]
21
  )
22
  #model = InferenceClientModel("deepseek-ai/DeepSeek-R1",max_tokens=500, token=HF_TOKEN)
23
- headers = {
24
- "Authorization": f"Bearer {HF_TOKEN}"
25
- }
26
 
27
  # Initialize the weather tool
28
  evaluate_consumption = evaluate_consumption()
@@ -58,7 +61,20 @@ with gr.Blocks(theme=gr.themes.Ocean()) as demo:
58
  inputs="text",
59
  outputs="text",
60
  title="Frugalize it!",
61
- examples=["What are you capable of? Show me using your custom tool evaluate_consumption_example, and provide examples based on the code in that tool to optimize it for frugality. Use both your tools and web searches if needed., "Here is my code, {code}, please give me frugal alternatives"],
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  description="Share your Python code with this AI agent! It will track its CO2 emissions using CodeCarbon and recommend greener, frugal AI alternatives."
63
  )
64
 
 
11
  from tools import evaluate_consumption, evaluate_consumption_example
12
  from retriever import FrugalAI_methods
13
 
14
+ #HF_TOKEN = os.environ.get("HF_TOKEN")
15
+ try:
16
+ API_KEY = os.environ.get("API_KEY")
17
+ except:
18
+ print("Please provide the Antrhopic API_KEY in the secret variables")
19
  # Initialize the Hugging Face model
20
  model = LiteLLMModel(
21
  model_id="anthropic/claude-3-5-sonnet-latest",
 
23
  api_key=os.environ["API_KEY"]
24
  )
25
  #model = InferenceClientModel("deepseek-ai/DeepSeek-R1",max_tokens=500, token=HF_TOKEN)
26
+ #headers = {
27
+ # "Authorization": f"Bearer {HF_TOKEN}"
28
+ #}
29
 
30
  # Initialize the weather tool
31
  evaluate_consumption = evaluate_consumption()
 
61
  inputs="text",
62
  outputs="text",
63
  title="Frugalize it!",
64
+ examples=[""\nYou are an AI agent that receives Python code from a manager. "
65
+ "Your task is to test its resource consumption using a custom tool. "
66
+ "Then, propose frugal alternatives, such as pruning, using your dedicated tool — always use it. "
67
+ "Additionally, feel free to search the internet for frugal methods and present them to the manager. "
68
+ "Examples include Knowledge Distillation, Transfer Learning, and others. "
69
+ "Show me what you can do using your custom tool evaluate_consumption_example, and provide examples based on the code in that tool to optimize it for frugality. "
70
+ "Use both your tools and web searches if needed.",
71
+
72
+ "\nYou are an AI agent that receives Python code from a manager. "
73
+ "Your task is to test its resource consumption using a custom tool. "
74
+ "Then, propose frugal alternatives, such as pruning, using your dedicated tool — always use it. "
75
+ "Additionally, feel free to search the internet for frugal methods and present them to the manager. "
76
+ "Examples include Knowledge Distillation, Transfer Learning, and others. "
77
+ "Here is my code, {code}, please give me frugal alternatives"],
78
  description="Share your Python code with this AI agent! It will track its CO2 emissions using CodeCarbon and recommend greener, frugal AI alternatives."
79
  )
80