-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#163: Changed a way to interact with clients to let clients manage re…
…sponseChunk channels. The channel can contain both success and error messages/chunks. Separated stream and sync chat schemas
- Loading branch information
1 parent
9657416
commit 548ea18
Showing
14 changed files
with
243 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package schemas | ||
|
||
// ChatStreamRequest defines a message that requests a new streaming chat | ||
type ChatStreamRequest struct { | ||
// TODO: implement | ||
} | ||
|
||
// ChatStreamChunk defines a message for a chunk of streaming chat response | ||
type ChatStreamChunk struct { | ||
// TODO: modify according to the streaming chat needs | ||
ID string `json:"id,omitempty"` | ||
Created int `json:"created,omitempty"` | ||
Provider string `json:"provider,omitempty"` | ||
RouterID string `json:"router,omitempty"` | ||
ModelID string `json:"model_id,omitempty"` | ||
ModelName string `json:"model,omitempty"` | ||
Cached bool `json:"cached,omitempty"` | ||
ModelResponse ModelResponse `json:"modelResponse,omitempty"` | ||
// TODO: add chat request-specific context | ||
} | ||
|
||
type ChatStreamError struct { | ||
// TODO: add chat request-specific context | ||
Reason string `json:"reason"` | ||
Message string `json:"message"` | ||
} | ||
|
||
type ChatStreamResult struct { | ||
chunk *ChatStreamChunk | ||
err *ChatStreamError | ||
} | ||
|
||
func (r *ChatStreamResult) Chunk() *ChatStreamChunk { | ||
return r.chunk | ||
} | ||
|
||
func (r *ChatStreamResult) Error() *ChatStreamError { | ||
return r.err | ||
} | ||
|
||
func NewChatStreamResult(chunk *ChatStreamChunk) *ChatStreamResult { | ||
return &ChatStreamResult{ | ||
chunk: chunk, | ||
err: nil, | ||
} | ||
} | ||
|
||
func NewChatStreamErrorResult(err *ChatStreamError) *ChatStreamResult { | ||
return &ChatStreamResult{ | ||
chunk: nil, | ||
err: err, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package clients | ||
|
||
import "glide/pkg/api/schemas" | ||
|
||
type ChatStreamResult struct { | ||
chunk *schemas.ChatStreamChunk | ||
err error | ||
} | ||
|
||
func (r *ChatStreamResult) Chunk() *schemas.ChatStreamChunk { | ||
return r.chunk | ||
} | ||
|
||
func (r *ChatStreamResult) Error() error { | ||
return r.err | ||
} | ||
|
||
func NewChatStreamResult(chunk *schemas.ChatStreamChunk, err error) *ChatStreamResult { | ||
return &ChatStreamResult{ | ||
chunk: chunk, | ||
err: err, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.