Comments (5)
@joakimriedel I suppose one further workaround could be to get the source of the last 1.0.0 SDK, rename all namespaces, and push that to a new NuGet package, in order to have the legacy package available as a separate package.
All of these are hacky, however, and their need is quite disappointing.
from azure-sdk-for-net.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @jpalvarezl @trrwilson.
from azure-sdk-for-net.
Note that this is intentionally not a feature request, because this breaks existing functionality that should still be supported.
from azure-sdk-for-net.
Thank you, @kescherCode, both for the mention here as well as on openai-dotnet. Although this was an intentional omission of the legacy completions surface on both the new client and this major version increment of the preview library, I hear you loud and clear on the migration block that imposes for /completions endpoint use. Breaking changes are very much expected, but breaking changes with no upgrade path are exceptionally painful.
We'll discuss this strategy in the product team and with OpenAI. In the interim, the prior v1.0.0-beta.17 release will continue to be a supported mechanism for using -instruct
with the 2024-04-01-preview
service API label even while v2.0.0-beta-*
does not (at least yet) support them.
from azure-sdk-for-net.
+1 for legacy completions, it is not just for the -instruct model but fine-tunes using babbage-002/davinci-002. We have an important logprobs classification task using a fine tuned babbage-002 which blocks upgrading to 2.0.0-beta.x right now.
Edit: managed to move the code calling the legacy completions into a separate "LegacyOpenAI" project, but had to do the following since the 2.0.0-beta version is pinned centrally for Nuget for all other projects in the solution;
<PackageReference Include="Azure.AI.OpenAI" VersionOverride="1.0.0-beta.17">
<NoWarn>NU1605</NoWarn>
</PackageReference>
posting the workaround here if it might help anyone else.
Edit2: This doesn't work, I get error
System.TypeLoadException: Could not load type 'Azure.AI.OpenAI.Completions' from assembly 'Azure.AI.OpenAI, Version=2.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8'.
Looking to solve this right now.
Edit3: Seems like there is no way to load a lower versioned library in a solution already having a higher versioned library loaded so I had to go deep in the rabbit hole here to solve this. I put the v1.0.0-beta.17 version of Azure.AI.OpenAI.dll
into my "LegacyOpenAI" project and renamed it to Azure.AI.OpenAI.Legacy.dll
to be able to load it in a new AssemblyLoadContext below using reflection... 🤦♂️
public async Task<IDictionary<string, float?>> GetTopLogProbsAsync(
string prompt, string? userId, int maxTokens, float temperature,
CancellationToken cancellationToken)
{
AssemblyLoadContext? loadContext = null;
try
{
loadContext = new AssemblyLoadContext(Guid.NewGuid().ToString(), true);
var pathToAssembly = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Azure.AI.OpenAI.Legacy.dll");
Assembly assembly = loadContext.LoadFromAssemblyPath(pathToAssembly);
var optionsType = assembly.GetType("Azure.AI.OpenAI.CompletionsOptions")
?? throw new ApplicationException("Could not get Azure.AI.OpenAI.CompletionsOptions from legacy dll");
dynamic options = Activator.CreateInstance(optionsType, _deploymentName, new[] { prompt })
?? throw new ApplicationException("Could not construct Azure.AI.OpenAI.CompletionsOptions from legacy dll");
options.DeploymentName = _deploymentName;
options.User = userId;
options.LogProbabilityCount = 2;
options.MaxTokens = maxTokens;
options.Temperature = temperature;
var clientType = assembly.GetType("Azure.AI.OpenAI.OpenAIClient")
?? throw new ApplicationException("Could not get Azure.AI.OpenAI.OpenAIClient from legacy dll");
dynamic client = (string.IsNullOrEmpty(openAIKey)
? Activator.CreateInstance(clientType, _endpoint, new Azure.Identity.DefaultAzureCredential())
: Activator.CreateInstance(clientType, _endpoint, new Azure.AzureKeyCredential(_openAIKey)))
?? throw new ApplicationException("Could not construct Azure.AI.OpenAI.OpenAIClient from legacy dll");
var response = await client.GetCompletionsAsync(options, cancellationToken);
dynamic choice = response.Value.Choices[0];
dynamic logprobs = choice.LogProbabilityModel.TopLogProbabilities[0];
return logprobs;
}
finally
{
// Unload the context.
loadContext?.Unload();
}
}
from azure-sdk-for-net.
Related Issues (20)
- [QUERY] Calling CloseAsync() or DisposeAsync() on ServiceBusProcessor throws exception with reason ServiceBusFailureReason.MessagingEntityNotFound HOT 6
- ClientModel: Add method to HttpClientPipelineTransport HOT 1
- ChatCompletionOptions doesn't work in .NET Standard 2.0 due to init properties. HOT 3
- [BUG] Cannot upload fine tuning files for Azure OpenAI
- [QUERY] Azure Service Bus: Time Spent in Queue is Large HOT 2
- [FEATURE REQ] Use change feed when available for Blob triggers HOT 1
- [BUG] BlobContainerClient under DataLakeFileSystemClient does not honor the audience set to DataLakeFileSystemClient HOT 1
- [BUG] EntityRecognitionSkill is deprecated, but EntityRecognitionSkillV3 is not public HOT 5
- [QUERY] "Invalid Audience" error instead of "Entity Not Found" HOT 11
- The pagesize parameter is not taken effect during the pageable operation
- Cognitive Vision Service Access Denied 401 Error
- AnalyzeDocumentFromUriAsync Does not exist HOT 1
- [BUG] OpenTelemetry Exporter for Monitor/App Insights omits LoggerRecord CategoryName HOT 2
- [BUG] Clarification on Handling Escape Characters in Azure Key Vault Secrets HOT 2
- [FEATURE REQ] Restore include options in DefaultAzureCredentialOptions. HOT 7
- [QUERY] Controlling the "type" name of an OTEL activity in Application Insights HOT 4
- [FEATURE REQ] SqlDatabaseResource.ExportAsync() / DatabaseExportDefinition to allow Managed Identity HOT 4
- Does uploading files by azure core is supported HOT 2
- [BUG] Unable to use Multipart Form data content types with Azure Core functionalities. HOT 2
- [BUG] Provisioning of zone redundant Hyperscale database with geo backup redundancy is not supported. Zone redundant Hyperscale databases must use either zone or geo zone backup redundancy. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-sdk-for-net.