-
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.
- Cleaned up and restructured provider/openai codebase. Separated unified schemas to the api package. - Added and exposed the language chat API with the unified request/response schemas. Updated the bruno collection with this request - Added an example of client tests - Connected Glide API with the underlying model provider (OpenAI client is hardcoded for now) - Implemented default value setting for nested nillable config items - Implemented provider setting validation on the model item level
- Loading branch information
1 parent
c62579d
commit ae3cf1b
Showing
29 changed files
with
693 additions
and
312 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
meta { | ||
name: [Lang] Chat | ||
type: http | ||
seq: 2 | ||
} | ||
|
||
post { | ||
url: {{base_url}}/v1/language/myrouter/chat/ | ||
body: json | ||
auth: none | ||
} | ||
|
||
body:json { | ||
{ | ||
"message": { | ||
"role": "user", | ||
"content": "How are you doing?" | ||
}, | ||
"messageHistory": [] | ||
} | ||
} |
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,3 +1,3 @@ | ||
vars { | ||
base_url: http://localhost:9099 | ||
base_url: http://127.0.0.1:9099 | ||
} |
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,9 @@ | ||
package http | ||
|
||
type ErrorSchema struct { | ||
Message string `json:"message"` | ||
} | ||
|
||
type HealthSchema struct { | ||
Healthy bool `json:"healthy"` | ||
} |
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,41 @@ | ||
package schemas | ||
|
||
// UnifiedChatRequest defines Glide's Chat Request Schema unified across all language models | ||
type UnifiedChatRequest struct { | ||
Message ChatMessage `json:"message"` | ||
MessageHistory []ChatMessage `json:"messageHistory"` | ||
} | ||
|
||
// UnifiedChatResponse defines Glide's Chat Response Schema unified across all language models | ||
type UnifiedChatResponse 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package config | ||
package fields | ||
|
||
import "encoding" | ||
|
||
|
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 config | ||
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
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,17 @@ | ||
telemetry: | ||
logging: | ||
level: INFO # DEBUG, INFO, WARNING, ERROR, FATAL | ||
encoding: json # console, json | ||
|
||
routers: | ||
language: | ||
- id: simplerouter | ||
strategy: priority | ||
models: | ||
- id: openai-boring | ||
openai: | ||
model: gpt-3.5-turbo | ||
api_key: "ABSC@124" | ||
default_params: | ||
temperature: 0 | ||
|
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 @@ | ||
telemetry: | ||
logging: | ||
level: INFO # DEBUG, INFO, WARNING, ERROR, FATAL | ||
encoding: json # console, json | ||
|
||
routers: | ||
language: | ||
- id: simplerouter | ||
strategy: priority | ||
models: | ||
- id: openaimodel | ||
|
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 was deleted.
Oops, something went wrong.
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.UnifiedChatRequest) (*schemas.UnifiedChatResponse, error) | ||
} |
Oops, something went wrong.