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

Add JsonSchema #150

Merged
merged 2 commits into from
Dec 9, 2024
Merged

Add JsonSchema #150

merged 2 commits into from
Dec 9, 2024

Conversation

mili-tan
Copy link
Contributor

@mili-tan mili-tan commented Dec 6, 2024

No description provided.

@awaescher
Copy link
Owner

Looks really awesome, but would you elaborate for noobs like me?

@mili-tan
Copy link
Contributor Author

mili-tan commented Dec 6, 2024

https://github.com/ollama/ollama/releases/tag/v0.5.0

Here's some new things added to Ollama 0.5, and maybe something like this:

public class Country()
{
	public string Name { get; set; }
	public string Capital { get; set; }
	public List<string> Languages { get; set; }
}

var ollama = new OllamaApiClient("http://localhost:11434");
ollama.SelectedModel = "llama3.1";

await foreach(var res in ollama.GenerateAsync(new GenerateRequest()
         {
	         Prompt = "Tell me about Canada.",
	         Format = JsonSchema.ToJsonSchema(typeof(Country)),
	         Stream = false
         }))
	Console.WriteLine(res.Response);

//{ "Capital": "Ottawa", "Languages": [ "English", "French" ], "Name": "Canada" }

@awaescher
Copy link
Owner

Holy moly, I totally missed this announcement. Did you try it successfully yet?

@mili-tan
Copy link
Contributor Author

mili-tan commented Dec 7, 2024

I think it works, for me.

@awaescher awaescher merged commit 23f0d32 into awaescher:main Dec 9, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants