ægteemil
ægteemil
Explore posts from servers
NNuxt
Created by ægteemil on 6/12/2024 in #❓・help
Centered grid with different-sized children
No description
2 replies
NNuxt
Created by ægteemil on 3/12/2024 in #❓・help
`useAsyncState` equivalent in Nuxt
Hey. Up until now I've been using useAsyncState from VueUse when doing any CRUD work through a service of mine, and I'm curious if this is bad practice and if there's an equivalent function baked into Nuxt? Today I'm doing something like this, which I'm looking to translate similarly to a Nuxt composable of some sort:
const { isLoading, execute: createApiKey } = useAsyncState(async (name: string) => {
await CustomersService.create({ name: name });
}, null, {
immediate: false,
onError: (error) => {
useApiErrorToast(error);
}
});
const { isLoading, execute: createApiKey } = useAsyncState(async (name: string) => {
await CustomersService.create({ name: name });
}, null, {
immediate: false,
onError: (error) => {
useApiErrorToast(error);
}
});
3 replies
CC#
Created by ægteemil on 6/23/2023 in #help
❔ streaming an IAsyncEnumerable<string> from complex type
hey. i have a minimal api that looks like this:
public static async IAsyncEnumerable<string> AskOpenAi(
[FromQuery] string question,
[FromServices] IOpenAIService openAiService)
{
var completionResult = openAiService.ChatCompletion.CreateCompletionAsStream(new ChatCompletionCreateRequest
{
Messages = new List<ChatMessage>
{
new(StaticValues.ChatMessageRoles.System, "You are a helpful assistant."),
new(StaticValues.ChatMessageRoles.User, question),
},
Model = Models.ChatGpt3_5Turbo,
MaxTokens = 150
});

await foreach (var completion in completionResult)
yield return completion.Choices.First().Message.Content;
}
public static async IAsyncEnumerable<string> AskOpenAi(
[FromQuery] string question,
[FromServices] IOpenAIService openAiService)
{
var completionResult = openAiService.ChatCompletion.CreateCompletionAsStream(new ChatCompletionCreateRequest
{
Messages = new List<ChatMessage>
{
new(StaticValues.ChatMessageRoles.System, "You are a helpful assistant."),
new(StaticValues.ChatMessageRoles.User, question),
},
Model = Models.ChatGpt3_5Turbo,
MaxTokens = 150
});

await foreach (var completion in completionResult)
yield return completion.Choices.First().Message.Content;
}
it's registered like this:
app.MapGet("", AskOpenAiEndpoint.AskOpenAi);
app.MapGet("", AskOpenAiEndpoint.AskOpenAi);
but whenever i visit the url, the answer is not being streamed but rather returend as one large string. i tried making a dummy endpoint that works like expected, but im unsure how to modify the above code so it works. this is the test that worked for me:
public static async IAsyncEnumerable<string> Test()
{
var values = new[] { "value1", "value2", "value3", "value4" };
foreach (var item in values)
{
await Task.Delay(1000);
yield return item;
}
}
public static async IAsyncEnumerable<string> Test()
{
var values = new[] { "value1", "value2", "value3", "value4" };
foreach (var item in values)
{
await Task.Delay(1000);
yield return item;
}
}
13 replies
CC#
Created by ægteemil on 4/20/2023 in #help
❔ Swagger shows unwanted schemas when with minimal api
2 replies
CC#
Created by ægteemil on 4/2/2023 in #help
❔ Required select field missing validation error message on iOS
Hey. If I create a required select field, and the select field is outside the current viewport (ie., if you've scrolled further down on the page), the browser doesn't jump to the required select and the validation message is missing. I managed to find a recent stackoverflow question for exactly this, but there's no comments on it. Does anyone here have an idea for how to fix it? https://stackoverflow.com/questions/75854715/html5-form-validation-with-select-field-on-ios-15-16-bug
2 replies
CC#
Created by ægteemil on 11/26/2022 in #help
❔ The foreign key property 'UserRole.RoleId1' was created in shadow state
I've expanded the default IdentityUserRole implementation for .NET identity like this:
public class UserRole : IdentityUserRole<Guid>
{
public Guid TenantId { get; set; }
public virtual Tenant Tenant { get; set; } = null!;

public virtual User User { get; set; } = null!;
public virtual Role Role { get; set; } = null!;
}
public class UserRole : IdentityUserRole<Guid>
{
public Guid TenantId { get; set; }
public virtual Tenant Tenant { get; set; } = null!;

public virtual User User { get; set; } = null!;
public virtual Role Role { get; set; } = null!;
}
And I've included the User and Role as navigation properties, which is now causing EF to write this when creating a migration: The foreign key property 'UserRole.RoleId1' was created in shadow state because a conflicting property with the simple name 'RoleId' exists in the entity type, but is either not mapped, is already used for another relationship, or is incompatible with the associated primary key type I'm not sure how to configure this properly and avoid the new foreign key property
2 replies
CC#
Created by ægteemil on 11/13/2022 in #help
❔ Customizing assigned roles on sign in using SignInManager
3 replies
CC#
Created by ægteemil on 8/31/2022 in #help
Disable bootstrap multiselect options after selecting
Hi. I have a bootstrap <select multiple/>. When one is selected, I want to disable all other selections temporarily (while waiting for an API response), then enable them again after the response. I can't seem to find a good example of this
6 replies