Documentation
¶
Index ¶
- Constants
- type ChatSession
- func (c *ChatSession) ClearHistory() error
- func (c *ChatSession) GetHistory() []*genai.Content
- func (c *ChatSession) ListModels() []string
- func (c *ChatSession) ModelInfo() (string, error)
- func (c *ChatSession) SendMessage(input string) (*genai.GenerateContentResponse, error)
- func (c *ChatSession) SendMessageStream(input string) iter.Seq2[*genai.GenerateContentResponse, error]
- func (c *ChatSession) SetHistory(history []*genai.Content) error
- func (c *ChatSession) SetModel(model string) error
- func (c *ChatSession) SetSystemInstruction(systemInstruction *genai.Content) error
- type SerializableContent
- type SystemInstruction
Constants ¶
const DefaultModel = "gemini-2.5-flash"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatSession ¶
type ChatSession struct {
// contains filtered or unexported fields
}
ChatSession represents a gemini powered chat session.
func NewChatSession ¶
func NewChatSession(ctx context.Context, model string, contentConfig *genai.GenerateContentConfig) (*ChatSession, error)
NewChatSession returns a new ChatSession.
func (*ChatSession) ClearHistory ¶
func (c *ChatSession) ClearHistory() error
ClearHistory clears the chat session history.
func (*ChatSession) GetHistory ¶ added in v0.4.0
func (c *ChatSession) GetHistory() []*genai.Content
GetHistory returns the chat session history.
func (*ChatSession) ListModels ¶ added in v0.4.0
func (c *ChatSession) ListModels() []string
ListModels returns a list of the supported generative model names.
func (*ChatSession) ModelInfo ¶ added in v0.4.0
func (c *ChatSession) ModelInfo() (string, error)
ModelInfo returns information about the chat generative model in JSON format.
func (*ChatSession) SendMessage ¶
func (c *ChatSession) SendMessage(input string) (*genai.GenerateContentResponse, error)
SendMessage sends a request to the model as part of a chat session.
func (*ChatSession) SendMessageStream ¶
func (c *ChatSession) SendMessageStream(input string) iter.Seq2[*genai.GenerateContentResponse, error]
SendMessageStream is like SendMessage, but with a streaming request.
func (*ChatSession) SetHistory ¶ added in v0.4.0
func (c *ChatSession) SetHistory(history []*genai.Content) error
SetHistory sets the chat session history.
func (*ChatSession) SetModel ¶ added in v0.4.0
func (c *ChatSession) SetModel(model string) error
SetModel sets the chat generative model.
func (*ChatSession) SetSystemInstruction ¶ added in v0.5.0
func (c *ChatSession) SetSystemInstruction(systemInstruction *genai.Content) error
SetSystemInstruction sets the chat session system instruction.
type SerializableContent ¶ added in v0.4.0
type SerializableContent struct {
// Ordered parts that constitute a single message.
Parts []string
// The producer of the content. Must be either 'user' or 'model'.
Role string
}
SerializableContent is the data type containing multipart text message content. It is a serializable equivalent of genai.Content, where message content parts are represented as strings.
func NewSerializableContent ¶ added in v0.4.0
func NewSerializableContent(c *genai.Content) *SerializableContent
NewSerializableContent instantiates and returns a new SerializableContent from the given genai.Content. It will panic if the content type is not supported.
func (*SerializableContent) ToContent ¶ added in v0.4.0
func (c *SerializableContent) ToContent() *genai.Content
ToContent converts the SerializableContent into a genai.Content.
type SystemInstruction ¶ added in v0.4.0
type SystemInstruction string
SystemInstruction represents a serializable system prompt, a more forceful instruction to the language model. The model will prioritize adhering to system instructions over regular prompts.
func (SystemInstruction) ToContent ¶ added in v0.4.0
func (si SystemInstruction) ToContent() *genai.Content
ToContent converts the SystemInstruction to genai.Content.