llmutil

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package llmutil holds small helpers shared between LLM-calling code paths.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanLLMResponse

func CleanLLMResponse(response string) string

CleanLLMResponse strips reasoning/thinking blocks and markdown code fences from a raw LLM response so the remaining text is ready for JSON parsing.

Thinking blocks:

  • <think>...</think>: both tags present; everything between is removed
  • ...</think>: orphan closer; everything before it is removed too

Markdown fences: a leading ```lang\n and a trailing ``` are stripped if present. This handles the common "```json\n{...}\n```" wrapping.

func ExtractJSON

func ExtractJSON(response string) string

ExtractJSON is a last-resort fallback used after CleanLLMResponse + json.Unmarshal fail: it returns the substring from the first '{' to the last '}', or the input unchanged if no braces are found.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL