IngoTB303 commited on
Commit
13ef4e0
·
1 Parent(s): 9e58d03

Refactor app.py: streamline imports, replace app_tokens with environment variables for model configuration

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -1,14 +1,12 @@
1
  import os
2
  import gradio as gr
3
  import requests
4
- import inspect
5
  import pandas as pd
6
- from smolagents import CodeAgent, HfApiModel, FinalAnswerTool, DuckDuckGoSearchTool, AzureOpenAIServerModel
7
  from huggingface_hub import login
 
8
 
9
- import app_tokens
10
-
11
- login(os.getenv('HF_API_KEY'))
12
 
13
  # Since I use a private endpoint behind a VPN, I coded app-test.py to fulfill the tasks, gather the answers and submit them
14
  # without Gradio to the server.
@@ -18,10 +16,10 @@ login(os.getenv('HF_API_KEY'))
18
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
19
 
20
  model = AzureOpenAIServerModel(
21
- model_id = app_tokens.AZURE_OPENAI_MODEL,
22
- azure_endpoint = app_tokens.AZURE_OPENAI_ENDPOINT,
23
- api_key = app_tokens.AZURE_OPENAI_API_KEY,
24
- api_version = app_tokens.OPENAI_API_VERSION
25
  )
26
 
27
  def run_and_submit_all( profile: gr.OAuthProfile | None):
 
1
  import os
2
  import gradio as gr
3
  import requests
 
4
  import pandas as pd
5
+ from smolagents import AzureOpenAIServerModel
6
  from huggingface_hub import login
7
+ from dotenv import load_dotenv
8
 
9
+ load_dotenv() # take environment variables
 
 
10
 
11
  # Since I use a private endpoint behind a VPN, I coded app-test.py to fulfill the tasks, gather the answers and submit them
12
  # without Gradio to the server.
 
16
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
17
 
18
  model = AzureOpenAIServerModel(
19
+ model_id = os.getenv("AZURE_OPENAI_MODEL"),
20
+ azure_endpoint = os.getenv("AZURE_OPENAI_ENDPOINT"),
21
+ api_key = os.getenv("AZURE_OPENAI_API_KEY"),
22
+ api_version = os.getenv("app_tokens.OPENAI_API_VERSION")
23
  )
24
 
25
  def run_and_submit_all( profile: gr.OAuthProfile | None):