Skip to content

Commit 2cb61a3

Browse files
committed
switch to azure and fix bug
1 parent 76097c0 commit 2cb61a3

File tree

2 files changed

+33
-32
lines changed

2 files changed

+33
-32
lines changed

app.py

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,9 @@ def build_api_call_function(model):
226226
from openai import AsyncAzureOpenAI
227227

228228
aclient = AsyncAzureOpenAI(
229+
api_key=AZURE_OPENAI_KEY,
229230
# https://learn.microsoft.com/azure/ai-services/openai/reference#rest-api-versioning
230-
api_version="2024-02-01",
231+
api_version="2025-04-01-preview",
231232
# https://learn.microsoft.com/azure/cognitive-services/openai/how-to/create-resource?pivots=web-portal#create-a-resource
232233
azure_endpoint=AZURE_OPENAI_ENDPOINT,
233234
)
@@ -836,30 +837,30 @@ def main():
836837
LOGGER.info(f"FORM {generation_config=}")
837838

838839
with st.expander("Info"):
840+
data_card = None # Initialize variable
839841
try:
840842
# Check if dataset_name exists in session state before accessing it
841843
if hasattr(st.session_state, 'dataset_name'):
842844
data_card = dataset_info(st.session_state.dataset_name, token=HF_TOKEN).cardData
843845
except (HFValidationError, RepositoryNotFoundError):
844846
pass
845-
else:
847+
848+
# Display dataset info if available
849+
if data_card:
846850
st.caption("Dataset")
847-
# Display the dataset card data in a cleaner format
848-
if data_card:
849-
try:
850-
# Try to convert to dict if it's not already
851-
if hasattr(data_card, '__dict__'):
852-
data_dict = data_card.__dict__
853-
else:
854-
data_dict = dict(data_card) if data_card else {}
855-
st.json(data_dict)
856-
except (TypeError, ValueError) as e:
857-
# Fallback to text representation if JSON serialization fails
858-
st.text(str(data_card))
859-
else:
860-
st.write("No dataset card data available")
851+
try:
852+
# Try to convert to dict if it's not already
853+
if hasattr(data_card, '__dict__'):
854+
data_dict = data_card.__dict__
855+
else:
856+
data_dict = dict(data_card) if data_card else {}
857+
st.json(data_dict)
858+
except (TypeError, ValueError) as e:
859+
# Fallback to text representation if JSON serialization fails
860+
st.text(str(data_card))
861861

862862
# Only try to get model info from HuggingFace for non-provider models
863+
model_card = None # Initialize variable
863864
if not any(model.startswith(known_provider) for known_provider in KNOWN_PROVIDERS):
864865
try:
865866
model_info_respose = model_info(model)
@@ -869,27 +870,27 @@ def main():
869870
)
870871
except (HFValidationError, RepositoryNotFoundError):
871872
pass
872-
else:
873+
874+
# Display model info if available
875+
if model_card:
873876
st.caption("Model")
874-
# Display the model card data in a cleaner format
875-
if model_card:
876-
try:
877-
# Try to convert to dict if it's not already
878-
if hasattr(model_card, '__dict__'):
879-
model_dict = model_card.__dict__
880-
else:
881-
model_dict = dict(model_card) if model_card else {}
882-
st.json(model_dict)
883-
except (TypeError, ValueError) as e:
884-
# Fallback to text representation if JSON serialization fails
885-
st.text(str(model_card))
886-
else:
887-
st.write("No model card data available")
877+
try:
878+
# Try to convert to dict if it's not already
879+
if hasattr(model_card, '__dict__'):
880+
model_dict = model_card.__dict__
881+
else:
882+
model_dict = dict(model_card) if model_card else {}
883+
st.json(model_dict)
884+
except (TypeError, ValueError) as e:
885+
# Fallback to text representation if JSON serialization fails
886+
st.text(str(model_card))
888887
else:
889888
# For provider models, we can't get info from HuggingFace
890889
# Set reasonable defaults for chat detection
891890
if model.startswith("openai/gpt") and "instruct" not in model:
892891
st.session_state["generation_config"]["is_chat"] = True
892+
elif model.startswith("azure/gpt") and "instruct" not in model:
893+
st.session_state["generation_config"]["is_chat"] = True
893894
elif model.startswith("together/") and any(chat_indicator in model for chat_indicator in ["chat", "instruct"]):
894895
st.session_state["generation_config"]["is_chat"] = True
895896
else:

launch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
export FM_MODEL="openai/gpt-4.1-nano-2025-04-14"
3+
export FM_MODEL="azure/gpt-4.1-nano"
44
export FM_HF_DATASET="shlomihod/civil-comments-wilds"
55
export FM_STOP_SEQUENCES=""
66
export FM_DATASET_SPLIT_SEED="1"

0 commit comments

Comments
 (0)