Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not load type 'OpenAI.OpenAIClient' from assembly 'OpenAI #501

Closed
dzianisradziukouacc opened this issue Jan 31, 2025 · 1 comment
Closed
Labels
bug Something isn't working providers

Comments

@dzianisradziukouacc
Copy link

Describe the bug

First run with the code from instruction throws an error:
System.TypeLoadException
HResult=0x80131522
Message=Could not load type 'OpenAI.OpenAIClient' from assembly 'OpenAI, Version=3.0.0.0, Culture=neutral, PublicKeyToken=20925763ef4043f0'.
Source=LangChain.Providers.Azure
StackTrace:
at LangChain.Providers.Azure.AzureOpenAiProvider..ctor(String apiKey, String endpoint, String deploymentID) in /_/src/Azure/src/AzureOpenAiProvider.cs:line 63
at Program.<

$>d__0.MoveNext() in C:\LLMAgent\Program.cs:line 8
at Program.(String[] args)

Steps to reproduce the bug

  1. Create a new console application in Net Core 8.
  2. Add code to the Program.cs file:
    using LangChain.Providers;
    using LangChain.Providers.Azure;

var AZURE_OPEN_AI_KEY = "...";//must be specified by user
var ENDPOINT = "...";//must be specified by user
var DEPLOYMENT_NAME = "gpt-4o-mini";

var provider = new AzureOpenAiProvider(apiKey: AZURE_OPEN_AI_KEY, endpoint: ENDPOINT, deploymentID: DEPLOYMENT_NAME);
var llm = new AzureOpenAiChatModel(provider, id: DEPLOYMENT_NAME);

var result = await llm.GenerateAsync("What is a good name for a company that sells colourful socks?");

Console.WriteLine(result);

  1. the line var provider = new AzureOpenAiProvider throws an error:
    System.TypeLoadException
    HResult=0x80131522
    Message=Could not load type 'OpenAI.OpenAIClient' from assembly 'OpenAI, Version=3.0.0.0, Culture=neutral, PublicKeyToken=20925763ef4043f0'.
    Source=LangChain.Providers.Azure
    StackTrace:
    at LangChain.Providers.Azure.AzureOpenAiProvider..ctor(String apiKey, String endpoint, String deploymentID) in /_/src/Azure/src/AzureOpenAiProvider.cs:line 63
    at Program.<$>d__0.MoveNext() in C:\LLMAgent\Program.cs:line 8
    at Program.(String[] args)

Expected behavior

No response

Screenshots

Image

NuGet package version

No response

Additional context

No response

@dzianisradziukouacc dzianisradziukouacc added the bug Something isn't working label Jan 31, 2025
@dzianisradziukouacc
Copy link
Author

It works fine in the latest 0.17.0 version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working providers
Projects
None yet
Development

No branches or pull requests

2 participants