stevenbucaille commited on
Commit
30b1518
·
1 Parent(s): 3f0e775

Update app and llm

Browse files
Files changed (2) hide show
  1. app.py +20 -1
  2. llm.py +16 -17
app.py CHANGED
@@ -123,6 +123,25 @@ with gr.Blocks() as demo:
123
  </div>
124
  """,
125
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  output_gallery = gr.Gallery(label="Images generated by the agent (do not put images)", type="pil", format="png")
127
  textbox = gr.MultimodalTextbox()
128
  gr.ChatInterface(
@@ -130,7 +149,7 @@ with gr.Blocks() as demo:
130
  type="messages",
131
  multimodal=True,
132
  textbox=textbox,
133
- additional_inputs=[output_gallery],
134
  additional_outputs=[output_gallery],
135
  )
136
 
 
123
  </div>
124
  """,
125
  )
126
+ gr.Markdown(
127
+ """
128
+ ## Update 17/06/2025
129
+ This Space was originally a Hackathon submission, funded with Anthropic Free Credits.<br>
130
+ Due to the high popularity of the Space, unfortunately I can't fund personally the credits anymore.<br>
131
+ I have added below the ability to add your own Anthropic API Key and select the model to use.<br>
132
+ """
133
+ )
134
+ anthropic_api_key = gr.Textbox(label="Anthropic API Key")
135
+ anthropic_model_id = gr.Dropdown(label="Anthropic Model", choices=ANTHROPIC_MODEL_IDS)
136
+ gr.Markdown(
137
+ """
138
+ ## Future plans
139
+ I plan to continue developing this Space on a more personal space here : https://huggingface.co/spaces/stevenbucaille/ScouterAI <br>
140
+ This Space will be powered with ZeroGPU and have more LLM options.<br>
141
+ Stay tuned!
142
+ <br>
143
+ """
144
+ )
145
  output_gallery = gr.Gallery(label="Images generated by the agent (do not put images)", type="pil", format="png")
146
  textbox = gr.MultimodalTextbox()
147
  gr.ChatInterface(
 
149
  type="messages",
150
  multimodal=True,
151
  textbox=textbox,
152
+ additional_inputs=[output_gallery, anthropic_api_key, anthropic_model_id],
153
  additional_outputs=[output_gallery],
154
  )
155
 
llm.py CHANGED
@@ -1,25 +1,24 @@
1
- import os
2
-
3
  from smolagents import LiteLLMModel
4
 
5
 
6
- LOCAL_LLM_SETTINGS = {
7
- "api_base": "http://127.0.0.1:1234/v1",
8
- "api_key": "api-key",
9
- "model_id": "gemma-3-12b-it-qat",
10
- }
11
-
12
- ANTHROPIC_API_KEY = os.getenv("ANTHROPIC_API_KEY")
13
-
14
- assert ANTHROPIC_API_KEY is not None, "ANTHROPIC_API_KEY is not set"
 
 
15
 
16
 
17
- def get_default_model():
 
 
18
  model = LiteLLMModel(
19
- # model_id="claude-3-7-sonnet-20250219",
20
- model_id="claude-3-5-haiku-latest",
21
- api_key=os.getenv("ANTHROPIC_API_KEY"),
22
- # reasoning_effort="low",
23
  )
24
- print("Loaded LLM model")
25
  return model
 
 
 
1
  from smolagents import LiteLLMModel
2
 
3
 
4
+ ANTHROPIC_MODEL_IDS = [
5
+ "claude-opus-4-20250514",
6
+ "claude-sonnet-4-20250514",
7
+ "claude-3-7-sonnet-latest",
8
+ "claude-3-5-haiku-latest",
9
+ "claude-3-5-sonnet-latest",
10
+ "claude-3-5-sonnet-20240620",
11
+ "claude-3-opus-latest",
12
+ "claude-3-sonnet-20240229",
13
+ "claude-3-haiku-20240307",
14
+ ]
15
 
16
 
17
+ def get_anthropic_model(model_id, anthropic_api_key):
18
+ if model_id not in ANTHROPIC_MODEL_IDS:
19
+ raise ValueError(f"Model {model_id} not found in Anthropic model IDs")
20
  model = LiteLLMModel(
21
+ model_id=model_id,
22
+ api_key=anthropic_api_key,
 
 
23
  )
 
24
  return model