-
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.
#42 Refined the OpenAI client structure
- Loading branch information
1 parent
7d1cfe9
commit a73e058
Showing
10 changed files
with
178 additions
and
214 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
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,44 @@ | ||
package schemas | ||
|
||
// ChatRequest defines Glide's Chat Request Schema unified across all language models | ||
type ChatRequest struct { | ||
Message []struct { // TODO: could we reuse ChatMessage? | ||
Role string `json:"role"` | ||
Content string `json:"content"` | ||
} `json:"message"` | ||
MessageHistory []string `json:"messageHistory"` | ||
} | ||
|
||
// ChatResponse defines Glide's Chat Response Schema unified across all language models | ||
type ChatResponse struct { | ||
ID string `json:"id,omitempty"` | ||
Created float64 `json:"created,omitempty"` | ||
Choices []*ChatChoice `json:"choices,omitempty"` | ||
Model string `json:"model,omitempty"` | ||
Object string `json:"object,omitempty"` // TODO: what does this mean "Object"? | ||
Usage Usage `json:"usage,omitempty"` | ||
} | ||
|
||
// ChatMessage is a message in a chat request. | ||
type ChatMessage struct { | ||
// The role of the author of this message. One of system, user, or assistant. | ||
Role string `json:"role"` | ||
// The content of the message. | ||
Content string `json:"content"` | ||
// The name of the author of this message. May contain a-z, A-Z, 0-9, and underscores, | ||
// with a maximum length of 64 characters. | ||
Name string `json:"name,omitempty"` | ||
} | ||
|
||
// ChatChoice is a choice in a chat response. | ||
type ChatChoice struct { | ||
Index int `json:"index"` | ||
Message ChatMessage `json:"message"` | ||
FinishReason string `json:"finish_reason"` | ||
} | ||
|
||
type Usage struct { | ||
CompletionTokens float64 `json:"completion_tokens,omitempty"` | ||
PromptTokens float64 `json:"prompt_tokens,omitempty"` | ||
TotalTokens float64 `json:"total_tokens,omitempty"` | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package providers | ||
package fields | ||
|
||
import "encoding" | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
pkg/providers/secret_test.go → pkg/config/fields/secret_test.go
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package providers | ||
package fields | ||
|
||
import ( | ||
"testing" | ||
|
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,12 @@ | ||
package providers | ||
|
||
import ( | ||
"context" | ||
|
||
"glide/pkg/api/schemas" | ||
) | ||
|
||
// ChatModel defines the interface a provider should fulfill to be able to serve language chat requests | ||
type ChatModel interface { | ||
Chat(ctx *context.Context, request *schemas.ChatRequest) (*schemas.ChatResponse, error) | ||
} |
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.