Skip to content

Commit 2a01d3b

Browse files
Added support for Perplexity (#545)
Co-authored-by: Thorsten Sommer <[email protected]>
1 parent adf61a1 commit 2a01d3b

39 files changed

+398
-39
lines changed

app/MindWork AI Studio/Assistants/I18N/allTexts.lua

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,9 @@ UI_TEXT_CONTENT["AISTUDIO::CHAT::CONTENTBLOCKCOMPONENT::T1603883875"] = "Yes, re
13331333
-- Yes, remove it
13341334
UI_TEXT_CONTENT["AISTUDIO::CHAT::CONTENTBLOCKCOMPONENT::T1820166585"] = "Yes, remove it"
13351335

1336+
-- Number of sources
1337+
UI_TEXT_CONTENT["AISTUDIO::CHAT::CONTENTBLOCKCOMPONENT::T1848978959"] = "Number of sources"
1338+
13361339
-- Do you really want to edit this message? In order to edit this message, the AI response will be deleted.
13371340
UI_TEXT_CONTENT["AISTUDIO::CHAT::CONTENTBLOCKCOMPONENT::T2018431076"] = "Do you really want to edit this message? In order to edit this message, the AI response will be deleted."
13381341

@@ -4615,6 +4618,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T1702902297"] = "Introduction"
46154618
-- Vision
46164619
UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T1892426825"] = "Vision"
46174620

4621+
-- You are not tied to any single provider. Instead, you might choose the provider that best suits your needs. Right now, we support OpenAI (GPT5, o1, etc.), Perplexity, Mistral, Anthropic (Claude), Google Gemini, xAI (Grok), DeepSeek, Alibaba Cloud (Qwen), Hugging Face, and self-hosted models using vLLM, llama.cpp, ollama, LM Studio, Groq, or Fireworks. For scientists and employees of research institutions, we also support Helmholtz and GWDG AI services. These are available through federated logins like eduGAIN to all 18 Helmholtz Centers, the Max Planck Society, most German, and many international universities.
4622+
UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T2183503084"] = "You are not tied to any single provider. Instead, you might choose the provider that best suits your needs. Right now, we support OpenAI (GPT5, o1, etc.), Perplexity, Mistral, Anthropic (Claude), Google Gemini, xAI (Grok), DeepSeek, Alibaba Cloud (Qwen), Hugging Face, and self-hosted models using vLLM, llama.cpp, ollama, LM Studio, Groq, or Fireworks. For scientists and employees of research institutions, we also support Helmholtz and GWDG AI services. These are available through federated logins like eduGAIN to all 18 Helmholtz Centers, the Max Planck Society, most German, and many international universities."
4623+
46184624
-- Let's get started
46194625
UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T2331588413"] = "Let's get started"
46204626

@@ -4624,9 +4630,6 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T2348849647"] = "Last Changelog"
46244630
-- Choose the provider and model best suited for your current task.
46254631
UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T2588488920"] = "Choose the provider and model best suited for your current task."
46264632

4627-
-- You are not tied to any single provider. Instead, you might choose the provider that best suits your needs. Right now, we support OpenAI (GPT4o, o1, etc.), Mistral, Anthropic (Claude), Google Gemini, xAI (Grok), DeepSeek, Alibaba Cloud (Qwen), Hugging Face, and self-hosted models using vLLM, llama.cpp, ollama, LM Studio, Groq, or Fireworks. For scientists and employees of research institutions, we also support Helmholtz and GWDG AI services. These are available through federated logins like eduGAIN to all 18 Helmholtz Centers, the Max Planck Society, most German, and many international universities.
4628-
UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T2900280782"] = "You are not tied to any single provider. Instead, you might choose the provider that best suits your needs. Right now, we support OpenAI (GPT4o, o1, etc.), Mistral, Anthropic (Claude), Google Gemini, xAI (Grok), DeepSeek, Alibaba Cloud (Qwen), Hugging Face, and self-hosted models using vLLM, llama.cpp, ollama, LM Studio, Groq, or Fireworks. For scientists and employees of research institutions, we also support Helmholtz and GWDG AI services. These are available through federated logins like eduGAIN to all 18 Helmholtz Centers, the Max Planck Society, most German, and many international universities."
4629-
46304633
-- Quick Start Guide
46314634
UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T3002014720"] = "Quick Start Guide"
46324635

@@ -4861,6 +4864,9 @@ UI_TEXT_CONTENT["AISTUDIO::PROVIDER::LLMPROVIDERSEXTENSIONS::T3424652889"] = "Un
48614864
-- no model selected
48624865
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::MODEL::T2234274832"] = "no model selected"
48634866

4867+
-- Sources
4868+
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::SOURCEEXTENSIONS::T2730980305"] = "Sources"
4869+
48644870
-- Use no chat template
48654871
UI_TEXT_CONTENT["AISTUDIO::SETTINGS::CHATTEMPLATE::T4258819635"] = "Use no chat template"
48664872

app/MindWork AI Studio/Chat/ContentBlockComponent.razor

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@using AIStudio.Tools
22
@using MudBlazor
33
@using AIStudio.Components
4+
@using AIStudio.Provider
45
@inherits AIStudio.Components.MSGComponentBase
56
<MudCard Class="@this.CardClasses" Outlined="@true">
67
<MudCardHeader>
@@ -15,6 +16,14 @@
1516
</MudText>
1617
</CardHeaderContent>
1718
<CardHeaderActions>
19+
@if (this.Content.Sources.Count > 0)
20+
{
21+
<MudTooltip Text="@T("Number of sources")" Placement="Placement.Bottom">
22+
<MudBadge Content="@this.Content.Sources.Count" Color="Color.Primary" Overlap="true" BadgeClass="sources-card-header">
23+
<MudIconButton Icon="@Icons.Material.Filled.Link" />
24+
</MudBadge>
25+
</MudTooltip>
26+
}
1827
@if (this.IsSecondToLastBlock && this.Role is ChatRole.USER && this.EditLastUserBlockFunc is not null)
1928
{
2029
<MudTooltip Text="@T("Edit")" Placement="Placement.Bottom">
@@ -72,6 +81,10 @@
7281
else
7382
{
7483
<MudMarkdown Value="@textContent.Text.RemoveThinkTags().Trim()" Props="Markdown.DefaultConfig" Styling="@this.MarkdownStyling" />
84+
@if (textContent.Sources.Count > 0)
85+
{
86+
<MudMarkdown Value="@textContent.Sources.ToMarkdown()" Props="Markdown.DefaultConfig" Styling="@this.MarkdownStyling" />
87+
}
7588
}
7689
}
7790
}

app/MindWork AI Studio/Chat/ContentImage.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public sealed class ContentImage : IContent, IImageSource
2727
[JsonIgnore]
2828
public Func<Task> StreamingEvent { get; set; } = () => Task.CompletedTask;
2929

30+
/// <inheritdoc />
31+
public List<Source> Sources { get; set; } = [];
32+
3033
/// <inheritdoc />
3134
public Task<ChatThread> CreateFromProviderAsync(IProvider provider, Model chatModel, IContent? lastPrompt, ChatThread? chatChatThread, CancellationToken token = default)
3235
{

app/MindWork AI Studio/Chat/ContentText.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public sealed class ContentText : IContent
2424
public bool InitialRemoteWait { get; set; }
2525

2626
/// <inheritdoc />
27-
// [JsonIgnore]
27+
[JsonIgnore]
2828
public bool IsStreaming { get; set; }
2929

3030
/// <inheritdoc />
@@ -35,6 +35,9 @@ public sealed class ContentText : IContent
3535
[JsonIgnore]
3636
public Func<Task> StreamingEvent { get; set; } = () => Task.CompletedTask;
3737

38+
/// <inheritdoc />
39+
public List<Source> Sources { get; set; } = [];
40+
3841
/// <inheritdoc />
3942
public async Task<ChatThread> CreateFromProviderAsync(IProvider provider, Model chatModel, IContent? lastPrompt, ChatThread? chatThread, CancellationToken token = default)
4043
{
@@ -80,7 +83,7 @@ await Task.Run(async () =>
8083
this.InitialRemoteWait = true;
8184

8285
// Iterate over the responses from the AI:
83-
await foreach (var deltaText in provider.StreamChatCompletion(chatModel, chatThread, settings, token))
86+
await foreach (var contentStreamChunk in provider.StreamChatCompletion(chatModel, chatThread, settings, token))
8487
{
8588
// When the user cancels the request, we stop the loop:
8689
if (token.IsCancellationRequested)
@@ -91,7 +94,10 @@ await Task.Run(async () =>
9194
this.IsStreaming = true;
9295

9396
// Add the response to the text:
94-
this.Text += deltaText;
97+
this.Text += contentStreamChunk;
98+
99+
// Merge the sources:
100+
this.Sources.MergeSources(contentStreamChunk.Sources);
95101

96102
// Notify the UI that the content has changed,
97103
// depending on the energy saving mode:

app/MindWork AI Studio/Chat/IContent.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ public interface IContent
3737
/// </summary>
3838
[JsonIgnore]
3939
public Func<Task> StreamingDone { get; set; }
40+
41+
/// <summary>
42+
/// The provided sources, if any.
43+
/// </summary>
44+
[JsonIgnore]
45+
public List<Source> Sources { get; set; }
4046

4147
/// <summary>
4248
/// Uses the provider to create the content.

app/MindWork AI Studio/Dialogs/ProviderDialog.razor.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,13 @@ private AIStudio.Settings.Provider CreateProviderSettings()
126126
Id = this.DataId,
127127
InstanceName = this.DataInstanceName,
128128
UsedLLMProvider = this.DataLLMProvider,
129+
129130
Model = this.DataLLMProvider switch
130131
{
131-
LLMProviders.FIREWORKS => new Model(this.dataManuallyModel, null),
132-
LLMProviders.HUGGINGFACE => new Model(this.dataManuallyModel, null),
132+
LLMProviders.FIREWORKS or LLMProviders.HUGGINGFACE => new Model(this.dataManuallyModel, null),
133133
_ => this.DataModel
134134
},
135+
135136
IsSelfHosted = this.DataLLMProvider is LLMProviders.SELF_HOSTED,
136137
IsEnterpriseConfiguration = false,
137138
Hostname = cleanedHostname.EndsWith('/') ? cleanedHostname[..^1] : cleanedHostname,
@@ -158,7 +159,7 @@ protected override async Task OnInitializedAsync()
158159
this.dataEditingPreviousInstanceName = this.DataInstanceName.ToLowerInvariant();
159160

160161
// When using Fireworks or Hugging Face, we must copy the model name:
161-
if (this.DataLLMProvider is LLMProviders.FIREWORKS or LLMProviders.HUGGINGFACE)
162+
if (this.DataLLMProvider.IsLLMModelProvidedManually())
162163
this.dataManuallyModel = this.DataModel.Id;
163164

164165
//
@@ -241,7 +242,7 @@ private async Task Store()
241242

242243
private string? ValidateManuallyModel(string manuallyModel)
243244
{
244-
if ((this.DataLLMProvider is LLMProviders.FIREWORKS or LLMProviders.HUGGINGFACE) && string.IsNullOrWhiteSpace(manuallyModel))
245+
if (this.DataLLMProvider.IsLLMModelProvidedManually() && string.IsNullOrWhiteSpace(manuallyModel))
245246
return T("Please enter a model name.");
246247

247248
return null;

app/MindWork AI Studio/Pages/Home.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private void InitializeAdvantagesItems()
3131
{
3232
this.itemsAdvantages = [
3333
new(this.T("Free of charge"), this.T("The app is free to use, both for personal and commercial purposes.")),
34-
new(this.T("Independence"), this.T("You are not tied to any single provider. Instead, you might choose the provider that best suits your needs. Right now, we support OpenAI (GPT4o, o1, etc.), Mistral, Anthropic (Claude), Google Gemini, xAI (Grok), DeepSeek, Alibaba Cloud (Qwen), Hugging Face, and self-hosted models using vLLM, llama.cpp, ollama, LM Studio, Groq, or Fireworks. For scientists and employees of research institutions, we also support Helmholtz and GWDG AI services. These are available through federated logins like eduGAIN to all 18 Helmholtz Centers, the Max Planck Society, most German, and many international universities.")),
34+
new(this.T("Independence"), this.T("You are not tied to any single provider. Instead, you might choose the provider that best suits your needs. Right now, we support OpenAI (GPT5, o1, etc.), Perplexity, Mistral, Anthropic (Claude), Google Gemini, xAI (Grok), DeepSeek, Alibaba Cloud (Qwen), Hugging Face, and self-hosted models using vLLM, llama.cpp, ollama, LM Studio, Groq, or Fireworks. For scientists and employees of research institutions, we also support Helmholtz and GWDG AI services. These are available through federated logins like eduGAIN to all 18 Helmholtz Centers, the Max Planck Society, most German, and many international universities.")),
3535
new(this.T("Assistants"), this.T("You just want to quickly translate a text? AI Studio has so-called assistants for such and other tasks. No prompting is necessary when working with these assistants.")),
3636
new(this.T("Unrestricted usage"), this.T("Unlike services like ChatGPT, which impose limits after intensive use, MindWork AI Studio offers unlimited usage through the providers API.")),
3737
new(this.T("Cost-effective"), this.T("You only pay for what you use, which can be cheaper than monthly subscription services like ChatGPT Plus, especially if used infrequently. But beware, here be dragons: For extremely intensive usage, the API costs can be significantly higher. Unfortunately, providers currently do not offer a way to display current costs in the app. Therefore, check your account with the respective provider to see how your costs are developing. When available, use prepaid and set a cost limit.")),

app/MindWork AI Studio/Plugins/languages/de-de-43065dbc-78d0-45b7-92be-f14c2926e2dc/plugin.lua

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,9 @@ UI_TEXT_CONTENT["AISTUDIO::CHAT::CONTENTBLOCKCOMPONENT::T1603883875"] = "Ja, neu
13351335
-- Yes, remove it
13361336
UI_TEXT_CONTENT["AISTUDIO::CHAT::CONTENTBLOCKCOMPONENT::T1820166585"] = "Ja, entferne es"
13371337

1338+
-- Number of sources
1339+
UI_TEXT_CONTENT["AISTUDIO::CHAT::CONTENTBLOCKCOMPONENT::T1848978959"] = "Anzahl der Quellen"
1340+
13381341
-- Do you really want to edit this message? In order to edit this message, the AI response will be deleted.
13391342
UI_TEXT_CONTENT["AISTUDIO::CHAT::CONTENTBLOCKCOMPONENT::T2018431076"] = "Möchten Sie diese Nachricht wirklich bearbeiten? Um die Nachricht zu bearbeiten, wird die Antwort der KI gelöscht."
13401343

@@ -4617,6 +4620,9 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T1702902297"] = "Einführung"
46174620
-- Vision
46184621
UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T1892426825"] = "Vision"
46194622

4623+
-- You are not tied to any single provider. Instead, you might choose the provider that best suits your needs. Right now, we support OpenAI (GPT5, o1, etc.), Perplexity, Mistral, Anthropic (Claude), Google Gemini, xAI (Grok), DeepSeek, Alibaba Cloud (Qwen), Hugging Face, and self-hosted models using vLLM, llama.cpp, ollama, LM Studio, Groq, or Fireworks. For scientists and employees of research institutions, we also support Helmholtz and GWDG AI services. These are available through federated logins like eduGAIN to all 18 Helmholtz Centers, the Max Planck Society, most German, and many international universities.
4624+
UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T2183503084"] = "Sie sind an keinen einzelnen Anbieter gebunden. Stattdessen können Sie den Anbieter wählen, der am besten zu ihren Bedürfnissen passt. Derzeit unterstützen wir OpenAI (GPT5, o1, etc.), Perplexity, Mistral, Anthropic (Claude), Google Gemini, xAI (Grok), DeepSeek, Alibaba Cloud (Qwen), Hugging Face und selbst gehostete Modelle mit vLLM, llama.cpp, ollama, LM Studio, Groq oder Fireworks. Für Wissenschaftler und Mitarbeiter von Forschungseinrichtungen unterstützen wir auch die KI-Dienste von Helmholtz und GWDG. Diese sind über föderierte Anmeldungen wie eduGAIN für alle 18 Helmholtz-Zentren, die Max-Planck-Gesellschaft, die meisten deutschen und viele internationale Universitäten verfügbar."
4625+
46204626
-- Let's get started
46214627
UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T2331588413"] = "Los geht's"
46224628

@@ -4626,9 +4632,6 @@ UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T2348849647"] = "Letztes Änderungsproto
46264632
-- Choose the provider and model best suited for your current task.
46274633
UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T2588488920"] = "Wählen Sie den Anbieter und das Modell aus, die am besten zu ihrer aktuellen Aufgabe passen."
46284634

4629-
-- You are not tied to any single provider. Instead, you might choose the provider that best suits your needs. Right now, we support OpenAI (GPT5, o1, etc.), Mistral, Anthropic (Claude), Google Gemini, xAI (Grok), DeepSeek, Alibaba Cloud (Qwen), Hugging Face, and self-hosted models using vLLM, llama.cpp, ollama, LM Studio, Groq, or Fireworks. For scientists and employees of research institutions, we also support Helmholtz and GWDG AI services. These are available through federated logins like eduGAIN to all 18 Helmholtz Centers, the Max Planck Society, most German, and many international universities.
4630-
UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T2900280782"] = "Sie sind an keinen einzelnen Anbieter gebunden. Stattdessen können Sie den Anbieter wählen, der am besten zu ihren Bedürfnissen passt. Derzeit unterstützen wir OpenAI (GPT5, o1, etc.), Mistral, Anthropic (Claude), Google Gemini, xAI (Grok), DeepSeek, Alibaba Cloud (Qwen), Hugging Face und selbst gehostete Modelle mit vLLM, llama.cpp, ollama, LM Studio, Groq oder Fireworks. Für Wissenschaftler und Mitarbeiter von Forschungseinrichtungen unterstützen wir auch die KI-Dienste von Helmholtz und GWDG. Diese sind über föderierte Anmeldungen wie eduGAIN für alle 18 Helmholtz-Zentren, die Max-Planck-Gesellschaft, die meisten deutschen und viele internationale Universitäten verfügbar."
4631-
46324635
-- Quick Start Guide
46334636
UI_TEXT_CONTENT["AISTUDIO::PAGES::HOME::T3002014720"] = "Schnellstart-Anleitung"
46344637

@@ -4863,6 +4866,9 @@ UI_TEXT_CONTENT["AISTUDIO::PROVIDER::LLMPROVIDERSEXTENSIONS::T3424652889"] = "Un
48634866
-- no model selected
48644867
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::MODEL::T2234274832"] = "Kein Modell ausgewählt"
48654868

4869+
-- Sources
4870+
UI_TEXT_CONTENT["AISTUDIO::PROVIDER::SOURCEEXTENSIONS::T2730980305"] = "Quellen"
4871+
48664872
-- Use no chat template
48674873
UI_TEXT_CONTENT["AISTUDIO::SETTINGS::CHATTEMPLATE::T4258819635"] = "Keine Chat-Vorlage verwenden"
48684874

0 commit comments

Comments
 (0)