mirror of
https://github.com/coalaura/whiskr.git
synced 2025-12-02 20:22:52 +00:00
image generation wip
This commit is contained in:
32
stream.go
32
stream.go
@@ -52,6 +52,19 @@ func (s *Stream) Send(ch Chunk) error {
|
||||
return WriteChunk(s.wr, s.ctx, ch)
|
||||
}
|
||||
|
||||
func StartChunk() Chunk {
|
||||
return Chunk{
|
||||
Type: "start",
|
||||
}
|
||||
}
|
||||
|
||||
func IDChunk(id string) Chunk {
|
||||
return Chunk{
|
||||
Type: "id",
|
||||
Text: id,
|
||||
}
|
||||
}
|
||||
|
||||
func ReasoningChunk(text string) Chunk {
|
||||
return Chunk{
|
||||
Type: "reason",
|
||||
@@ -73,10 +86,10 @@ func ToolChunk(tool *ToolCall) Chunk {
|
||||
}
|
||||
}
|
||||
|
||||
func IDChunk(id string) Chunk {
|
||||
func ErrorChunk(err error) Chunk {
|
||||
return Chunk{
|
||||
Type: "id",
|
||||
Text: id,
|
||||
Type: "error",
|
||||
Text: GetErrorMessage(err),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,19 +99,6 @@ func EndChunk() Chunk {
|
||||
}
|
||||
}
|
||||
|
||||
func StartChunk() Chunk {
|
||||
return Chunk{
|
||||
Type: "start",
|
||||
}
|
||||
}
|
||||
|
||||
func ErrorChunk(err error) Chunk {
|
||||
return Chunk{
|
||||
Type: "error",
|
||||
Text: GetErrorMessage(err),
|
||||
}
|
||||
}
|
||||
|
||||
func GetErrorMessage(err error) string {
|
||||
if apiErr, ok := err.(*openrouter.APIError); ok {
|
||||
return apiErr.Error()
|
||||
|
||||
Reference in New Issue
Block a user