Documentation
¶
Index ¶
- func ExtractLastMessage(messages []openai.ChatCompletionMessageParamUnion) (string, error)
- func ExtractPromptFromAnthropicMessages(messages []anthropic.MessageParam) (string, error)
- func ExtractPromptFromGeminiContents(contents []*genai.Content) (string, error)
- func ExtractToolCallsFromAnthropicMessages(messages []anthropic.MessageParam) any
- func ExtractToolCallsFromGeminiContents(contents []*genai.Content) *genai.Part
- func ExtractToolCallsFromLastMessage(messages []openai.ChatCompletionMessageParamUnion) any
- func FindLastUserMessage(messages []openai.ChatCompletionMessageParamUnion) (string, error)
- func Get() *bytebufferpool.ByteBuffer
- func ParseProviderModel(modelSpec string) (provider, model string, err error)
- func ParseProviderModelWithDefault(modelSpec, defaultProvider string) (provider, model string, err error)
- func Put(buf *bytebufferpool.ByteBuffer)
- type BufferPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractLastMessage ¶
func ExtractLastMessage(messages []openai.ChatCompletionMessageParamUnion) (string, error)
ExtractLastMessage extracts content from the last message for cache key generation. This supports all message roles (user, assistant, system, developer, tool).
func ExtractPromptFromAnthropicMessages ¶
func ExtractPromptFromAnthropicMessages(messages []anthropic.MessageParam) (string, error)
ExtractPromptFromAnthropicMessages extracts the prompt text from Anthropic MessageParam array for routing decisions Gets the last user message with text content
func ExtractPromptFromGeminiContents ¶
ExtractPromptFromGeminiContents extracts the prompt text from Gemini Content array for routing decisions Intelligently processes different part types and combines them into a coherent prompt
func ExtractToolCallsFromAnthropicMessages ¶
func ExtractToolCallsFromAnthropicMessages(messages []anthropic.MessageParam) any
ExtractToolCallsFromAnthropicMessages extracts tool calls from the last message if it's an assistant message.
func ExtractToolCallsFromGeminiContents ¶
ExtractToolCallsFromGeminiContents extracts tool calls from the last content if it's a model content
func ExtractToolCallsFromLastMessage ¶
func ExtractToolCallsFromLastMessage(messages []openai.ChatCompletionMessageParamUnion) any
ExtractToolCallsFromLastMessage extracts tool calls from the last message if it's an assistant message.
func FindLastUserMessage ¶
func FindLastUserMessage(messages []openai.ChatCompletionMessageParamUnion) (string, error)
FindLastUserMessage safely finds the last user message in a conversation.
func Get ¶
func Get() *bytebufferpool.ByteBuffer
Get is a convenience function that uses the global pool
func ParseProviderModel ¶
ParseProviderModel parses a model specification in "provider:model" format. This function is strict - it requires exact format and will error if not correct. Examples:
- "openai:gpt-4" -> ("openai", "gpt-4", nil)
- "anthropic:claude-3-5-sonnet-20241022" -> ("anthropic", "claude-3-5-sonnet-20241022", nil)
- "gpt-4" -> error (no provider specified)
- "openai:" -> error (empty model)
- ":gpt-4" -> error (empty provider)
- "openai:gpt-4:extra" -> error (too many parts)
func ParseProviderModelWithDefault ¶
func ParseProviderModelWithDefault(modelSpec, defaultProvider string) (provider, model string, err error)
ParseProviderModelWithDefault parses a model specification, using defaultProvider if no provider is specified. This is less strict than ParseProviderModel - it allows model-only specifications. Examples:
- "openai:gpt-4" -> ("openai", "gpt-4", nil)
- "gpt-4" with defaultProvider="openai" -> ("openai", "gpt-4", nil)
- "anthropic:" -> error (empty model)
- ":gpt-4" -> error (empty provider)
func Put ¶
func Put(buf *bytebufferpool.ByteBuffer)
Put is a convenience function that uses the global pool
Types ¶
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool provides efficient buffer pooling for streaming operations Uses bytebufferpool for automatic size-class management and anti-fragmentation
func (*BufferPool) Get ¶
func (bp *BufferPool) Get() *bytebufferpool.ByteBuffer
Get retrieves a buffer from the pool
func (*BufferPool) Put ¶
func (bp *BufferPool) Put(buf *bytebufferpool.ByteBuffer)
Put returns a buffer to the pool