microsoft / semantic-kernel

Integrate cutting-edge LLM technology quickly and easily into your apps
https://aka.ms/semantic-kernel
MIT License
21.26k stars 3.12k forks source link

.Net: Pinecone Connector throws exception after upgrading from Beta8 to RC4 #4360

Open Pelias2525 opened 8 months ago

Pelias2525 commented 8 months ago

After updating from Beta 8 to RC4, after making the necessary code changes, when I run the code below, InvokeAsync() throws the following exception: "The JSON value could not be converted to Microsoft.SemanticKernel.Connectors.Pinecone.PodType. Path: $.database.pod_type | LineNumber: 0 | BytePositionInLine: 121." I've included the full stacktrace below as well.

var kernelBuilder = Kernel.CreateBuilder();
kernelBuilder = kernelBuilder.AddOpenAITextEmbeddingGeneration(index.EmbeddingModel, config.EmbeddingConfig.Key);
kernelBuilder = kernelBuilder.AddOpenAIChatCompletion(index.CompletionModel, config.CompletionConfig.Key);

var kernel = kernelBuilder.Build();

PineconeMemoryStore memoryStore = new PineconeMemoryStore(config.MemoryStoreConfig.EnvironmentName, config.MemoryStoreConfig.APIKey);

// Create an embedding generator to use for semantic memory.
var embeddingGenerator = new OpenAITextEmbeddingGenerationService(index.EmbeddingModel, config.EmbeddingConfig.Key);
SemanticTextMemory textMemory = new(memoryStore, embeddingGenerator);

var memoryPlugin = new TextMemoryPlugin(textMemory);
kernel.ImportPluginFromObject(memoryPlugin, "textmemoryskill");

var completionPromptFunction = kernel.CreateFunctionFromPrompt(index.CompletionPrompt,
        new OpenAIPromptExecutionSettings() { MaxTokens = index.CompletionMaxTokens, PresencePenalty = 0, TopP = 1, Temperature = .5, FrequencyPenalty = 0 });

string responseText = string.Empty;
FunctionResult response = null;
try
{
  // Exception thrown from InvokeAsync call below
    response = await kernel.InvokeAsync(completionPromptFunction, new()
    {
        [TextMemoryPlugin.CollectionParam] = aiConfig.MemoryStoreConfig.IndexName,
        [TextMemoryPlugin.LimitParam] = 3,
        [TextMemoryPlugin.RelevanceParam] = "0.70",
        ["input"] = query.UserPrompt
    });

    responseText = response.GetValue<string>();
}
catch (Exception ex)
{
    // Exception caught here
}

Stack Trace:

at System.Text.Json.ThrowHelper.ThrowJsonException(String message)
   at System.Text.Json.Serialization.Converters.EnumConverter`1.ReadEnumUsingNamingPolicy(String enumString)
   at System.Text.Json.Serialization.Converters.EnumConverter`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
   at System.Text.Json.Serialization.Metadata.JsonPropertyInfo`1.ReadJsonAndSetMember(Object obj, ReadStack& state, Utf8JsonReader& reader)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.Converters.SmallObjectWithParameterizedConstructorConverter`5.TryRead[TArg](ReadStack& state, Utf8JsonReader& reader, JsonParameterInfo jsonParameterInfo, TArg& arg)
   at System.Text.Json.Serialization.Converters.SmallObjectWithParameterizedConstructorConverter`5.ReadAndCacheConstructorArgument(ReadStack& state, Utf8JsonReader& reader, JsonParameterInfo jsonParameterInfo)
   at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1.OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value)
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo`1 jsonTypeInfo, Nullable`1 actualByteCount)
   at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 json, JsonTypeInfo`1 jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
   at Microsoft.SemanticKernel.Connectors.Pinecone.PineconeClient.<DescribeIndexAsync>d__12.MoveNext()
   at Microsoft.SemanticKernel.Connectors.Pinecone.PineconeClient.<GetIndexHostAsync>d__24.MoveNext()
   at Microsoft.SemanticKernel.Connectors.Pinecone.PineconeClient.<GetVectorOperationsApiBasePathAsync>d__21.MoveNext()
   at Microsoft.SemanticKernel.Connectors.Pinecone.PineconeClient.<QueryAsync>d__2.MoveNext()
   at Microsoft.SemanticKernel.Connectors.Pinecone.PineconeClient.<QueryAsync>d__2.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.SemanticKernel.Connectors.Pinecone.PineconeClient.<GetMostRelevantAsync>d__3.MoveNext()
   at Microsoft.SemanticKernel.Connectors.Pinecone.PineconeClient.<GetMostRelevantAsync>d__3.MoveNext()
   at Microsoft.SemanticKernel.Connectors.Pinecone.PineconeClient.<GetMostRelevantAsync>d__3.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.SemanticKernel.Connectors.Pinecone.PineconeMemoryStore.<GetNearestMatchesFromNamespaceAsync>d__25.MoveNext()
   at Microsoft.SemanticKernel.Connectors.Pinecone.PineconeMemoryStore.<GetNearestMatchesFromNamespaceAsync>d__25.MoveNext()
   at Microsoft.SemanticKernel.Connectors.Pinecone.PineconeMemoryStore.<GetNearestMatchesFromNamespaceAsync>d__25.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at Microsoft.SemanticKernel.Memory.SemanticTextMemory.<SearchAsync>d__7.MoveNext()
   at Microsoft.SemanticKernel.Memory.SemanticTextMemory.<SearchAsync>d__7.MoveNext()
   at Microsoft.SemanticKernel.Memory.SemanticTextMemory.<SearchAsync>d__7.System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult(Int16 token)
   at System.Linq.AsyncEnumerable.<ToListAsync>d__5`1.MoveNext()
   at System.Linq.AsyncEnumerable.<ToListAsync>d__5`1.MoveNext()
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.SemanticKernel.Plugins.Memory.TextMemoryPlugin.<RecallAsync>d__11.MoveNext()
   at Microsoft.SemanticKernel.KernelFunctionFromMethod.<>c.<<GetReturnValueMarshalerDelegate>b__13_4>d.MoveNext()
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.SemanticKernel.KernelFunction.<InvokeAsync>d__18.MoveNext()
   at Microsoft.SemanticKernel.TemplateEngine.CodeBlock.<RenderFunctionCallAsync>d__10.MoveNext()
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.SemanticKernel.KernelPromptTemplate.<RenderAsync>d__5.MoveNext()
   at Microsoft.SemanticKernel.KernelFunctionFromPrompt.<RenderPromptAsync>d__16.MoveNext()
   at Microsoft.SemanticKernel.KernelFunctionFromPrompt.<InvokeCoreAsync>d__3.MoveNext()
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.SemanticKernel.KernelFunction.<InvokeAsync>d__18.MoveNext()

Platform

Pelias2525 commented 8 months ago

I've confirmed that this is still an issue with Microsoft.SemanticKernel v1.0.1 and Microsoft.SemanticKernel.Connectors.Pinecone 1.0.1-alpha packages released yesterday afternoon.

Pelias2525 commented 5 months ago

Will the fix be released any time soon? I haven't seen it listed in the release notes thus far...