Naoufal CHABAA commited on
Commit
0199a4f
·
1 Parent(s): 4c19836

Add .env.example for Azure API configuration and update app.py to load environment variables

Browse files
Files changed (2) hide show
  1. .env.example +3 -0
  2. app.py +7 -3
.env.example ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ AZURE_ENDPOINT="https://models.github.ai/inference"
2
+ AZURE_MODEL_NAME="meta/Meta-Llama-3.1-8B-Instruct" # Model must be instruct tuned
3
+ AZURE_TOKEN="" # Your Azure token HERE
app.py CHANGED
@@ -10,6 +10,8 @@ from azure.ai.inference.models import SystemMessage, UserMessage
10
  from azure.core.credentials import AzureKeyCredential
11
 
12
  from Gradio_UI import GradioUI
 
 
13
 
14
  # Simple response object to match smolagents expectations
15
  class ChatMessage:
@@ -93,9 +95,11 @@ class AzureModel:
93
  return ChatMessage(f"Error calling Azure API: {str(e)}")
94
 
95
  # Azure API configuration
96
- endpoint = "https://models.github.ai/inference"
97
- model_name = "meta/Meta-Llama-3.1-8B-Instruct"
98
- token = "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"
 
 
99
 
100
  @tool
101
  def summarize_webpage(url: str) -> str:
 
10
  from azure.core.credentials import AzureKeyCredential
11
 
12
  from Gradio_UI import GradioUI
13
+ from dotenv import load_dotenv
14
+ import os
15
 
16
  # Simple response object to match smolagents expectations
17
  class ChatMessage:
 
95
  return ChatMessage(f"Error calling Azure API: {str(e)}")
96
 
97
  # Azure API configuration
98
+ load_dotenv() # Loads from .env by default
99
+
100
+ endpoint = os.getenv("AZURE_ENDPOINT")
101
+ model_name = os.getenv("AZURE_MODEL_NAME")
102
+ token = os.getenv("AZURE_TOKEN")
103
 
104
  @tool
105
  def summarize_webpage(url: str) -> str: