More work
This commit is contained in:
1 parent
c06f06c6ce
commit
8b476e6939
20 files changed
+871
-22
No files matched your search
@@ -0,0 +1,24 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace PaperlessAI.Models;
|
||||
|
||||
public class Configuration(IConfiguration config)
|
||||
{
|
||||
public string Model { get; set; } = config["LlmAgent:Model"] ?? throw new InvalidOperationException("Configuration not found \"LlmAgent:Model\"");
|
||||
public string McpServer { get; set; } = config["LlmAgent:McpServer"] ?? throw new InvalidOperationException("Configuration not found \"LlmAgent:McpServer\"");
|
||||
public int ContextLength { get; set; } = int.Parse(config["LlmAgent:ContextLength"] ?? throw new InvalidOperationException("Configuration not found \"LlmAgent:ContextLength\""));
|
||||
public int max_output_tokens { get; set; } = int.Parse(config["LlmAgent:MaxOutputTokens"] ?? throw new InvalidOperationException("Configuration not found \"LlmAgent:MaxOutputTokens\""));
|
||||
public double Temperature { get; set; } = double.Parse(config["LlmAgent:Temperature"] ?? throw new InvalidOperationException("Configuration not found \"LlmAgent:Temperature\""), CultureInfo.InvariantCulture);
|
||||
public double TopP { get; set; } = double.Parse(config["LlmAgent:TopP"] ?? throw new InvalidOperationException("Configuration not found \"LlmAgent:TopP\""), CultureInfo.InvariantCulture);
|
||||
public string Reasoning { get; set; } = config["LlmAgent:Reasoning"] ?? throw new InvalidOperationException("Configuration not found \"LlmAgent:Reasoning\"");
|
||||
public int TimeoutSeconds { get; set; } = int.Parse(config["LlmAgent:TimeoutSeconds"] ?? throw new InvalidOperationException("Configuration not found \"LlmAgent:TimeoutSeconds\""));
|
||||
public List<string> IntegrationsList { get; set; } = new List<string>() { config["LlmAgent:McpServer"] ?? throw new InvalidOperationException("Configuration not found \"LlmAgent:McpServer\"") };
|
||||
|
||||
public int CheckDocumentsToProcessJobPeriodSeconds { get; set; } = int.Parse(config["Settings:CheckDocumentsToProcessJobPeriodSeconds"] ?? throw new InvalidOperationException("Configuration not found \"Settings:CheckDocumentsToProcessJobPeriodSeconds\""));
|
||||
|
||||
|
||||
public string SystemPrompt { get; set; } = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "Prompts", "llm-system-prompt.txt")) ?? throw new InvalidOperationException("File \"SystemPrompt\" not found.");
|
||||
public string Prompt { get; set; } = File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "Prompts", "llm-prompt.txt")) ?? throw new InvalidOperationException("File \"Prompt\" not found.");
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
public class LmStudioChatRequest
|
||||
{
|
||||
[JsonPropertyName("model")]
|
||||
public required string Model { get; set; }
|
||||
|
||||
[JsonPropertyName("system_prompt")]
|
||||
public string? SystemPrompt { get; set; }
|
||||
|
||||
[JsonPropertyName("input")]
|
||||
public required string Input { get; set; }
|
||||
|
||||
[JsonPropertyName("integrations")]
|
||||
public List<string>? Integrations { get; set; }
|
||||
|
||||
[JsonPropertyName("reasoning")]
|
||||
public string? Reasoning { get; set; }
|
||||
|
||||
[JsonPropertyName("temperature")]
|
||||
public double Temperature { get; set; }
|
||||
|
||||
[JsonPropertyName("top_p")]
|
||||
public double TopP { get; set; }
|
||||
|
||||
[JsonPropertyName("context_length")]
|
||||
public int ContextLength { get; set; }
|
||||
|
||||
[JsonPropertyName("max_output_tokens")]
|
||||
public int MaxOutputTokens { get; set; }
|
||||
|
||||
[JsonPropertyName("store")]
|
||||
public bool Store { get; set; } = true;
|
||||
|
||||
[JsonPropertyName("stream")]
|
||||
public bool Stream { get; set; } = false;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PaperlessAI.Models.LMStudio;
|
||||
|
||||
public class LmStudioChatResponse
|
||||
{
|
||||
[JsonProperty("model_instance_id")]
|
||||
public string? ModelInstanceId { get; set; }
|
||||
|
||||
[JsonProperty("output")]
|
||||
List<LmStudioChatResponseOutput>? Outputs { get; set; }
|
||||
|
||||
public List<LmStudioChatResponseOutput>? GetOutputsByResponseType(string responseType)
|
||||
{
|
||||
return Outputs?.Where(x => x.Type?.ToUpper() == responseType.ToUpper()).ToList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PaperlessAI.Models.LMStudio;
|
||||
|
||||
public class LmStudioChatResponseOutput
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public string? Type { get; set; }
|
||||
|
||||
[JsonProperty("tool")]
|
||||
public string? Tool { get; set; }
|
||||
|
||||
[JsonProperty("content")]
|
||||
public string? Content { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace PaperlessAI.Models.LMStudio;
|
||||
|
||||
public class LmStudioLlmResponse
|
||||
{
|
||||
[JsonProperty("document_Id")]
|
||||
public long DocumentId { get; set; } = -1;
|
||||
|
||||
[JsonProperty("success")]
|
||||
public bool Success { get; set; } = false;
|
||||
|
||||
[JsonProperty("message")]
|
||||
public string Message { get; set; } = string.Empty;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
}
|
||||
|
||||
public bool IsValid => !string.IsNullOrWhiteSpace(Message) && DocumentId != -1;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace PaperlessAI.Models.LMStudio;
|
||||
|
||||
public class LmStudioUnloadModel
|
||||
{
|
||||
[JsonPropertyName("instance_id")]
|
||||
public required string InstanceId { get; set; }
|
||||
}
|
||||
@@ -6,7 +6,8 @@ public class PaperlessDocument
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public long DocumentId { get; set; }
|
||||
public EOperationState DocumentState { get; set; } = EOperationState.Created;
|
||||
public EDocumentState DocumentState { get; set; } = EDocumentState.Created;
|
||||
public string LastLlmMessage { get; set; } = string.Empty;
|
||||
public DateTimeOffset CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTimeOffset ModifiedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
@@ -21,9 +22,18 @@ public class PaperlessDocument
|
||||
return paperlessDocument;
|
||||
}
|
||||
|
||||
public void SetDocumentState(EDocumentState documentState)
|
||||
{
|
||||
DocumentState = documentState;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Id: {Id}, DocumentId: {DocumentId}";
|
||||
}
|
||||
|
||||
internal void SetLastLlmMessage(string message)
|
||||
{
|
||||
LastLlmMessage = message;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user