-
Notifications
You must be signed in to change notification settings - Fork 314
fixes issue with error printing and credentials handling #177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,3 +18,4 @@ node_modules/ | |
| # React build output | ||
| src/api/static/react/ | ||
| .vscode/launch.json | ||
| .DS_Store | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| "scripts": { | ||
| "dev": "vite", | ||
| "build": "tsc && vite build", | ||
| "setup": "npm install -g [email protected] && pnpm install && pnpm build", | ||
| "setup": "pnpm install && pnpm build", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This have been resolved in the latest code. |
||
| "preview": "vite preview", | ||
| "typecheck": "tsc --noEmit" | ||
| }, | ||
|
|
@@ -27,6 +27,7 @@ | |
| "@vitejs/plugin-react": "4.4.1", | ||
| "clsx": "2.1.1", | ||
| "copy-to-clipboard": "^3.3.3", | ||
| "prismjs": "1.30.0", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This have been resolved in the latest code. |
||
| "react": "19.1.0", | ||
| "react-dom": "19.1.0", | ||
| "react-markdown": "10.1.0", | ||
|
|
@@ -40,8 +41,8 @@ | |
| "remark-math": "^6.0.0", | ||
| "remark-parse": "^11.0.0", | ||
| "remark-supersub": "^1.0.0", | ||
| "vite": "6.3.4", | ||
| "prismjs": "1.30.0" | ||
| "setup": "^0.0.3", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should have been resolved in the latest code. |
||
| "vite": "6.3.4" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/node": "22.14.1", | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,6 +23,7 @@ | |
| from azure.ai.projects.models import ConnectionType, ApiKeyCredentials | ||
| from azure.identity.aio import DefaultAzureCredential | ||
| from azure.core.credentials_async import AsyncTokenCredential | ||
| from azure.core.credentials import AzureKeyCredential | ||
|
|
||
| from dotenv import load_dotenv | ||
|
|
||
|
|
@@ -66,22 +67,24 @@ async def create_index_maybe( | |
| """ | ||
| from api.search_index_manager import SearchIndexManager | ||
| endpoint = os.environ.get('AZURE_AI_SEARCH_ENDPOINT') | ||
| embedding = os.getenv('AZURE_AI_EMBED_DEPLOYMENT_NAME') | ||
| if endpoint and embedding: | ||
| embedding = os.getenv('AZURE_AI_EMBED_DEPLOYMENT_NAME') | ||
| search_api_key = os.getenv('AZURE_AI_SEARCH_API_KEY') # <-- Add this line | ||
|
|
||
| if endpoint and embedding and search_api_key: | ||
| try: | ||
| aoai_connection = await ai_client.connections.get_default( | ||
| connection_type=ConnectionType.AZURE_OPEN_AI, include_credentials=True) | ||
| except ValueError as e: | ||
| logger.error("Error creating index: {e}") | ||
| logger.error(f"Error creating index: {e}") | ||
| return | ||
|
|
||
| embed_api_key = None | ||
| if aoai_connection.credentials and isinstance(aoai_connection.credentials, ApiKeyCredentials): | ||
| embed_api_key = aoai_connection.credentials.api_key | ||
|
|
||
| search_mgr = SearchIndexManager( | ||
| endpoint=endpoint, | ||
| credential=creds, | ||
| credential=AzureKeyCredential(search_api_key), # <-- Use API key here | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't store api key as env var for security unless the key is set. The latest code is using AAD. So this isn't necessary. |
||
| index_name=os.getenv('AZURE_AI_SEARCH_INDEX_NAME'), | ||
| dimensions=None, | ||
| model=embedding, | ||
|
|
@@ -253,4 +256,8 @@ def on_starting(server): | |
| if __name__ == "__main__": | ||
| print("Running initialize_resources directly...") | ||
| asyncio.run(initialize_resources()) | ||
| print("initialize_resources finished.") | ||
| print("initialize_resources finished.") | ||
|
|
||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I ask why?