-
Notifications
You must be signed in to change notification settings - Fork 548
feat: add resp format, timeout, model override to conversation api #4129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 8 commits
433c1b1
7e9b98a
81a767a
03c09db
d51e59f
a82bb60
515defb
af00135
f5752c7
4ed9d7c
296fb49
0ec82cb
b79a0ba
65abb47
1ad0019
a26ef93
007feda
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,9 +17,9 @@ package conversation | |
| import ( | ||
| "context" | ||
| "io" | ||
| "time" | ||
|
|
||
| "github.com/tmc/langchaingo/llms" | ||
| "google.golang.org/protobuf/types/known/anypb" | ||
|
|
||
| "github.com/dapr/components-contrib/metadata" | ||
| ) | ||
|
|
@@ -36,23 +36,29 @@ type Conversation interface { | |
|
|
||
| type Request struct { | ||
| // Message can be user input prompt/instructions and/or tool call responses. | ||
| Message *[]llms.MessageContent | ||
| Tools *[]llms.Tool | ||
| ToolChoice *string | ||
| Parameters map[string]*anypb.Any `json:"parameters"` | ||
| ConversationContext string `json:"conversationContext"` | ||
| Temperature float64 `json:"temperature"` | ||
|
|
||
| // from metadata | ||
| Key string `json:"key"` | ||
| Model string `json:"model"` | ||
| Endpoints []string `json:"endpoints"` | ||
| Policy string `json:"loadBalancingPolicy"` | ||
|
Comment on lines
-42
to
-50
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The “from metadata” fields were bubbling the Metadata field from the Conversations API (see https://github.com/dapr/dapr/blob/master/dapr/proto/runtime/v1/ai.proto#L43 As a result, we can remove the following fields: Key, Endpoints, and Policy. I also removed Parameters and ConversationContext, since these were surfaced but never actually used. All of this traces back to the original implementation, which I’m now cleaning up. |
||
| Message *[]llms.MessageContent | ||
| Tools *[]llms.Tool | ||
| ToolChoice *string | ||
| Temperature float64 `json:"temperature"` | ||
|
|
||
| // Metadata fields that are separate from the actual component metadata fields | ||
| // that get passed to the LLM through the conversation. | ||
| // https://github.com/openai/openai-go/blob/main/chatcompletion.go#L3010 | ||
| Metadata map[string]string `json:"metadata"` | ||
|
|
||
| ResponseFormatAsJSONSchema map[string]any `json:"responseFormatAsJsonSchema"` | ||
| PromptCacheRetention time.Duration `json:"promptCacheRetention"` | ||
| Model *string `json:"model"` | ||
|
|
||
| // LlmTimeout specifies the max duration to wait for the LLM to complete a conversation request. | ||
| // Langchaingo timeout is respected, so if this is set, it will override the provider's timeout. | ||
| LlmTimeout time.Duration `json:"llmTimeout"` | ||
| } | ||
|
|
||
| type Response struct { | ||
| ConversationContext string `json:"conversationContext"` | ||
| Outputs []Result `json:"outputs"` | ||
| Outputs []Result `json:"outputs"` | ||
| Usage *Usage `json:"usage,omitempty"` | ||
| Model string `json:"model"` | ||
| } | ||
|
|
||
| type Result struct { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.