Agent par défaut

This commit is contained in:
fabien committed 2026-09-07 21:04:48 +02:00
1 parent cf10b9073b
commit f74e4d1043
24 files changed
+385 -37

No files matched your search

@@ -63,7 +63,7 @@ create table user_addresses (
create table teams (
id text not null primary key,
label text not null,
default_model_id text,
default_agent_id text,
_date_created numeric not null default current_timestamp,
_date_updated numeric ,
_version text not null
@@ -68,7 +68,7 @@ func (ur *TursoUserRepository) DeleteUser(id string) error {
}
func (ur *TursoUserRepository) FindTeam(userid string, teamid string) (*domain.Team, error) {
return ur.TeamTable.SelectOne("id=$1 and user_id=$2", teamid, userid)
return ur.TeamTable.SelectOne("id=$1 and id in (select team_id from user_teams where user_id=$2)", teamid, userid)
}
func (ur *TursoUserRepository) ListTeams(userid string) ([]*domain.Team, error) {
@@ -74,3 +74,48 @@ func (e *AnyLLMEngine) ListModelsFromProvider(ctx context.Context, provider *dom
}
return models, nil
}
func (e *AnyLLMEngine) Stream(
ctx context.Context,
provider *domain.Provider,
modelID string,
params *domain.StreamParams,
messages []*domain.Message,
) error {
p, err := providerFactory(provider)
if err != nil {
return err
}
anyllmMessages := make([]anyllm.Message, 0)
for _, m := range messages {
anyllmMessages = append(anyllmMessages, anyllm.Message{
Role: m.Role,
Content: m.Content,
})
}
chunkChan, errChan := p.CompletionStream(ctx, anyllm.CompletionParams{
Model: modelID,
Messages: anyllmMessages,
Stream: true,
})
for chunk := range chunkChan {
if len(chunk.Choices) > 0 {
content := chunk.Choices[0].Delta.Content
if params.OnChunk != nil {
params.OnChunk(&domain.Chunk{
Content: content,
})
}
}
}
if err := <-errChan; err != nil {
return err
}
return nil
}