Skip to content
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

Enable AzureOpenAI model testing #514

Merged

Conversation

riedgar-ms
Copy link
Collaborator

@riedgar-ms riedgar-ms commented Dec 7, 2023

Working to enable AzureOpenAI model testing. This:

  • Fixes models/_azure_openai.py after recent adjustments left it in a non-working state
  • Shows how to use GitHub secrets in Actions
  • Adds a CI build to run the test with the secrets

@riedgar-ms riedgar-ms marked this pull request as draft December 7, 2023 18:13
@@ -27,6 +28,13 @@ jobs:
pip install -e .[test]
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
env: # Configure endpoints
AZUREAI_CHAT_ENDPOINT: ${{ secrets.AZUREAI_CHAT_ENDPOINT }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These work in my fork, but of course would have to be updated in the guidance-ai/guidance repo.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I've just discovered that the environment variable will exist even if the secret doesn't. So my _env_or_skip() method doesn't quite work :-/

@riedgar-ms
Copy link
Collaborator Author

Tag @Harsha-Nori etc.

@riedgar-ms riedgar-ms marked this pull request as ready for review February 21, 2024 16:22
@riedgar-ms riedgar-ms changed the title Sample secrets in GitHub Actions Enable AzureAI model testing Feb 21, 2024
@riedgar-ms riedgar-ms changed the title Enable AzureAI model testing Enable AzureOpenAI model testing Feb 21, 2024
@riedgar-ms
Copy link
Collaborator Author

The best way of handling the secrets in the build is not completely clear to me. If we're accepting PRs, then the PR could run and leak the secrets; hence a CI build

@riedgar-ms
Copy link
Collaborator Author

In order for the tests to work, the six environment variables will need to be set as GitHub secrets. I do not have permissions to do this.

@Harsha-Nori
Copy link
Collaborator

I added the secrets into the env, but it looks like they don't get passed on a fork/PR. Since these are just extra tests, merging in for now so we can see if the secret-passing works properly.

def __init__(
self,
model: str,
azure_endpoint: str,
azure_deployment: str,
azure_deployment: str = None,
azure_ad_token_provider=None,
api_key: str = None,
tokenizer=None,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@riedgar-ms I assume there's no way to do auto-tokenizer detection logic on Azure OpenAI models?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will - it ultimately uses the model string, just like with the OpenAI class. Users to have to set this for themselves, though, since it's not part of the URI which AzureAI provides.

@@ -77,55 +66,61 @@ def __init__(
azure_deployment=azure_deployment,
tokenizer=tokenizer,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to above, I imagine we may need to make initializing and passing a tokenizer a required arg if we can't autodetect? seems like the default behavior is to pass through None here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Users should be able to pass through a particular tokeniser if they want, but otherwise, this should just use the same model argument as the OpenAI implementation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's just that the AzureOpenAI model deployments can be named anything, which would likely break the tiktoken detection logic we use in the OpenAI base classes. But that's OK - this is as good as our current behavior, so we can deal with cleaning it up later. It may be worth investigating if there is some way in Azure APIs to detect what the underlying model powering any deployment is (so that we get a tiktoken friendly string).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not if the user has passed in the model argument set to the name of the model used by the deployment. We can certainly investigate if there's a way of getting that info, short of querying the Azure API (to which the user might not have access)

@Harsha-Nori Harsha-Nori merged commit 0f67fbb into guidance-ai:main Feb 26, 2024
5 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants