Urgent please: Custom Avatar Sample Code: How to set temperature?

It is VMS 170 Reputation points
2025-08-26T17:48:43.0233333+00:00

Hi folks

Have a look at https://github.com/Azure-Samples/cognitive-services-speech-sdk/tree/master/samples/js/browser/avatar

There's a place where we can call the OpenAI endpoint with a prompt. We'd like to also send a temperature for this. Where do we set it? can't see it neither in the javascript source files

User's image

Any ideas will be very much appreciated!

Thanks!

@Manas Mohanty : you are one hell of a resourceful guy who has helped us in the past, on this topic... please see if you can look at this.

Azure AI Speech
Azure AI Speech
An Azure service that integrates speech processing into apps and services.
{count} votes

1 answer

Sort by: Most helpful
  1. Manas Mohanty 9,655 Reputation points Microsoft External Staff Moderator
    2025-08-27T01:25:40.0333333+00:00

    Hi It is VMS

    Yes, Agreed with Shivaprasad's inputs

    Found the code snippet in chat.js

       body = JSON.stringify({
                dataSources: dataSources,
                messages: messages,
                stream: true
            })
        }
    
    
    

    Can be replaced with

    let body = JSON.stringify({
        messages: messages,
        stream: true,
        temperature: 0.7 // or any value between 0 and 2
    })
    
    let url = "{AOAIEndpoint}/openai/deployments/{AOAIDeployment}/chat/completions?api-version=2023-06-01-preview".replace("{AOAIEndpoint}", azureOpenAIEndpoint).replace("{AOAIDeployment}", azureOpenAIDeploymentName)
        let body = JSON.stringify({
            messages: messages,
            stream: true
        })
    
        if (dataSources.length > 0) {
            url = "{AOAIEndpoint}/openai/deployments/{AOAIDeployment}/extensions/chat/completions?api-version=2023-06-01-preview".replace("{AOAIEndpoint}", azureOpenAIEndpoint).replace("{AOAIDeployment}", azureOpenAIDeploymentName)
            body = JSON.stringify({
                dataSources: dataSources,
                messages: messages,
                stream: true
            })
        }
    
        let assistantReply = ''
        let toolContent = ''
        let spokenSentence = ''
        let displaySentence = ''
    
        fetch(url, {
            method: 'POST',
            headers: {
                'api-key': azureOpenAIApiKey,
                'Content-Type': 'application/json'
            },
            body: body
        })
    
    
    

    Hope it helps.

    Thank you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.