Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 64 additions & 43 deletions proto/gen/rill/runtime/v1/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions proto/gen/rill/runtime/v1/api.pb.validate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions proto/gen/rill/runtime/v1/runtime.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ paths:
prompt:
type: string
description: The prompt to complete.
locale:
type: string
description: Locale of the user.
agent:
type: string
description: |-
Expand Down Expand Up @@ -476,6 +479,9 @@ paths:
prompt:
type: string
description: The prompt to complete.
locale:
type: string
description: Locale of the user.
agent:
type: string
description: |-
Expand Down
4 changes: 4 additions & 0 deletions proto/rill/runtime/v1/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,8 @@ message CompleteRequest {
string conversation_id = 2;
// The prompt to complete.
string prompt = 3;
// Locale of the user.
string locale = 14;
// Optional agent to use for the completion.
// If not set, it will infer an agent based on the prompt and conversation history.
string agent = 10 [(validate.rules).string = {ignore_empty: true, in: ["analyst_agent", "developer_agent", "feedback_agent"]}];
Expand Down Expand Up @@ -1229,6 +1231,8 @@ message CompleteStreamingRequest {
string conversation_id = 2;
// The prompt to complete.
string prompt = 3;
// Locale of the user.
string locale = 14;
// Optional agent to use for the completion.
// If not set, it will infer an agent based on the prompt and conversation history.
string agent = 10 [(validate.rules).string = {ignore_empty: true, in: ["analyst_agent", "developer_agent", "feedback_agent"]}];
Expand Down
6 changes: 6 additions & 0 deletions runtime/ai/analyst_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var _ Tool[*AnalystAgentArgs, *AnalystAgentResult] = (*AnalystAgent)(nil)

type AnalystAgentArgs struct {
Prompt string `json:"prompt"`
Locale string `json:"locale" yaml:"locale" jsonschema:"Optional locale for the prompt. If provided, the prompt will be localized to this locale and the response will be in the locale's language'."`
Explore string `json:"explore,omitempty" yaml:"explore" jsonschema:"Optional explore dashboard name. If provided, the exploration will be limited to this dashboard."`
Dimensions []string `json:"dimensions,omitempty" yaml:"dimensions" jsonschema:"Optional list of dimensions for queries. If provided, the queries will be limited to these dimensions."`
Measures []string `json:"measures,omitempty" yaml:"measures" jsonschema:"Optional list of measures for queries. If provided, the queries will be limited to these measures."`
Expand Down Expand Up @@ -258,6 +259,10 @@ func (t *AnalystAgent) userPrompt(ctx context.Context, metricsViewNames []string
"max_query_limit": instanceCfg.AIMaxQueryLimit,
}

if args.Locale != "" {
data["locale"] = args.Locale
}

if !args.TimeStart.IsZero() && !args.TimeEnd.IsZero() {
data["time_start"] = args.TimeStart.Format(time.RFC3339)
data["time_end"] = args.TimeEnd.Format(time.RFC3339)
Expand Down Expand Up @@ -289,6 +294,7 @@ func (t *AnalystAgent) userPrompt(ctx context.Context, metricsViewNames []string
// Generate the user prompt.
// It carries all the per-invocation context: the current date, dashboard/report context, applied query settings, forked-session caveats, and finally the user's actual prompt.
return executeTemplate(`Today's date is {{ .now.Format "Monday, January 2, 2006" }} ({{ .now.Format "2006-01-02" }}).
{{ if .locale }}User's locale is "{{ .locale }}". Make sure to use this locale's language in the response.{{ end }}

{{ if .is_report }}
You are operating in an automated scheduled insight report mode where you will come up with insights on your own without additional user input.
Expand Down
2 changes: 2 additions & 0 deletions runtime/ai/router_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var _ Tool[*RouterAgentArgs, *RouterAgentResult] = (*RouterAgent)(nil)

type RouterAgentArgs struct {
Prompt string `json:"prompt" jsonschema:"The user's prompt to be routed."`
Locale string `json:"locale" yaml:"locale" jsonschema:"Optional locale for the prompt. If provided, the prompt will be localized to this locale and the response will be in the locale's language'."`
Agent string `json:"agent,omitempty" jsonschema:"Optional agent to route the request to. If not specified, the system will infer the best agent."`
AnalystAgentArgs *AnalystAgentArgs `json:"analyst_agent_args,omitempty" jsonschema:"Optional arguments to pass to the analyst agent if the selected agent is analyst_agent."`
DeveloperAgentArgs *DeveloperAgentArgs `json:"developer_agent_args,omitempty" jsonschema:"Optional arguments to pass to the developer agent if the selected agent is developer_agent."`
Expand Down Expand Up @@ -157,6 +158,7 @@ func (t *RouterAgent) Handler(ctx context.Context, args *RouterAgentArgs) (*Rout
analystAgentArgs = &AnalystAgentArgs{}
}
analystAgentArgs.Prompt = args.Prompt
analystAgentArgs.Locale = args.Locale

var res *AnalystAgentResult
_, err := s.CallToolWithOptions(ctx, &CallToolOptions{
Expand Down
2 changes: 2 additions & 0 deletions runtime/server/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ func (s *Server) Complete(ctx context.Context, req *runtimev1.CompleteRequest) (
var res *ai.RouterAgentResult
msg, err := session.CallTool(ctx, ai.RoleUser, ai.RouterAgentName, &res, ai.RouterAgentArgs{
Prompt: req.Prompt,
Locale: req.Locale,
Agent: req.Agent,
AnalystAgentArgs: analystAgentArgs,
DeveloperAgentArgs: developerAgentArgs,
Expand Down Expand Up @@ -447,6 +448,7 @@ func (s *Server) CompleteStreaming(req *runtimev1.CompleteStreamingRequest, stre
var res *ai.RouterAgentResult
msg, err := session.CallTool(ctx, ai.RoleUser, ai.RouterAgentName, &res, ai.RouterAgentArgs{
Prompt: req.Prompt,
Locale: req.Locale,
Agent: req.Agent,
AnalystAgentArgs: analystAgentArgs,
DeveloperAgentArgs: developerAgentArgs,
Expand Down
2 changes: 2 additions & 0 deletions web-common/src/features/chat/core/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ export class Conversation {
*/
private async startStreaming(request: {
prompt?: string;
locale?: string;
context?: RuntimeServiceCompleteBody;
feedbackAgentContext?: {
targetMessageId: string;
Expand All @@ -360,6 +361,7 @@ export class Conversation {
? undefined
: this.conversationId,
prompt: request.prompt,
locale: request.locale,
agent: request.feedbackAgentContext
? ToolName.FEEDBACK_AGENT
: this.agent,
Expand Down
13 changes: 10 additions & 3 deletions web-common/src/features/chat/core/input/ChatInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import Button from "@rilldata/web-common/components/button/Button.svelte";
import { m } from "@rilldata/web-common/lib/i18n/gen/messages";
import { ArrowUp } from "lucide-svelte";
import { getLocale } from "@rilldata/web-common/lib/i18n/gen/runtime";

export let conversationManager: ConversationManager;
export let onSend: (() => void) | undefined = undefined;
Expand Down Expand Up @@ -46,9 +47,15 @@

// Message handling with input focus
try {
await currentConversation.sendMessage(additionalContext, {
onStreamStart: () => editor.commands.setContent(""),
});
await currentConversation.sendMessage(
{
...additionalContext,
locale: getLocale(),
},
{
onStreamStart: () => editor.commands.setContent(""),
},
);
onSend?.();
} catch (error) {
console.error("Failed to send message:", error);
Expand Down
Loading
Loading