Skip to main content

Notifications

Copilot Studio - Topic Creation & Management
Unanswered

Sending an HTTP request to OPEN AI API in Copilot Studio Virtual Agents

(0) ShareShare
ReportReport
Posted on by 10

Is there an example of how to setup this http call properly? The documentation I find is not relative to the newer versions of PVA. Also, Automate "complete text..." does not work as it points to 3.5.

 

I'm sending a string to Chatgpt 4.0 that I have and expect a return answer. It passes authentication then fails. See comps.

  • adilei Profile Picture
    adilei on at
    Re: Sending an HTTP request to OPEN AI API in Copilot Studio Virtual Agents

    Can use assign the payload to a variable before invoking an HTTP request and validate it was populated correctly?

  • Freddie_B Profile Picture
    Freddie_B 60 on at
    Re: Sending an HTTP request to OPEN AI API in Copilot Studio Virtual Agents

    Does anyone can help me with this? Or has any idea why this is hapenning? I have a similiar problem

     

    Your help will be much appreciated 😊

     

    I'm attempting to send an HTTP request to OpenAI's service. It seems to function correctly overall. However, when I dynamically assign the content of the user field in the JSON payload to a variable where the question is stored, the response indicates that the information isn't found in the retrieved data. Strangely, if I manually input the same question into the content field, I receive the correct response.

    @HenryJammes , would you happen to have any clue why this is hapenning?

     

    Thanks everyone

     

    This is the code:

     

     

     

     

     

     

     

    kind: AdaptiveDialog
    beginDialog:
     kind: OnUnknownIntent
     id: main
     priority: -1
     actions:
     - kind: SetVariable
     id: setVariable_J8onVi
     variable: Topic.UserQuestion
     value: =System.Activity.Text
    
     - kind: HttpRequestAction
     id: vdrcdy
     method: Post
     url: https://ai-XXXXXXXXXXXXXXXXX.openai.azure.com/openai/deployments/gpt-35-turbo-16k/extensions/chat/completions?api-version=2023-06-01-preview
     headers:
     api-key: XXXXX-XXX-XXXXX-XXXXX-XXXX
    
     body:
     kind: JsonRequestContent
     content:
     kind: ValueExpression
     literalValue:
     dataSources:
     - parameters:
     endpoint: https://xxxx-xx-xxx-xx.search.windows.net
     fieldsMapping:
     contentFields:
     - Value: content
    
     contentFieldsSeparator: |
     
     filepathField: metadata_spo_item_name
     titleField: Name
     urlField:
     vectorFields:
    
     filter:
     indexName: sharepoint-index
     inScope: true
     key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     queryType: simple
     roleInformation: You are an AI assistant and you are part of our organization. You need to be polite when you give the answers. The information you will be giving is from an internal SharePoint.
     semanticConfiguration: default
     strictness: 3
     topNDocuments: 5
    
     type: AzureCognitiveSearch
    
     deployment: gpt-35-turbo-16k
     max_tokens: 800
     messages:
     - content: You are an AI assistant and you are part of our organization. You need to be polite when you give the answers. The information you will be giving is from an internal SharePoint.
     role: system
    
     - content: ${Topic.UserQuestion}
     role: user
    
     stop:
     stream: false
     temperature: 0
     top_p: 1
    
     response: Topic.Response
     responseSchema:
     kind: Record
     properties:
     choices:
     type:
     kind: Table
     properties:
     index: Number
     messages:
     type:
     kind: Table
     properties:
     content: String
     end_turn: Boolean
     index: Number
     role: String
    
     created: Number
     id: String
     model: String
     object: String
     usage:
     type:
     kind: Record
     properties:
     completion_tokens: Number
     prompt_tokens: Number
     total_tokens: Number
    
     - kind: SendActivity
     id: sendActivity_CUSi4i
     activity: "{Last(Last(Topic.Response.choices).messages).content}"
    
     - kind: EndDialog
     id: a1Vse4

     

     

     

     

     

     

     

     



           

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,508

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,839

Leaderboard

Featured topics