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

Bug: The requested operation requires an element of type 'String', but the target element has type 'Object'. #8900

Closed
JP-droidic opened this issue Sep 18, 2024 · 2 comments
Assignees
Labels
agents bug Something isn't working

Comments

@JP-droidic
Copy link

Hi guys

I'm getting the message bellow if an agent has attached a vectorStore

OpenAIAssistantAgent agent =
            await OpenAIAssistantAgent.CreateAsync(
                kernel: new Kernel(),
                GetClientProvider(),
                new OpenAIAssistantDefinition(openAiOptions.ChatModelId)
                {
                    Instructions = instructions,
                    Name = name,
                    EnableFileSearch = !string.IsNullOrEmpty(vectorStoreId),
                    EnableCodeInterpreter = enableCodeInterpreter,
                    VectorStoreId = vectorStoreId
                });

The error happens when I try to invoke the chat.

System.InvalidOperationException: The requested operation requires an element of type 'String', but the target element has type 'Object'. at System.Text.Json.ThrowHelper.ThrowJsonElementWrongTypeException(JsonTokenType expectedType, JsonTokenType actualType) at System.Text.Json.JsonDocument.GetString(Int32 index, JsonTokenType expectedType) at OpenAI.Assistants.InternalRunStepDeltaStepDetailsToolCallsFileSearchObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsFileSearchObject(JsonElement element, ModelReaderWriterOptions options) at OpenAI.Assistants.InternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsObjectToolCallsObject(JsonElement element, ModelReaderWriterOptions options) at OpenAI.Assistants.InternalRunStepDeltaStepDetailsToolCallsObject.DeserializeInternalRunStepDeltaStepDetailsToolCallsObject(JsonElement element, ModelReaderWriterOptions options) at OpenAI.Assistants.InternalRunStepDeltaStepDetails.DeserializeInternalRunStepDeltaStepDetails(JsonElement element, ModelReaderWriterOptions options) at OpenAI.Assistants.InternalRunStepDeltaObjectDelta.DeserializeInternalRunStepDeltaObjectDelta(JsonElement element, ModelReaderWriterOptions options) at OpenAI.Assistants.InternalRunStepDelta.DeserializeInternalRunStepDelta(JsonElement element, ModelReaderWriterOptions options) at OpenAI.Assistants.RunStepDetailsUpdate.DeserializeRunStepDetailsUpdates(JsonElement element, StreamingUpdateReason updateKind, ModelReaderWriterOptions options) at OpenAI.Assistants.StreamingUpdate.FromEvent(SseItem1 sseItem) at OpenAI.Assistants.AsyncStreamingUpdateCollection.AsyncStreamingUpdateEnumerator.System.Collections.Generic.IAsyncEnumerator.MoveNextAsync() at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.InvokeStreamingAsync(OpenAIAssistantAgent agent, AssistantClient client, String threadId, IList1 messages, OpenAIAssistantInvocationOptions invocationOptions, ILogger logger, Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)+MoveNext() at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.InvokeStreamingAsync(OpenAIAssistantAgent agent, AssistantClient client, String threadId, IList1 messages, OpenAIAssistantInvocationOptions invocationOptions, ILogger logger, Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)+MoveNext() at Microsoft.SemanticKernel.Agents.OpenAI.Internal.AssistantThreadActions.InvokeStreamingAsync(OpenAIAssistantAgent agent, AssistantClient client, String threadId, IList1 messages, OpenAIAssistantInvocationOptions invocationOptions, ILogger logger, Kernel kernel, KernelArguments arguments, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource.GetResult() at AiEngine.SemanticKernel.SemanticKernelService.GetChatMessageContentStreamingAssistantAsync(RequestModel requestModel, OpenAIAssistantAgent assistant, String threadId) in

@JP-droidic JP-droidic added the bug Something isn't working label Sep 18, 2024
@JP-droidic
Copy link
Author

Even with code modifcation where vectore store is attached to a thread

    ```

OpenAIAssistantAgent agent =
await OpenAIAssistantAgent.CreateAsync(
kernel: new Kernel(),
GetClientProvider(),
new OpenAIAssistantDefinition(openAiOptions.ChatModelId)
{
Instructions = instructions,
Name = name,
EnableFileSearch = !string.IsNullOrEmpty(vectorStoreId),
EnableCodeInterpreter = enableCodeInterpreter
});

    return agent;

return await assistant.CreateThreadAsync(new OpenAIThreadCreationOptions()
{
VectorStoreId = setup.VectorStoreId
});


I can see in openAI:

![image](https://github.com/user-attachments/assets/602be13a-3cb9-465d-9c2e-e0da4e5f1c68)

@JP-droidic
Copy link
Author

Sorry guys false alarm. Once we upgraded the library to 1.20 it started working.

I'm going to close this issue now

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

No branches or pull requests

3 participants