Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions docs/workshop/docs/workshop/Challenge-5/python/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def schema_to_tool(schema: Any):
return json.loads(
assistant_message.tool_calls[0].function.arguments, strict=False
)
except:
except Exception:
return assistant_message.tool_calls[0].function.arguments

def get_structured_output_answer(
Expand Down Expand Up @@ -348,7 +348,6 @@ def generate_scenes(
scene_generation_prompt = Template(SCENE_GENERATION_PROMPT).substitute(
descriptions=next_segment_content
)
scence_response = VideoSceneResponse(scenes=[])
scence_response = openai_assistant.get_structured_output_answer(
"", scene_generation_prompt, VideoSceneResponse
)
Expand Down Expand Up @@ -433,7 +432,6 @@ def generate_chapters(
chapter_generation_prompt = Template(CHAPTER_GENERATION_PROMPT).substitute(
descriptions=scene_descriptions
)
chapter_response = VideoChapterResponse(chapters=[])
chapter_response = openai_assistant.get_structured_output_answer(
"", chapter_generation_prompt, VideoChapterResponse
)
Expand All @@ -460,7 +458,6 @@ def aggregate_tags(
tags_dedup = set(map(lambda x: re.sub(r'^ ', '', x), tags))
tag_dedup_prompt = Template(DEDUP_PROMPT).substitute(tag_list=tags_dedup)

tag_response = VideoTagResponse(tags=[])
tag_response = openai_assistant.get_structured_output_answer(
"", tag_dedup_prompt, VideoTagResponse
)
Expand Down
19 changes: 8 additions & 11 deletions infra/scripts/fabric_scripts/create_fabric_items.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from azure.identity import ManagedIdentityCredential
import base64
import json
import requests
import pandas as pd
import os
from glob import iglob
import zipfile
Expand Down Expand Up @@ -98,11 +96,11 @@
# upload extracted folder
file_names = [f for f in iglob(os.path.join(local_path, "**", "*"), recursive=True) if os.path.isfile(f)]
# print('file_names ex', file_names)
for file_name in file_names:
upload_file_name = os.path.basename(file_name)
for extracted_file in file_names:
upload_file_name = os.path.basename(extracted_file)
file_client = directory_client.get_file_client("cu_audio_files_all/" + upload_file_name)
# with open(file=os.path.join(extract_dir, file_name), mode="rb") as data:
with open(file=file_name, mode="rb") as data:
# with open(file=os.path.join(extract_dir, extracted_file), mode="rb") as data:
with open(file=extracted_file, mode="rb") as data:
# print('data', data)
file_client.upload_data(data, overwrite=True)

Expand All @@ -127,7 +125,7 @@
env_res = requests.get(fabric_env_url, headers=fabric_headers)
env_res_id = env_res.json()['value'][0]['id']
# print(env_res.json())
except:
except Exception: # Environments may not be provisioned yet
env_res_id = ''

#create notebook items
Expand All @@ -150,14 +148,14 @@
notebook_json['metadata']['dependencies']['lakehouse']['default_lakehouse'] = lakehouse_res.json()['id']
notebook_json['metadata']['dependencies']['lakehouse']['default_lakehouse_name'] = lakehouse_res.json()['displayName']
notebook_json['metadata']['dependencies']['lakehouse']['default_lakehouse_workspace_id'] = lakehouse_res.json()['workspaceId']
except:
except Exception: # Lakehouse metadata may not be available
pass

if env_res_id != '':
try:
notebook_json['metadata']['dependencies']['environment']['environmentId'] = env_res_id
notebook_json['metadata']['dependencies']['environment']['workspaceId'] = lakehouse_res.json()['workspaceId']
except:
except Exception: # Environment metadata may not be available
pass


Expand All @@ -178,8 +176,7 @@
}
}

fabric_response = requests.post(fabric_items_url, headers=fabric_headers, json=notebook_data)
#print(fabric_response.json())
requests.post(fabric_items_url, headers=fabric_headers, json=notebook_data)

time.sleep(120)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
analyzer = client.get_analyzer_detail_by_id(ANALYZER_ID)
if analyzer is not None:
client.delete_analyzer(ANALYZER_ID)
except Exception:
except Exception: # Analyzer may not exist yet, safe to ignore
pass

response = client.begin_create_analyzer(ANALYZER_ID, analyzer_template_path=ANALYZER_TEMPLATE_FILE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
analyzer = client.get_analyzer_detail_by_id(ANALYZER_ID)
if analyzer is not None:
client.delete_analyzer(ANALYZER_ID)
except Exception:
except Exception: # Analyzer may not exist yet, safe to ignore
pass

response = client.begin_create_analyzer(ANALYZER_ID, analyzer_template_path=ANALYZER_TEMPLATE_FILE)
Expand Down
5 changes: 2 additions & 3 deletions infra/scripts/index_scripts/03_cu_process_data_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,10 @@ async def process_files():

docs.extend(await prepare_search_doc(content, conversation_id, path.name, embeddings_client))
counter += 1
except Exception:
except Exception: # Skip files that fail processing
pass
if docs != [] and counter % 10 == 0:
result = search_client.upload_documents(documents=docs)
search_client.upload_documents(documents=docs)
docs = []
if docs:
search_client.upload_documents(documents=docs)
Expand Down Expand Up @@ -533,7 +533,6 @@ async def call_topic_mining_agent(topics_str1):
column_names = [i[0] for i in cursor.description]
df_topics = pd.DataFrame(rows, columns=column_names)
mined_topics_list = df_topics['label'].tolist()
mined_topics = ", ".join(mined_topics_list)
print(f"✓ Mined {len(mined_topics_list)} topics")

async def call_topic_mapping_agent(agent, input_text, list_of_topics):
Expand Down
14 changes: 5 additions & 9 deletions infra/scripts/index_scripts/04_cu_process_custom_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def create_search_index():
connection_string = f"DRIVER={driver};SERVER={SQL_SERVER};DATABASE={SQL_DATABASE};"
conn = pyodbc.connect(connection_string, attrs_before={SQL_COPT_SS_ACCESS_TOKEN: token_struct})
cursor = conn.cursor()
except:
except Exception: # Fall back to ODBC Driver 17
driver = "{ODBC Driver 17 for SQL Server}"
token_bytes = credential.get_token("https://database.windows.net/.default").token.encode("utf-16-LE")
token_struct = struct.pack(f"<I{len(token_bytes)}s", len(token_bytes), token_bytes)
Expand Down Expand Up @@ -435,10 +435,10 @@ async def process_files():

docs.extend(await prepare_search_doc(content, conversation_id, path.name, embeddings_client))
counter += 1
except Exception:
except Exception: # Skip files that fail processing
pass
if docs != [] and counter % 10 == 0:
result = search_client.upload_documents(documents=docs)
search_client.upload_documents(documents=docs)
docs = []
if docs:
search_client.upload_documents(documents=docs)
Expand Down Expand Up @@ -469,7 +469,6 @@ async def process_files():
conversation_id = file_name.split('convo_', 1)[1].split('_')[0]
conversationIds.append(conversation_id)

duration = int(result['result']['contents'][0]['fields']['Duration']['valueString'])
fields = result['result']['contents'][0]['fields']
duration_str = get_field_value(fields, 'Duration', '0')
try:
Expand Down Expand Up @@ -507,9 +506,9 @@ async def process_files():
docs.extend(await prepare_search_doc(content, document_id, path.name, embeddings_client))
counter += 1
except Exception:
pass
pass # Skip files that fail to process
if docs != [] and counter % 10 == 0:
result = search_client.upload_documents(documents=docs)
search_client.upload_documents(documents=docs)
docs = []

# upload the last batch
Expand Down Expand Up @@ -620,8 +619,6 @@ async def call_topic_mining_agent(topics_str1):
res = res.replace("```json", '').replace("```", '').strip()
return json.loads(res)

MAX_TOKENS = 3096

res = asyncio.run(call_topic_mining_agent(topics_str))
for object1 in res['topics']:
cursor.execute("INSERT INTO km_mined_topics (label, description) VALUES (?,?)", (object1['label'], object1['description']))
Expand All @@ -632,7 +629,6 @@ async def call_topic_mining_agent(topics_str1):
column_names = [i[0] for i in cursor.description]
df_topics = pd.DataFrame(rows, columns=column_names)
mined_topics_list = df_topics['label'].tolist()
mined_topics = ", ".join(mined_topics_list)
print(f"✓ Mined {len(mined_topics_list)} topics")

async def call_topic_mapping_agent(agent, input_text, list_of_topics):
Expand Down
2 changes: 1 addition & 1 deletion infra/scripts/validate_bicep_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def parse_parameters_env_vars(json_path: Path) -> dict[str, list[str]]:
try:
data = json.loads(sanitized)
params = data.get("parameters", {})
except json.JSONDecodeError:
except json.JSONDecodeError: # Parameters file may have azd variable placeholders
pass

# Walk each top-level parameter and scan its entire serialized value
Expand Down
2 changes: 1 addition & 1 deletion src/App/src/components/ChartFilter/ChartFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const ChartFilter: React.FC<FilterComponentProps> = (props) => {
(state) => state.dashboards
);
const { applyFilters, fetchingCharts } = props;
const initialDateRange = typeof Array.isArray(selectedFilters.DateRange)
const initialDateRange = Array.isArray(selectedFilters.DateRange)
? selectedFilters.DateRange
: [""];

Expand Down
2 changes: 1 addition & 1 deletion src/api/common/database/cosmosdb_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async def delete_messages(self, conversation_id, user_id):
item=message["id"], partition_key=user_id
)
response_list.append(resp)
return response_list
return response_list

async def get_conversations(self, user_id, limit, sort_order="DESC", offset=0):
parameters = [{"name": "@userId", "value": user_id}]
Expand Down
3 changes: 2 additions & 1 deletion src/api/common/database/sqldb_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ async def get_db_connection():

if conn is None:
raise RuntimeError("Unable to connect using ODBC Driver 18 or 17 with Azure Credential")
return conn
except Exception as e:
logging.error("Failed with Azure Credential: %s", str(e))
raise RuntimeError("Unable to connect to SQL database using Microsoft Entra authentication.") from e
Expand Down Expand Up @@ -179,7 +180,7 @@ async def fetch_chart_data(chart_filters: ChartFilters = ''):
req_body = ''
try:
req_body = chart_filters.model_dump()
except BaseException:
except Exception: # model_dump may fail if filters are empty or invalid
pass
if req_body != '':
where_clause = ''
Expand Down
2 changes: 1 addition & 1 deletion src/api/services/chat_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def replace_citation_marker(match):
if db_conn is not None:
try:
db_conn.close()
except Exception:
except Exception: # Best-effort connection cleanup
pass

# Only emit fallback and tool citations if no error occurred
Expand Down
Loading
Loading