Skip to content

Commit

Permalink
Fix Repo
Browse files Browse the repository at this point in the history
  • Loading branch information
mili-tan committed Jun 30, 2024
1 parent 34c1b81 commit 9284a3f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Onllama.Tiny/FormRegistryInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@ public FormRegistryInfo(string tags)
InitializeComponent();
this.Text += @" - " + tags;

var model = tags;
var repo = tags;
var version = "latest";
if (tags.Contains(":"))
{
model = tags.Split(':').First();
repo = tags.Split(':').First();
version = tags.Split(':').Last();
}
if (!repo.Contains("/"))
{
repo = "library/" + repo;
}

try
{
using var httpClient = new HttpClient();
using var request = new HttpRequestMessage(new HttpMethod("GET"),
$"https://registry.ollama.ai/v2/library/{model}/manifests/{version}");
$"https://registry.ollama.ai/v2/{repo}/manifests/{version}");
request.Headers.TryAddWithoutValidation("Accept", "application/vnd.docker.distribution.manifest.v2+json");

var response = JsonNode.Parse(httpClient.SendAsync(request).Result.Content.ReadAsStringAsync().Result);
Expand All @@ -40,17 +44,17 @@ public FormRegistryInfo(string tags)
else if (layer["mediaType"].ToString() == "application/vnd.ollama.image.template")
{
inputTemplate.Text = new HttpClient().GetStringAsync(
$"https://registry.ollama.ai/v2/library/{model}/blobs/{layer["digest"]}").Result;
$"https://registry.ollama.ai/v2/{repo}/blobs/{layer["digest"]}").Result;
}
else if (layer["mediaType"].ToString() == "application/vnd.ollama.image.license")
{
inputLicense.Text = new HttpClient().GetStringAsync(
$"https://registry.ollama.ai/v2/library/{model}/blobs/{layer["digest"]}").Result;
$"https://registry.ollama.ai/v2/{repo}/blobs/{layer["digest"]}").Result;
}
else if (layer["mediaType"].ToString() == "application/vnd.ollama.image.params")
{
inputParameters.Text += new HttpClient()
.GetStringAsync($"https://registry.ollama.ai/v2/library/{model}/blobs/{layer["digest"]}")
.GetStringAsync($"https://registry.ollama.ai/v2/{repo}/blobs/{layer["digest"]}")
.Result;
}
});
Expand Down

0 comments on commit 9284a3f

Please sign in to comment.