Skip to content

Commit

Permalink
Merge pull request #56 from milbk/main
Browse files Browse the repository at this point in the history
  • Loading branch information
awaescher authored Jul 28, 2024
2 parents 99b43a8 + a58f33c commit 9488506
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
42 changes: 41 additions & 1 deletion src/Models/Chat/ChatRequest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using static OllamaSharp.Models.Chat.Message;

namespace OllamaSharp.Models.Chat;

Expand Down Expand Up @@ -53,4 +54,43 @@ public class ChatRequest
/// </summary>
[JsonPropertyName("stream")]
public bool Stream { get; set; } = true;
}

/// <summary>
/// Tools for the model to use if supported. Requires stream to be set to false.
/// </summary>
[JsonPropertyName("tools")]
public List<Tool>? Tools { get; set; }
}

public class Tool
{
[JsonPropertyName("type")]
public string? Type { get; set; }

[JsonPropertyName("function")]
public Function? Function { get; set; }
}

public class Function
{
[JsonPropertyName("name")]
public string? Name { get; set; }

[JsonPropertyName("description")]
public string? Description { get; set; }

[JsonPropertyName("parameters")]
public Dictionary<string, Parameter>? Parameters { get; set; }
}

public class Parameter
{
[JsonPropertyName("type")]
public string? Type { get; set; }

[JsonPropertyName("description")]
public string? Description { get; set; }

[JsonPropertyName("enum")]
public List<string>? Enum { get; set; }
}
22 changes: 22 additions & 0 deletions src/Models/Chat/Message.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Text.Json.Serialization;

Expand Down Expand Up @@ -50,4 +51,25 @@ public Message()
/// </summary>
[JsonPropertyName("images")]
public string[]? Images { get; set; }

/// <summary>
/// A list of tools the model wants to use (for models that support function calls, such as llama3.1)
/// </summary>
[JsonPropertyName("tool_calls")]
public List<ToolCall>? ToolCalls { get; set; }

public class ToolCall
{
[JsonPropertyName("function")]
public Function? Function { get; set; }
}

public class Function
{
[JsonPropertyName("name")]
public string? Name { get; set; }

[JsonPropertyName("arguments")]
public Dictionary<string, string>? Arguments { get; set; }
}
}

0 comments on commit 9488506

Please sign in to comment.