| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This repository contains multiple packages:
DimonSmart.AiUtils is a library designed to extract JSON strings and process structured content from responses generated by Large Language Models (LLMs). It ensures accurate extraction of both JSON data and thought processes from LLM outputs.
LLMs often produce additional text alongside the requested JSON data. This can include explanations, clarifications, or contextual information that may interfere with JSON parsing. DimonSmart.AiUtils addresses this issue by extracting only the valid JSON strings from the response, allowing for seamless integration with JSON parsers.
Extracts and returns the largest valid JSON object or array as a string from the input text.
string json = JsonExtractor.ExtractJson(responseText);Extracts all valid JSON objects or arrays from the input text.
var jsons = JsonExtractor.ExtractAllJsons(responseText);Extracts a single valid JSON fragment starting from the specified index in the text.
string json = JsonExtractor.ExtractJson(0, responseText);Extracts and separates content within <think> tags from the main response text. This is particularly useful when working with LLM responses that include both thought processes and final answers.
var result = ThinkTagParser.ExtractThinkAnswer(responseText);
string thoughts = result.Thoughts; // Combined content from all <think> tags
var segments = result.ThoughtSegments; // Individual thought segments
string answer = result.Answer; // Clean text without the think tagsExample:
var input = "Let me think about this. <think>First consider option A</think> The answer is B <think>Option B is better because...</think>";
var result = ThinkTagParser.ExtractThinkAnswer(input);
// result.Thoughts contains: "First consider option A\nOption B is better because..."
// result.ThoughtSegments == ["First consider option A", "Option B is better because..."]
// result.Answer contains: "Let me think about this. The answer is B"Install via NuGet:
dotnet add package DimonSmart.AiUtilsThis library is licensed under the 0BSD License.
| Back | FazBrowse Home | New Git URL |