Skip to content

Commit 7b8b38b

Browse files
chore(internal): remove unnecessary internal aliasing
1 parent a99ab95 commit 7b8b38b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+342
-598
lines changed

src/Swarms/ISwarmsClientClient.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
11
using System;
2+
using System.Net.Http;
23
using System.Text.Json;
34
using System.Threading.Tasks;
4-
using Agent = Swarms.Services.Agent;
5-
using Client = Swarms.Services.Client;
6-
using Health = Swarms.Services.Health;
7-
using Http = System.Net.Http;
8-
using Models = Swarms.Services.Models;
9-
using ReasoningAgents = Swarms.Services.ReasoningAgents;
10-
using Swarms = Swarms.Services.Swarms;
5+
using Swarms.Models;
6+
using Swarms.Services.Agent;
7+
using Swarms.Services.Client;
8+
using Swarms.Services.Health;
9+
using Swarms.Services.Models;
10+
using Swarms.Services.ReasoningAgents;
11+
using Swarms.Services.Swarms;
1112

1213
namespace Swarms;
1314

1415
public interface ISwarmsClientClient
1516
{
16-
Http::HttpClient HttpClient { get; init; }
17+
HttpClient HttpClient { get; init; }
1718

1819
Uri BaseUrl { get; init; }
1920

2021
string? APIKey { get; init; }
2122

22-
Health::IHealthService Health { get; }
23+
IHealthService Health { get; }
2324

24-
Agent::IAgentService Agent { get; }
25+
IAgentService Agent { get; }
2526

26-
Models::IModelService Models { get; }
27+
IModelService Models { get; }
2728

28-
Swarms::ISwarmService Swarms { get; }
29+
ISwarmService Swarms { get; }
2930

30-
ReasoningAgents::IReasoningAgentService ReasoningAgents { get; }
31+
IReasoningAgentService ReasoningAgents { get; }
3132

32-
Client::IClientService Client { get; }
33+
IClientService Client { get; }
3334

3435
/// <summary>
3536
/// Root
3637
/// </summary>
37-
Task<JsonElement> GetRoot(global::Swarms.Models.ClientGetRootParams parameters);
38+
Task<JsonElement> GetRoot(ClientGetRootParams parameters);
3839
}

src/Swarms/Models/Agent/AgentCompletion.cs

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
using System.Diagnostics.CodeAnalysis;
33
using System.Text.Json;
44
using System.Text.Json.Serialization;
5-
using AgentCompletionProperties = Swarms.Models.Agent.AgentCompletionProperties;
6-
using Swarms = Swarms;
5+
using Swarms.Models.Agent.AgentCompletionProperties;
76

87
namespace Swarms.Models.Agent;
98

10-
[JsonConverter(typeof(Swarms::ModelConverter<AgentCompletion>))]
11-
public sealed record class AgentCompletion : Swarms::ModelBase, Swarms::IFromRaw<AgentCompletion>
9+
[JsonConverter(typeof(ModelConverter<AgentCompletion>))]
10+
public sealed record class AgentCompletion : ModelBase, IFromRaw<AgentCompletion>
1211
{
1312
/// <summary>
1413
/// The configuration of the agent to be completed.
@@ -20,10 +19,7 @@ public AgentSpec? AgentConfig
2019
if (!this.Properties.TryGetValue("agent_config", out JsonElement element))
2120
return null;
2221

23-
return JsonSerializer.Deserialize<AgentSpec?>(
24-
element,
25-
Swarms::ModelBase.SerializerOptions
26-
);
22+
return JsonSerializer.Deserialize<AgentSpec?>(element, ModelBase.SerializerOptions);
2723
}
2824
set { this.Properties["agent_config"] = JsonSerializer.SerializeToElement(value); }
2925
}
@@ -32,17 +28,14 @@ public AgentSpec? AgentConfig
3228
/// The history of the agent's previous tasks and responses. Can be either a
3329
/// dictionary or a list of message objects.
3430
/// </summary>
35-
public AgentCompletionProperties::History? History
31+
public History? History
3632
{
3733
get
3834
{
3935
if (!this.Properties.TryGetValue("history", out JsonElement element))
4036
return null;
4137

42-
return JsonSerializer.Deserialize<AgentCompletionProperties::History?>(
43-
element,
44-
Swarms::ModelBase.SerializerOptions
45-
);
38+
return JsonSerializer.Deserialize<History?>(element, ModelBase.SerializerOptions);
4639
}
4740
set { this.Properties["history"] = JsonSerializer.SerializeToElement(value); }
4841
}
@@ -57,10 +50,7 @@ public string? Img
5750
if (!this.Properties.TryGetValue("img", out JsonElement element))
5851
return null;
5952

60-
return JsonSerializer.Deserialize<string?>(
61-
element,
62-
Swarms::ModelBase.SerializerOptions
63-
);
53+
return JsonSerializer.Deserialize<string?>(element, ModelBase.SerializerOptions);
6454
}
6555
set { this.Properties["img"] = JsonSerializer.SerializeToElement(value); }
6656
}
@@ -75,10 +65,7 @@ public List<string>? Imgs
7565
if (!this.Properties.TryGetValue("imgs", out JsonElement element))
7666
return null;
7767

78-
return JsonSerializer.Deserialize<List<string>?>(
79-
element,
80-
Swarms::ModelBase.SerializerOptions
81-
);
68+
return JsonSerializer.Deserialize<List<string>?>(element, ModelBase.SerializerOptions);
8269
}
8370
set { this.Properties["imgs"] = JsonSerializer.SerializeToElement(value); }
8471
}
@@ -93,7 +80,7 @@ public bool? Stream
9380
if (!this.Properties.TryGetValue("stream", out JsonElement element))
9481
return null;
9582

96-
return JsonSerializer.Deserialize<bool?>(element, Swarms::ModelBase.SerializerOptions);
83+
return JsonSerializer.Deserialize<bool?>(element, ModelBase.SerializerOptions);
9784
}
9885
set { this.Properties["stream"] = JsonSerializer.SerializeToElement(value); }
9986
}
@@ -108,10 +95,7 @@ public string? Task
10895
if (!this.Properties.TryGetValue("task", out JsonElement element))
10996
return null;
11097

111-
return JsonSerializer.Deserialize<string?>(
112-
element,
113-
Swarms::ModelBase.SerializerOptions
114-
);
98+
return JsonSerializer.Deserialize<string?>(element, ModelBase.SerializerOptions);
11599
}
116100
set { this.Properties["task"] = JsonSerializer.SerializeToElement(value); }
117101
}

src/Swarms/Models/Agent/AgentCompletionProperties/History.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using System.Text.Json;
44
using System.Text.Json.Serialization;
5-
using HistoryVariants = Swarms.Models.Agent.AgentCompletionProperties.HistoryVariants;
5+
using Swarms.Models.Agent.AgentCompletionProperties.HistoryVariants;
66

77
namespace Swarms.Models.Agent.AgentCompletionProperties;
88

@@ -16,10 +16,10 @@ public abstract record class History
1616
internal History() { }
1717

1818
public static implicit operator History(Dictionary<string, JsonElement> value) =>
19-
new HistoryVariants::JsonElements(value);
19+
new JsonElements(value);
2020

2121
public static implicit operator History(List<Dictionary<string, string>> value) =>
22-
new HistoryVariants::Strings(value);
22+
new Strings(value);
2323

2424
public abstract void Validate();
2525
}
@@ -42,7 +42,7 @@ JsonSerializerOptions options
4242
);
4343
if (deserialized != null)
4444
{
45-
return new HistoryVariants::JsonElements(deserialized);
45+
return new JsonElements(deserialized);
4646
}
4747
}
4848
catch (JsonException e)
@@ -58,7 +58,7 @@ JsonSerializerOptions options
5858
);
5959
if (deserialized != null)
6060
{
61-
return new HistoryVariants::Strings(deserialized);
61+
return new Strings(deserialized);
6262
}
6363
}
6464
catch (JsonException e)
@@ -74,8 +74,8 @@ public override void Write(Utf8JsonWriter writer, History? value, JsonSerializer
7474
object? variant = value switch
7575
{
7676
null => null,
77-
HistoryVariants::JsonElements(var jsonElements) => jsonElements,
78-
HistoryVariants::Strings(var strings) => strings,
77+
JsonElements(var jsonElements) => jsonElements,
78+
Strings(var strings) => strings,
7979
_ => throw new ArgumentOutOfRangeException(nameof(value)),
8080
};
8181
JsonSerializer.Serialize(writer, variant, options);

src/Swarms/Models/Agent/AgentRunParams.cs

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
using System.Net.Http;
44
using System.Text;
55
using System.Text.Json;
6-
using AgentRunParamsProperties = Swarms.Models.Agent.AgentRunParamsProperties;
7-
using Swarms = Swarms;
6+
using Swarms.Models.Agent.AgentRunParamsProperties;
87

98
namespace Swarms.Models.Agent;
109

1110
/// <summary>
1211
/// Run an agent with the specified task.
1312
/// </summary>
14-
public sealed record class AgentRunParams : Swarms::ParamsBase
13+
public sealed record class AgentRunParams : ParamsBase
1514
{
1615
public Dictionary<string, JsonElement> BodyProperties { get; set; } = [];
1716

@@ -25,10 +24,7 @@ public AgentSpec? AgentConfig
2524
if (!this.BodyProperties.TryGetValue("agent_config", out JsonElement element))
2625
return null;
2726

28-
return JsonSerializer.Deserialize<AgentSpec?>(
29-
element,
30-
Swarms::ModelBase.SerializerOptions
31-
);
27+
return JsonSerializer.Deserialize<AgentSpec?>(element, ModelBase.SerializerOptions);
3228
}
3329
set { this.BodyProperties["agent_config"] = JsonSerializer.SerializeToElement(value); }
3430
}
@@ -37,17 +33,14 @@ public AgentSpec? AgentConfig
3733
/// The history of the agent's previous tasks and responses. Can be either a
3834
/// dictionary or a list of message objects.
3935
/// </summary>
40-
public AgentRunParamsProperties::History? History
36+
public History? History
4137
{
4238
get
4339
{
4440
if (!this.BodyProperties.TryGetValue("history", out JsonElement element))
4541
return null;
4642

47-
return JsonSerializer.Deserialize<AgentRunParamsProperties::History?>(
48-
element,
49-
Swarms::ModelBase.SerializerOptions
50-
);
43+
return JsonSerializer.Deserialize<History?>(element, ModelBase.SerializerOptions);
5144
}
5245
set { this.BodyProperties["history"] = JsonSerializer.SerializeToElement(value); }
5346
}
@@ -62,10 +55,7 @@ public string? Img
6255
if (!this.BodyProperties.TryGetValue("img", out JsonElement element))
6356
return null;
6457

65-
return JsonSerializer.Deserialize<string?>(
66-
element,
67-
Swarms::ModelBase.SerializerOptions
68-
);
58+
return JsonSerializer.Deserialize<string?>(element, ModelBase.SerializerOptions);
6959
}
7060
set { this.BodyProperties["img"] = JsonSerializer.SerializeToElement(value); }
7161
}
@@ -80,10 +70,7 @@ public List<string>? Imgs
8070
if (!this.BodyProperties.TryGetValue("imgs", out JsonElement element))
8171
return null;
8272

83-
return JsonSerializer.Deserialize<List<string>?>(
84-
element,
85-
Swarms::ModelBase.SerializerOptions
86-
);
73+
return JsonSerializer.Deserialize<List<string>?>(element, ModelBase.SerializerOptions);
8774
}
8875
set { this.BodyProperties["imgs"] = JsonSerializer.SerializeToElement(value); }
8976
}
@@ -98,7 +85,7 @@ public bool? Stream
9885
if (!this.BodyProperties.TryGetValue("stream", out JsonElement element))
9986
return null;
10087

101-
return JsonSerializer.Deserialize<bool?>(element, Swarms::ModelBase.SerializerOptions);
88+
return JsonSerializer.Deserialize<bool?>(element, ModelBase.SerializerOptions);
10289
}
10390
set { this.BodyProperties["stream"] = JsonSerializer.SerializeToElement(value); }
10491
}
@@ -113,15 +100,12 @@ public string? Task
113100
if (!this.BodyProperties.TryGetValue("task", out JsonElement element))
114101
return null;
115102

116-
return JsonSerializer.Deserialize<string?>(
117-
element,
118-
Swarms::ModelBase.SerializerOptions
119-
);
103+
return JsonSerializer.Deserialize<string?>(element, ModelBase.SerializerOptions);
120104
}
121105
set { this.BodyProperties["task"] = JsonSerializer.SerializeToElement(value); }
122106
}
123107

124-
public override Uri Url(Swarms::ISwarmsClientClient client)
108+
public override Uri Url(ISwarmsClientClient client)
125109
{
126110
return new UriBuilder(client.BaseUrl.ToString().TrimEnd('/') + "/v1/agent/completions")
127111
{
@@ -138,12 +122,12 @@ public StringContent BodyContent()
138122
);
139123
}
140124

141-
public void AddHeadersToRequest(HttpRequestMessage request, Swarms::ISwarmsClientClient client)
125+
public void AddHeadersToRequest(HttpRequestMessage request, ISwarmsClientClient client)
142126
{
143-
Swarms::ParamsBase.AddDefaultHeaders(request, client);
127+
ParamsBase.AddDefaultHeaders(request, client);
144128
foreach (var item in this.HeaderProperties)
145129
{
146-
Swarms::ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value);
130+
ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value);
147131
}
148132
}
149133
}

src/Swarms/Models/Agent/AgentRunParamsProperties/History.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections.Generic;
33
using System.Text.Json;
44
using System.Text.Json.Serialization;
5-
using HistoryVariants = Swarms.Models.Agent.AgentRunParamsProperties.HistoryVariants;
5+
using Swarms.Models.Agent.AgentRunParamsProperties.HistoryVariants;
66

77
namespace Swarms.Models.Agent.AgentRunParamsProperties;
88

@@ -16,10 +16,10 @@ public abstract record class History
1616
internal History() { }
1717

1818
public static implicit operator History(Dictionary<string, JsonElement> value) =>
19-
new HistoryVariants::JsonElements(value);
19+
new JsonElements(value);
2020

2121
public static implicit operator History(List<Dictionary<string, string>> value) =>
22-
new HistoryVariants::Strings(value);
22+
new Strings(value);
2323

2424
public abstract void Validate();
2525
}
@@ -42,7 +42,7 @@ JsonSerializerOptions options
4242
);
4343
if (deserialized != null)
4444
{
45-
return new HistoryVariants::JsonElements(deserialized);
45+
return new JsonElements(deserialized);
4646
}
4747
}
4848
catch (JsonException e)
@@ -58,7 +58,7 @@ JsonSerializerOptions options
5858
);
5959
if (deserialized != null)
6060
{
61-
return new HistoryVariants::Strings(deserialized);
61+
return new Strings(deserialized);
6262
}
6363
}
6464
catch (JsonException e)
@@ -74,8 +74,8 @@ public override void Write(Utf8JsonWriter writer, History? value, JsonSerializer
7474
object? variant = value switch
7575
{
7676
null => null,
77-
HistoryVariants::JsonElements(var jsonElements) => jsonElements,
78-
HistoryVariants::Strings(var strings) => strings,
77+
JsonElements(var jsonElements) => jsonElements,
78+
Strings(var strings) => strings,
7979
_ => throw new ArgumentOutOfRangeException(nameof(value)),
8080
};
8181
JsonSerializer.Serialize(writer, variant, options);

0 commit comments

Comments
 (0)