openai

package
v0.0.0-...-fa69716 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DEFAULT_STRUCTURED_PREDICT_PROMPT = `<background>
You are a intelligent data processing engine. Your core objective is to analyze the user's request, perform reasoning and computation using logic and knowledge, and ultimately deliver the processed result in the form of a **perfectly formatted JSON object that strictly complies with the provided JSON Schema**.
</background>

<processing_instructions>
1.  **Analyze Thoroughly:** Carefully analyze the user_request to understand the user's underlying intent and all specific requirements.
2.  **Reason & Execute:** Perform all necessary reasoning, information extraction, data calculation, or logical judgment based on the request. This is your internal processing stage.
3.  **Structure the Result:** Map and populate your final result meticulously into the structure defined by the response_schema. Ensure all field names, data types, nested relationships, and constraints (e.g., required, enum) are 100% compliant.
4.  **Make Reasonable Assumptions:** For any fields required by the response_schema not explicitly specified in the request, make the most reasonable assumptions based on context and common sense (e.g., generating IDs, timestamps, or status labels).
</processing_instructions>

<output_instructions>
-   **Your final output MUST be EXCLUSIVELY a single JSON object.**
-   **You are ABSOLUTELY FORBIDDEN from adding any content outside this JSON object, including:**
    -   Explanatory text, comments (//, /* */), apologies, or greetings.
    -   Markdown code block fences (e.g., ` + "```json, ```" + `).
    -   Your internal reasoning or thought process (e.g., [THOUGHT]...).
-   The JSON object MUST be directly parsable by standard libraries (e.g., JSON.parse()) without any need for preprocessing or cleanup.
</output_instructions>

<structural_example>
### Input
[USER_REQUEST]
<The user's natural language request>

[RESPONSE_SCHEMA]
<The JSON Schema defining the structure your output MUST adhere to>

### Output
One and only one JSON object compliant with the response_schema.

</structural_example>

**Begin processing the following request.**

[USER_REQUEST]
{insert_user_request_here}

[RESPONSE_SCHEMA]
{insert_json_schema_here}
`

	DEFAULT_TOOL_USE_PROMPT = `` /* 5537-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func New

func New(host, apiKey string, model Model) providers.Client

func NewCompatible deprecated

func NewCompatible(host, apiKey string, model Model) providers.Client

Deprecated: NewCompatible is not used. Do not use for new integrations.

Types

type Embedding

type Embedding struct {
	// contains filtered or unexported fields
}

func NewEmbedding

func NewEmbedding(host, apiKey string, model Model) *Embedding

func (Embedding) Completion

func (c Embedding) Completion(ctx context.Context, request providers.Request) providers.Response

func (Embedding) CompletionNonStreaming

func (c Embedding) CompletionNonStreaming(ctx context.Context, request providers.Request) (_ string, retErr error)

func (Embedding) ContextWindow

func (c Embedding) ContextWindow() int64

func (Embedding) StructuredPredict

func (c Embedding) StructuredPredict(ctx context.Context, request providers.Request, model any) (retErr error)

func (*Embedding) Vectorization

func (o *Embedding) Vectorization(ctx context.Context, content string) ([]float64, error)

type Model

type Model struct {
	Name               string
	Temperature        *float64
	FrequencyPenalty   *float64
	PresencePenalty    *float64
	StrictMode         bool
	QPM                int64
	Proxy              string
	ContextWindow      int64
	InsecureSkipVerify bool
}

type Reasoning

type Reasoning struct {
	XMLName xml.Name `xml:"think"`
	Content string   `xml:",chardata"`
}

type ToolDefinePrompt

type ToolDefinePrompt struct {
	Tools []ToolPrompt `xml:"tools"`
}

type ToolPrompt

type ToolPrompt struct {
	Name        string `xml:"name"`
	Description string `xml:"description"`
	Arguments   string `xml:"arguments"`
}

type ToolUse

type ToolUse struct {
	XMLName   xml.Name `xml:"tool_use" json:"-"`
	ID        string   `xml:"id" json:"id"`
	Name      string   `xml:"name" json:"name"`
	Arguments string   `xml:"arguments" json:"arguments"`
	Error     string   `xml:"error" json:"error"`
	Reasoning string   `xml:"-" json:"-"`
}

type ToolUseResult

type ToolUseResult struct {
	XMLName xml.Name `xml:"tool_use_result"`
	Name    string   `xml:"name"`
	Result  string   `xml:"result"`
}

Jump to

Keyboard shortcuts

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