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

.NET Connector: Simplifies config using custom attributes #100

Merged
merged 6 commits into from
Oct 8, 2024
Merged

.NET Connector: Simplifies config using custom attributes #100

merged 6 commits into from
Oct 8, 2024

Conversation

tommasodotNET
Copy link
Contributor

Using a custom attribute for MyAgentConfig propoerties reduce the boilerplate code necessary to implement IAgentConfig.

MyAgentConfig now extend and AgentConflict class that uses reflection to read the custom attributes and implements all the IAgentConfig logic.

@dluc dluc changed the title Simplifies config using custom attributes .NET Connector: Simplifies config using custom attributes Oct 8, 2024
@dluc dluc self-requested a review October 8, 2024 17:20
@dluc
Copy link
Contributor

dluc commented Oct 8, 2024

Getting an error while testing example 3:

[12:40:46.666] fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1] An unhandled exception has occurred while executing the request. System.UriFormatException: Invalid URI: The hostname could not be parsed.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
at System.Uri..ctor(String uriString)
at AgentExample.Program.<>c__DisplayClass2_0.b__0(IServiceProvider _) in examples/dotnet/dotnet-03-simple-chatbot/Program.cs:line 54

at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.CreateServiceAccessor(ServiceIdentifier serviceIdentifier)
at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorInfoEx.GetService(IServiceProvider serviceProvider, Int32 parameterIndex)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance[T](IServiceProvider provider, Object[] parameters)

at AgentExample.MyWorkbenchConnector.CreateAgentAsync(String agentId, String name, Object configData, CancellationToken cancellationToken)
in examples/dotnet/dotnet-03-simple-chatbot/MyWorkbenchConnector.cs:line 46

at Microsoft.SemanticWorkbench.Connector.Webservice.<>c.<b__2_0>d.MoveNext()
in libraries/dotnet/WorkbenchConnector/Webservice.cs:line 80 --- End of stack trace from previous location ---

at Microsoft.AspNetCore.Http.RequestDelegateFactory.ExecuteTaskResult[T](Task`1 task, HttpContext httpContext)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.<>c__DisplayClass104_2.<b__2>d.MoveNext() --- End of stack trace from previous location ---
at Microsoft.AspNetCore.Routing.EndpointMiddleware.g__AwaitRequestTask|7_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

@dluc
Copy link
Contributor

dluc commented Oct 8, 2024

looks like all .NET examples are broken with the same error, something must have changed in the service

@dluc
Copy link
Contributor

dluc commented Oct 8, 2024

Exception fixed, it was just a configuration problem

Another problem: the two default properties in AgentConfig render last in the UI, which is confusing:

image

Also: validate moderation service URI in Program.cs (example 2 and 3)
@dluc dluc merged commit ddf9733 into microsoft:main Oct 8, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants