Qscar KIM commited on
Commit
274b107
·
1 Parent(s): 5667afd

update codes

Browse files
Files changed (2) hide show
  1. app.py +8 -11
  2. requirements.txt +1 -0
app.py CHANGED
@@ -4,7 +4,7 @@ import requests
4
  import inspect
5
  import pandas as pd
6
  import random
7
- from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool
8
 
9
  # --- Constants ---
10
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
@@ -13,10 +13,13 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
13
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
  class BasicAgent:
15
  def __init__(self):
16
- # model_id를 지정하지 않고 프레임워크 기본 빌트인 모델을 사용하며,
17
- # 안전하게 Secrets의 HF_TOKEN만 인스턴스에 직접 연동
18
- model = InferenceClientModel(
19
- token=os.getenv("HF_TOKEN")
 
 
 
20
  )
21
 
22
  search_tool = DuckDuckGoSearchTool()
@@ -179,10 +182,4 @@ with gr.Blocks() as demo:
179
  )
180
 
181
  if __name__ == "__main__":
182
- space_host_startup = os.getenv("SPACE_HOST")
183
- space_id_startup = os.getenv("SPACE_ID")
184
- if space_host_startup:
185
- print(f"✅ SPACE_HOST found: {space_host_startup}")
186
- if space_id_startup:
187
- print(f"✅ SPACE_ID found: {space_id_startup}")
188
  demo.launch(debug=True, share=False)
 
4
  import inspect
5
  import pandas as pd
6
  import random
7
+ from smolagents import CodeAgent, LiteLLMModel, DuckDuckGoSearchTool
8
 
9
  # --- Constants ---
10
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
 
13
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
14
  class BasicAgent:
15
  def __init__(self):
16
+ # Google AI Studio에서 발급받은 API 키를 환경 변수에서 로드
17
+ gemini_key = os.getenv("GEMINI_API_KEY") or os.getenv("GOOGLE_API_KEY")
18
+
19
+ # smolagents의 LiteLLM 커넥터를 사용하여 Google AI Studio의 고성능 무료 모델 바인딩
20
+ model = LiteLLMModel(
21
+ model_id="gemini/gemini-1.5-flash",
22
+ api_key=gemini_key
23
  )
24
 
25
  search_tool = DuckDuckGoSearchTool()
 
182
  )
183
 
184
  if __name__ == "__main__":
 
 
 
 
 
 
185
  demo.launch(debug=True, share=False)
requirements.txt CHANGED
@@ -1,5 +1,6 @@
1
  smolagents>=1.1.0
2
  duckduckgo-search>=6.2.1
 
3
  pandas
4
  requests
5
  gradio
 
1
  smolagents>=1.1.0
2
  duckduckgo-search>=6.2.1
3
+ litellm
4
  pandas
5
  requests
6
  gradio