Skip to content

Commit

Permalink
display azure subscription in status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Jun 11, 2024
1 parent fb7783d commit ff5566e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion demo/genaisrc/az-explain.genai.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
script({
model: "gpt-3.5-turbo",
model: "azure:gpt2networkverification",
temperature: 0,
files: "web-app-basic-linux/main.bicep",
system: [
Expand Down
5 changes: 5 additions & 0 deletions demo/genaisrc/poem.genai.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
script({
model: "azure:gpt2networkverification",
})

$`Write a short poem.`
3 changes: 2 additions & 1 deletion packages/core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export const CHANGE = "change"
export const MAX_CACHED_TEMPERATURE = 0.5
export const MAX_CACHED_TOP_P = 0.5
export const MAX_TOOL_CALLS = 100
//https://learn.microsoft.com/en-us/azure/ai-services/openai/reference
// https://learn.microsoft.com/en-us/azure/ai-services/openai/reference
// https://github.com/Azure/azure-rest-api-specs/blob/main/specification/cognitiveservices/data-plane/AzureOpenAI/inference/stable/2024-02-01/inference.yaml
export const AZURE_OPENAI_API_VERSION = "2024-02-01"
export const AZURE_OPENAI_TOKEN_SCOPES = Object.freeze([
"https://cognitiveservices.azure.com/.default",
Expand Down
4 changes: 4 additions & 0 deletions packages/vscode/src/azuremanager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export class AzureManager {
return this._subscription
}

get hasToken() {
return this._token?.token !== undefined
}

async signIn(): Promise<TokenCredential> {
if (this._subscription) return this._subscription.credential

Expand Down
10 changes: 7 additions & 3 deletions packages/vscode/src/statusbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ export function activateStatusBar(state: ExtensionState) {
)
statusBarItem.command = "genaiscript.request.status"
const updateStatusBar = async () => {
const { parsing } = state
const { computing, progress, options, editsApplied } =
state.aiRequest || {}
const { parsing, host } = state
const { azure } = host
const { subscription } = azure
const { computing, progress, options } = state.aiRequest || {}
const { template, fragment } = options || {}
const { tokensSoFar } = progress || {}
statusBarItem.text = toStringList(
Expand All @@ -33,6 +34,9 @@ export function activateStatusBar(state: ExtensionState) {
: undefined,
template
? `- tool: ${template.title} (${template.id})`
: undefined,
subscription
? `- Azure subscription: ${subscription.name} (${subscription.subscriptionId})`
: undefined
),
true
Expand Down

0 comments on commit ff5566e

Please sign in to comment.