Skip to content

Instantly share code, notes, and snippets.

- task: SonarQubePrepare@6
inputs:
SonarQube: 'SonarQubeEndpoint-SNapp2'
scannerMode: 'MSBuild'
projectKey: 'SNapp2_SNapp2_c81c7b03-1b40-4b55-bcd0-5ad7541f2cb6'
projectName: 'SNapp2SonarQube'
//Check the latest message to see if a tool was called
foreach (var toolCall in chat.Messages.Last().ToolCalls)
{
if (toolCall.Function.Name == nameof(GetWeather))
Console.WriteLine(GetWeather(toolCall.Function.Arguments["location"], toolCall.Function.Arguments["format"]));
}
var uri = new Uri("http://localhost:11434"); //Default Ollama endpoint
var ollama = new OllamaApiClient(uri);
ollama.SelectedModel = "llama3.1:latest";
string GetWeather(string location, string format)
{
//Call the weather API here
return $"The weather in {location} is 25 degrees {format}";
}
var tool = new Tool()
{
Function = new Function
{
Description = "Get the current weather for a location",
Name = "GetWeather",
Parameters = new Parameters
{
Properties = new Dictionary<string, Properties>
{
var chat = new Chat(ollama);
while (true)
{
Console.Write("User>");
var message = Console.ReadLine();
Console.Write("Assistant>");
await foreach (var answerToken in chat.Send(message))
Console.Write(answerToken);
Console.WriteLine();
}
using OllamaSharp;
var uri = new Uri("http://localhost:11434"); //Default Ollama endpoint
var ollama = new OllamaApiClient(uri);
ollama.SelectedModel = "phi3.5:latest";
#if PLATTELANDSLOKET
public Guid Id { get; init; }
#else
public int Id { get; init; }
#endif
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>$(DefineConstants);PLATTELANDSLOKET</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>$(DefineConstants);PLATTELANDSLOKET</DefineConstants>
</PropertyGroup>
@wullemsb
wullemsb / InCode.cs
Last active September 20, 2024 12:31
#define PLATTELANDSLOKET
#if PLATTELANDSLOKET
public Guid Id { get; init; }
#else
public int Id { get; init; }
#endif
class Program
{
static void Main(string[] args)
{
#if DEBUG
Console.WriteLine("Debug mode is enabled.");
#else
Console.WriteLine("Release mode. Go go go!");
#endif
}