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

Threads endpoint remapping #32

Merged
merged 32 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
df82446
adding support for Threads CRUD
BoHomola Jan 31, 2025
a6179df
adding mapping for Message
BoHomola Feb 2, 2025
950454c
Refactor message handling and annotations for threads.
BoHomola Feb 3, 2025
c12a8e9
merge conflict
BoHomola Feb 3, 2025
f2909c1
adapting to new Torando tests
BoHomola Feb 3, 2025
ba05b16
adding demo test cases for Run endpoint
BoHomola Feb 4, 2025
9e86956
moving all json propreties to Newtonsoft
BoHomola Feb 4, 2025
f0a3d76
refining mapping of RunStep
BoHomola Feb 5, 2025
2e1e5a2
correcting serialization of enum and adding rest of the RunSteps tests
BoHomola Feb 5, 2025
4fd7071
Fixing MessageAnnotation serialization issues and adding demo case fo…
BoHomola Feb 5, 2025
36c85d0
enumarizing TruncationStrategy type
BoHomola Feb 5, 2025
67a7b8c
formatting&enumartion of string types
BoHomola Feb 5, 2025
3c79c73
add a few ctors, format
lofcz Feb 6, 2025
078b852
formatting
lofcz Feb 6, 2025
fa415d5
Merge branch 'master' into pr/32
lofcz Feb 6, 2025
f202c34
clean up message roles
lofcz Feb 6, 2025
c5e2b47
Converting to enums and mappint ToolOutput
BoHomola Feb 6, 2025
9bfc849
Thread rename & other refactorings
BoHomola Feb 6, 2025
4b7bd81
Adding submit tool endpoint
BoHomola Feb 6, 2025
b44912e
changing serialization so that it does not cause stack overflow
BoHomola Feb 6, 2025
5236ad7
adding multiple entries of function calling to test out deserialization
BoHomola Feb 7, 2025
cd30505
Streaming of assistatants prototype
BoHomola Feb 7, 2025
f018872
adding TornadoTest Attribute to streaming assistant
BoHomola Feb 7, 2025
7e8f4a2
adding colors and adding demo for streaming a file extraction assistant
BoHomola Feb 7, 2025
27a4d77
optimize assistants streaming
lofcz Feb 8, 2025
e941562
formatting
lofcz Feb 8, 2025
e087adf
Merge branch 'master' into pr/32
lofcz Feb 8, 2025
73f7c87
fix
lofcz Feb 8, 2025
a99326a
Added CodeInterpreter, added doc and converted ToolChoiceType to froz…
BoHomola Feb 10, 2025
ffeb710
refinining file_search
BoHomola Feb 10, 2025
744893d
adding Body to the httpException callback
BoHomola Feb 10, 2025
b874abd
Adjusting FeatureMatrix with supported features
BoHomola Feb 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FeatureMatrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ _*Custom means any OpenAI compatible provider, such as Azure OpenAI, Ollama, Kob

Assistants | Threads | Messages | Runs | Run steps | Vector stores | Vector store files | Vector store file batches | Realtime |
|-----------|------------|---------|----------|------| ---------------|-------------------|-------------------------|-----------|
| ✅ | ️ | ️ | ️ | ️ | ✅ | ✅ | ✅ | |
| ✅ | ️ | ️ | ️ | ️ | ✅ | ✅ | ✅ | |

## Google Specific

Expand Down
77 changes: 44 additions & 33 deletions LlmTornado.Demo/AssistantsDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public static async Task<Assistant> CreateFunctionAssistant()
new CreateAssistantRequest(
null,
GenerateName(),
"FileSearch Demo Assistant",
"You are a helpful assistant with the ability to call functions.")
"Function Demo Assistant",
"You are a helpful assistant with the ability to call functions related to weather")
{
Tools = new List<AssistantTool>()
Tools = new List<AssistantTool>
{
new AssistantToolFunction(new ToolFunctionConfig(
"get_weather",
Expand All @@ -59,6 +59,24 @@ public static async Task<Assistant> CreateFunctionAssistant()
required = new List<string> {"location"},
additionalProperties = false
}
)),
new AssistantToolFunction(new ToolFunctionConfig(
"get_humidity",
"Get current humidity for a given city",
new
{
type = "object",
properties = new
{
location = new
{
type = "string",
description = "City and Country"
}
},
required = new List<string> {"location"},
additionalProperties = false
}
))
}
});
Expand All @@ -68,26 +86,35 @@ public static async Task<Assistant> CreateFunctionAssistant()
}

[TornadoTest]
public static async Task<Assistant> CreateFileSearchAssistant()
public static async Task<Assistant> CreateFileSearchAssistant(string? filePath = null)
{
VectorStoreFile vectorStoreFile = await VectorStoreDemo.CreateVectorStoreFile();
VectorStoreFile vectorStoreFile = null!;

if (string.IsNullOrWhiteSpace(filePath))
{
vectorStoreFile = await VectorStoreDemo.CreateVectorStoreFile();
}
else
{
vectorStoreFile = await VectorStoreDemo.CreateVectorStoreFile(filePath);
}

HttpCallResult<Assistant> response = await Program.Connect().Assistants.CreateAssistantAsync(
new CreateAssistantRequest(
null,
GenerateName(),
"FileSearch Demo Assistant",
"You are a helpful assistant with the ability to search files.")
"You are a helpful assistant with the ability to search info in files")
{
Tools = new List<AssistantTool>()
Tools = new List<AssistantTool>
{
new AssistantToolFileSearch()
},
ToolResources = new ToolResources()
ToolResources = new ToolResources
{
FileSearch = new FileSearchConfig()
FileSearch = new FileSearchConfig
{
FileSearchFileIds = new List<string>() {vectorStoreFile.VectorStoreId}
FileSearchFileIds = new List<string> {vectorStoreFile.VectorStoreId}
}
}
});
Expand All @@ -99,25 +126,16 @@ public static async Task<Assistant> CreateFileSearchAssistant()
[TornadoTest]
public static async Task<Assistant> CreateWithCodeInterpreter()
{
VectorStoreFile vectorStoreFile = await VectorStoreDemo.CreateVectorStoreFile();

HttpCallResult<Assistant> response = await Program.Connect().Assistants.CreateAssistantAsync(
new CreateAssistantRequest(
null,
GenerateName(),
"Code Interpreter Demo Assistant",
"You are a helpful assistant with code interpretation capabilities.")
"You are a personal math tutor. When asked a math question, write and run code to answer the question.")
{
Tools = new List<AssistantTool>()
Tools = new List<AssistantTool>
{
AssistantToolCodeInterpreter.Inst
},
ToolResources = new ToolResources()
{
CodeInterpreter = new CodeInterpreterConfig()
{
CodeInterpreterFileIds = new List<string>() {vectorStoreFile.Id}
}
}
});

Expand All @@ -128,10 +146,7 @@ public static async Task<Assistant> CreateWithCodeInterpreter()
[TornadoTest]
public static async Task<Assistant?> Retrieve()
{
if (generatedAssistant is null)
{
await Create();
}
generatedAssistant ??= await Create();

HttpCallResult<Assistant> response =
await Program.Connect().Assistants.RetrieveAssistantAsync(generatedAssistant!.Id);
Expand All @@ -142,10 +157,7 @@ public static async Task<Assistant> CreateWithCodeInterpreter()
[TornadoTest]
public static async Task<Assistant?> Modify()
{
if (generatedAssistant is null)
{
await Create();
}
generatedAssistant ??= await Create();

CreateAssistantRequest modifyRequest = new CreateAssistantRequest(generatedAssistant!)
{
Expand All @@ -161,13 +173,11 @@ public static async Task<Assistant> CreateWithCodeInterpreter()
[TornadoTest]
public static async Task<bool> Delete()
{
if (generatedAssistant is null)
{
await Create();
}
generatedAssistant ??= await Create();

HttpCallResult<bool> response = await Program.Connect().Assistants.DeleteAssistantAsync(generatedAssistant!);
Console.WriteLine(response.Response);
generatedAssistant = null;
return response.Data;
}

Expand All @@ -179,6 +189,7 @@ public static async Task DeleteAllDemoAssistants()
where assistant.Name.StartsWith("demo_assistant")
select Program.Connect().Assistants.DeleteAssistantAsync(assistant.Id)).ToList();
Console.WriteLine($"Deleting {tasks.Count} assistants...");
generatedAssistant = null;
await Task.WhenAll(tasks);
}
}
2 changes: 1 addition & 1 deletion LlmTornado.Demo/CachingDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static async Task List()

Console.WriteLine($"Listed:");

foreach (var item in listed.Data.CachedContents)
foreach (CachedContentInformation? item in listed.Data.CachedContents)
{
Console.WriteLine($"{item.Name} - {item.ExpireTime}");
}
Expand Down
4 changes: 2 additions & 2 deletions LlmTornado.Demo/ChatDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ public static async Task CrossVendorFunctionsStreamingInteractive()
{
{ "prague", "A mild rain" },
{ "tokyo", "Foggy, cloudy" },
{ "paris", "A sunny day" },
{ "paris", "A sunny day" }
};

// 3. repl
Expand Down Expand Up @@ -1691,7 +1691,7 @@ public static async Task GoogleCached()
{
type = "string",
description = "Title/headline of the entry"
},
}
},
required = new List<string> { "content", "title" }
}), true);
Expand Down
12 changes: 9 additions & 3 deletions LlmTornado.Demo/FilesDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ public static class FilesDemo
[TornadoTest]
public static async Task<TornadoFile?> Upload()
{
HttpCallResult<TornadoFile> uploadedFile = await Program.Connect().Files.Upload("Static/Files/sample.pdf", FilePurpose.Assistants);
TornadoFile? retrievedFile = await Program.Connect().Files.Get(uploadedFile.Data?.Id);
Console.WriteLine($"uploaded id: {uploadedFile.Data.Id}");
TornadoFile? uploadedFile = await Upload("Static/Files/sample.pdf", FilePurpose.Assistants);
TornadoFile? retrievedFile = await Program.Connect().Files.Get(uploadedFile?.Id);
Console.WriteLine($"uploaded id: {uploadedFile.Id}");
Console.WriteLine($"retrieved file id: {retrievedFile?.Id}");
return uploadedFile;
}

public static async Task<TornadoFile?> Upload(string path, FilePurpose purpose)
{
HttpCallResult<TornadoFile> uploadedFile = await Program.Connect().Files.Upload(path, purpose);
return uploadedFile.Data;
}

Expand Down
Loading
Loading