How to return references with Javascript Azure Openai Client Library

Orellana, Felipe 0 Reputation points
2024-01-24T15:08:12.4133333+00:00

Hello, im currently using the Javascript Azure Openai Client Library with my own data. How can i return the references of the answers at the end of these, just like Azure Openai Studio does? Im getting the answers like this:

const replyText = result.choices[0].message.content;

When for example i try to get the references from messages[0].content.citations im getting just a very long string with no references of the files in it. Any way to do this? Thank you.

Microsoft 365 and Office Development Office JavaScript API
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,080 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Saurabh Sharma 23,846 Reputation points Microsoft Employee Moderator
    2024-01-24T21:59:13.1366667+00:00

    Hi @Orellana, Felipe
    Welcome to Microsoft Q&A! Thanks for posting the question.

    Have tried using - (await result).choices[0].message.context.messages[0].content?

    You can also try using field mappings with extensions to see if your fields are coming through?

     "fieldsMapping": {
    58      "contentFieldsSeparator": "\n",
    59      "contentFields": [
    60        "content"
    61      ],
    62      "filepathField": "filepath",
    63      "titleField": "doc_title",
    64      "urlField": "doc_url",
    65      "vectorFields": []
    66    },
    

    Reference: document Thanks Saurabh

    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.