Skip to content

Commit d9d2e4a

Browse files
authored
Merge pull request #32 from BoHomola/threads_endpoint_remapping
Threads endpoint remapping
2 parents 7fd08d3 + b874abd commit d9d2e4a

File tree

81 files changed

+3371
-1640
lines changed

Some content is hidden

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

81 files changed

+3371
-1640
lines changed

FeatureMatrix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ _*Custom means any OpenAI compatible provider, such as Azure OpenAI, Ollama, Kob
2727

2828
Assistants | Threads | Messages | Runs | Run steps | Vector stores | Vector store files | Vector store file batches | Realtime |
2929
|-----------|------------|---------|----------|------| ---------------|-------------------|-------------------------|-----------|
30-
|| | | | |||| |
30+
|| | | | |||| |
3131

3232
## Google Specific
3333

LlmTornado.Demo/AssistantsDemo.cs

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public static async Task<Assistant> CreateFunctionAssistant()
3737
new CreateAssistantRequest(
3838
null,
3939
GenerateName(),
40-
"FileSearch Demo Assistant",
41-
"You are a helpful assistant with the ability to call functions.")
40+
"Function Demo Assistant",
41+
"You are a helpful assistant with the ability to call functions related to weather")
4242
{
43-
Tools = new List<AssistantTool>()
43+
Tools = new List<AssistantTool>
4444
{
4545
new AssistantToolFunction(new ToolFunctionConfig(
4646
"get_weather",
@@ -59,6 +59,24 @@ public static async Task<Assistant> CreateFunctionAssistant()
5959
required = new List<string> {"location"},
6060
additionalProperties = false
6161
}
62+
)),
63+
new AssistantToolFunction(new ToolFunctionConfig(
64+
"get_humidity",
65+
"Get current humidity for a given city",
66+
new
67+
{
68+
type = "object",
69+
properties = new
70+
{
71+
location = new
72+
{
73+
type = "string",
74+
description = "City and Country"
75+
}
76+
},
77+
required = new List<string> {"location"},
78+
additionalProperties = false
79+
}
6280
))
6381
}
6482
});
@@ -68,26 +86,35 @@ public static async Task<Assistant> CreateFunctionAssistant()
6886
}
6987

7088
[TornadoTest]
71-
public static async Task<Assistant> CreateFileSearchAssistant()
89+
public static async Task<Assistant> CreateFileSearchAssistant(string? filePath = null)
7290
{
73-
VectorStoreFile vectorStoreFile = await VectorStoreDemo.CreateVectorStoreFile();
91+
VectorStoreFile vectorStoreFile = null!;
92+
93+
if (string.IsNullOrWhiteSpace(filePath))
94+
{
95+
vectorStoreFile = await VectorStoreDemo.CreateVectorStoreFile();
96+
}
97+
else
98+
{
99+
vectorStoreFile = await VectorStoreDemo.CreateVectorStoreFile(filePath);
100+
}
74101

75102
HttpCallResult<Assistant> response = await Program.Connect().Assistants.CreateAssistantAsync(
76103
new CreateAssistantRequest(
77104
null,
78105
GenerateName(),
79106
"FileSearch Demo Assistant",
80-
"You are a helpful assistant with the ability to search files.")
107+
"You are a helpful assistant with the ability to search info in files")
81108
{
82-
Tools = new List<AssistantTool>()
109+
Tools = new List<AssistantTool>
83110
{
84111
new AssistantToolFileSearch()
85112
},
86-
ToolResources = new ToolResources()
113+
ToolResources = new ToolResources
87114
{
88-
FileSearch = new FileSearchConfig()
115+
FileSearch = new FileSearchConfig
89116
{
90-
FileSearchFileIds = new List<string>() {vectorStoreFile.VectorStoreId}
117+
FileSearchFileIds = new List<string> {vectorStoreFile.VectorStoreId}
91118
}
92119
}
93120
});
@@ -99,25 +126,16 @@ public static async Task<Assistant> CreateFileSearchAssistant()
99126
[TornadoTest]
100127
public static async Task<Assistant> CreateWithCodeInterpreter()
101128
{
102-
VectorStoreFile vectorStoreFile = await VectorStoreDemo.CreateVectorStoreFile();
103-
104129
HttpCallResult<Assistant> response = await Program.Connect().Assistants.CreateAssistantAsync(
105130
new CreateAssistantRequest(
106131
null,
107132
GenerateName(),
108133
"Code Interpreter Demo Assistant",
109-
"You are a helpful assistant with code interpretation capabilities.")
134+
"You are a personal math tutor. When asked a math question, write and run code to answer the question.")
110135
{
111-
Tools = new List<AssistantTool>()
136+
Tools = new List<AssistantTool>
112137
{
113138
AssistantToolCodeInterpreter.Inst
114-
},
115-
ToolResources = new ToolResources()
116-
{
117-
CodeInterpreter = new CodeInterpreterConfig()
118-
{
119-
CodeInterpreterFileIds = new List<string>() {vectorStoreFile.Id}
120-
}
121139
}
122140
});
123141

@@ -128,10 +146,7 @@ public static async Task<Assistant> CreateWithCodeInterpreter()
128146
[TornadoTest]
129147
public static async Task<Assistant?> Retrieve()
130148
{
131-
if (generatedAssistant is null)
132-
{
133-
await Create();
134-
}
149+
generatedAssistant ??= await Create();
135150

136151
HttpCallResult<Assistant> response =
137152
await Program.Connect().Assistants.RetrieveAssistantAsync(generatedAssistant!.Id);
@@ -142,10 +157,7 @@ public static async Task<Assistant> CreateWithCodeInterpreter()
142157
[TornadoTest]
143158
public static async Task<Assistant?> Modify()
144159
{
145-
if (generatedAssistant is null)
146-
{
147-
await Create();
148-
}
160+
generatedAssistant ??= await Create();
149161

150162
CreateAssistantRequest modifyRequest = new CreateAssistantRequest(generatedAssistant!)
151163
{
@@ -161,13 +173,11 @@ public static async Task<Assistant> CreateWithCodeInterpreter()
161173
[TornadoTest]
162174
public static async Task<bool> Delete()
163175
{
164-
if (generatedAssistant is null)
165-
{
166-
await Create();
167-
}
176+
generatedAssistant ??= await Create();
168177

169178
HttpCallResult<bool> response = await Program.Connect().Assistants.DeleteAssistantAsync(generatedAssistant!);
170179
Console.WriteLine(response.Response);
180+
generatedAssistant = null;
171181
return response.Data;
172182
}
173183

@@ -179,6 +189,7 @@ public static async Task DeleteAllDemoAssistants()
179189
where assistant.Name.StartsWith("demo_assistant")
180190
select Program.Connect().Assistants.DeleteAssistantAsync(assistant.Id)).ToList();
181191
Console.WriteLine($"Deleting {tasks.Count} assistants...");
192+
generatedAssistant = null;
182193
await Task.WhenAll(tasks);
183194
}
184195
}

LlmTornado.Demo/CachingDemo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static async Task List()
3232

3333
Console.WriteLine($"Listed:");
3434

35-
foreach (var item in listed.Data.CachedContents)
35+
foreach (CachedContentInformation? item in listed.Data.CachedContents)
3636
{
3737
Console.WriteLine($"{item.Name} - {item.ExpireTime}");
3838
}

LlmTornado.Demo/ChatDemo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ public static async Task CrossVendorFunctionsStreamingInteractive()
571571
{
572572
{ "prague", "A mild rain" },
573573
{ "tokyo", "Foggy, cloudy" },
574-
{ "paris", "A sunny day" },
574+
{ "paris", "A sunny day" }
575575
};
576576

577577
// 3. repl
@@ -1691,7 +1691,7 @@ public static async Task GoogleCached()
16911691
{
16921692
type = "string",
16931693
description = "Title/headline of the entry"
1694-
},
1694+
}
16951695
},
16961696
required = new List<string> { "content", "title" }
16971697
}), true);

LlmTornado.Demo/FilesDemo.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ public static class FilesDemo
99
[TornadoTest]
1010
public static async Task<TornadoFile?> Upload()
1111
{
12-
HttpCallResult<TornadoFile> uploadedFile = await Program.Connect().Files.Upload("Static/Files/sample.pdf", FilePurpose.Assistants);
13-
TornadoFile? retrievedFile = await Program.Connect().Files.Get(uploadedFile.Data?.Id);
14-
Console.WriteLine($"uploaded id: {uploadedFile.Data.Id}");
12+
TornadoFile? uploadedFile = await Upload("Static/Files/sample.pdf", FilePurpose.Assistants);
13+
TornadoFile? retrievedFile = await Program.Connect().Files.Get(uploadedFile?.Id);
14+
Console.WriteLine($"uploaded id: {uploadedFile.Id}");
1515
Console.WriteLine($"retrieved file id: {retrievedFile?.Id}");
16+
return uploadedFile;
17+
}
18+
19+
public static async Task<TornadoFile?> Upload(string path, FilePurpose purpose)
20+
{
21+
HttpCallResult<TornadoFile> uploadedFile = await Program.Connect().Files.Upload(path, purpose);
1622
return uploadedFile.Data;
1723
}
1824

0 commit comments

Comments
 (0)