Unable to add data source to chat client with C# 7.3

Alex Kienzle 5 Reputation points
2024-06-21T14:21:38.3366667+00:00

I am working on a UWP application that interacts with Azure OpenAI chat client. I have been using the latest Nuget package (2.0.0-beta.2) and have had some success creating and using a chat client. I am now trying to add a data source to my chat client, but it seems that there is no way to create a data source with the C# language version I am currently using. I have been using this sample as a guide:
https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/openai/Azure.AI.OpenAI/tests/Samples/02_Oyd.cs

C# 7.3 does not support init-only setters, which seem to be a requirement to create one of the AzureChatDataSource objects. Since I cannot upgrade my UWP project to version 9.0 and I cannot find a workaround, I seem to be stuck. Other features of this library seem to otherwise be supported, so I suspect this may have been an oversight.

The attached image shows the issue I am having.

User's image

Syntactically, there doesn't seem to be any other way to create a data source. Is there something I am missing? Please advise. Thanks!

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,658 questions
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
2,659 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. gekka 8,141 Reputation points MVP
    2024-06-22T07:24:12.0333333+00:00

    To resolve this error, you need to add the LangVersion to your *.csproj file.

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
      <PropertyGroup>
    
        <LangVersion>9</LangVersion> 
    
    0 comments No comments