You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "DoubleBirdsU (via GitHub)" <gi...@apache.org> on 2025/03/23 01:03:33 UTC
[PR] Add flight booking AI Agent demo #817 [dubbo-go-samples]
DoubleBirdsU opened a new pull request, #818:
URL: https://github.com/apache/dubbo-go-samples/pull/818
Add flight booking AI Agent demo
[Book-Flight](https://github.com/apache/dubbo-go-samples/issues/817)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] Add flight booking AI Agent demo #817 [dubbo-go-samples]
Posted by "AlexStocks (via GitHub)" <gi...@apache.org>.
AlexStocks commented on code in PR #818:
URL: https://github.com/apache/dubbo-go-samples/pull/818#discussion_r2061135966
##########
llm/book-flight/go-server/agents/task.go:
##########
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package agents
+
+import (
Review Comment:
split
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] Add flight booking AI Agent demo #817 [dubbo-go-samples]
Posted by "AlexStocks (via GitHub)" <gi...@apache.org>.
AlexStocks commented on code in PR #818:
URL: https://github.com/apache/dubbo-go-samples/pull/818#discussion_r2040636153
##########
llm/book-flight/go-client/frontend/handlers/chat.go:
##########
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package handlers
+
+import (
Review Comment:
正确格式化 import
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] Add flight booking AI Agent demo #817 [dubbo-go-samples]
Posted by "FoghostCn (via GitHub)" <gi...@apache.org>.
FoghostCn commented on PR #818:
URL: https://github.com/apache/dubbo-go-samples/pull/818#issuecomment-2746632507
plz fix CI
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] Add flight booking AI Agent demo #817 [dubbo-go-samples]
Posted by "AlexStocks (via GitHub)" <gi...@apache.org>.
AlexStocks commented on PR #818:
URL: https://github.com/apache/dubbo-go-samples/pull/818#issuecomment-2798793569
问题列表:
1 对话过程中怎么处理记忆;
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] Add flight booking AI Agent demo #817 [dubbo-go-samples]
Posted by "No-SilverBullet (via GitHub)" <gi...@apache.org>.
No-SilverBullet commented on code in PR #818:
URL: https://github.com/apache/dubbo-go-samples/pull/818#discussion_r2082791579
##########
llm/book-flight/go-client/cmd/client.go:
##########
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "bufio"
+ "context"
+ "fmt"
+ "os"
+ "strings"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/client"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+)
+
+import (
+ chat "github.com/apache/dubbo-go-samples/llm/book-flight/proto"
+)
+
+type ChatContext struct {
+ ID string
+ History []*chat.ChatMessage
+}
+
+var (
+ contexts = make(map[string]*ChatContext)
+ currentCtxID string
+ contextOrder []string
+ maxID uint8 = 0
+)
+
+func handleCommand(cmd string) (resp string) {
+ cmd = strings.TrimSpace(cmd)
+ resp = ""
+ switch {
+ case cmd == "/?" || cmd == "/help":
+ resp += "Available commands:\n"
+ resp += "/? help - Show this help\n"
+ resp += "/list - List all contexts\n"
+ resp += "/cd <context> - Switch context\n"
+ resp += "/new - Create new context"
+ return resp
+ case cmd == "/list":
+ fmt.Println("Stored contexts (max 3):")
+ for _, ctxID := range contextOrder {
+ resp += fmt.Sprintf("- %s\n", ctxID)
+ }
+ return resp
+ case strings.HasPrefix(cmd, "/cd "):
+ target := strings.TrimPrefix(cmd, "/cd ")
+ if ctx, exists := contexts[target]; exists {
+ currentCtxID = ctx.ID
+ resp += fmt.Sprintf("Switched to context: %s\n", target)
+ } else {
+ resp += "Context not found"
+ }
+ return resp
+ case cmd == "/new":
+ newID := createContext()
+ currentCtxID = newID
+ resp += fmt.Sprintf("Created new context: %s\n", newID)
+ return resp
+ default:
+ resp += "Available commands:\n"
+ resp += "/? help - Show this help\n"
+ resp += "/list - List all contexts\n"
+ resp += "/cd <context> - Switch context\n"
+ resp += "/new - Create new context"
+ return resp
+ }
+}
+
+func createContext() string {
+ id := fmt.Sprintf("ctx%d", maxID)
+ maxID++
+ contexts[id] = &ChatContext{
+ ID: id,
+ History: []*chat.ChatMessage{},
+ }
+ contextOrder = append(contextOrder, id)
+
+ // up to 3 context
+ if len(contextOrder) > 3 {
Review Comment:
why 3?if this is a default value, make it to const
##########
llm/book-flight/go-client/cmd/client.go:
##########
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "bufio"
+ "context"
+ "fmt"
+ "os"
+ "strings"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/client"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+)
+
+import (
+ chat "github.com/apache/dubbo-go-samples/llm/book-flight/proto"
+)
+
+type ChatContext struct {
+ ID string
+ History []*chat.ChatMessage
+}
+
+var (
+ contexts = make(map[string]*ChatContext)
+ currentCtxID string
+ contextOrder []string
+ maxID uint8 = 0
+)
+
+func handleCommand(cmd string) (resp string) {
+ cmd = strings.TrimSpace(cmd)
+ resp = ""
+ switch {
+ case cmd == "/?" || cmd == "/help":
+ resp += "Available commands:\n"
+ resp += "/? help - Show this help\n"
+ resp += "/list - List all contexts\n"
+ resp += "/cd <context> - Switch context\n"
+ resp += "/new - Create new context"
+ return resp
+ case cmd == "/list":
+ fmt.Println("Stored contexts (max 3):")
+ for _, ctxID := range contextOrder {
+ resp += fmt.Sprintf("- %s\n", ctxID)
+ }
+ return resp
+ case strings.HasPrefix(cmd, "/cd "):
+ target := strings.TrimPrefix(cmd, "/cd ")
+ if ctx, exists := contexts[target]; exists {
+ currentCtxID = ctx.ID
+ resp += fmt.Sprintf("Switched to context: %s\n", target)
+ } else {
+ resp += "Context not found"
+ }
+ return resp
+ case cmd == "/new":
+ newID := createContext()
+ currentCtxID = newID
+ resp += fmt.Sprintf("Created new context: %s\n", newID)
+ return resp
+ default:
+ resp += "Available commands:\n"
+ resp += "/? help - Show this help\n"
+ resp += "/list - List all contexts\n"
+ resp += "/cd <context> - Switch context\n"
+ resp += "/new - Create new context"
+ return resp
+ }
+}
+
+func createContext() string {
+ id := fmt.Sprintf("ctx%d", maxID)
+ maxID++
+ contexts[id] = &ChatContext{
+ ID: id,
+ History: []*chat.ChatMessage{},
+ }
+ contextOrder = append(contextOrder, id)
+
+ // up to 3 context
+ if len(contextOrder) > 3 {
+ delete(contexts, contextOrder[0])
+ contextOrder = contextOrder[1:]
+ }
+ return id
+}
+
+func main() {
+ currentCtxID = createContext()
+
+ cli, err := client.NewClient(
+ client.WithClientURL("tri://127.0.0.1:20000"),
+ )
+ if err != nil {
+ panic(err)
+ }
+
+ svc, err := chat.NewChatService(cli)
+ if err != nil {
+ fmt.Printf("Error creating service: %v\n", err)
+ return
+ }
+
+ fmt.Print("\nSend a message (/? for help)")
+ scanner := bufio.NewScanner(os.Stdin)
+ for {
+ fmt.Print("\n> ")
+ scanner.Scan()
+ input := scanner.Text()
+
+ // handle command
+ if strings.HasPrefix(input, "/") {
+ fmt.Println(handleCommand(input))
+ continue
+ }
+
+ func() {
+ currentCtx := contexts[currentCtxID]
+ currentCtx.History = append(currentCtx.History,
+ &chat.ChatMessage{
+ Role: "human",
+ Content: input,
+ Bin: nil,
+ })
+
+ stream, err := svc.Chat(context.Background(), &chat.ChatRequest{
+ Messages: currentCtx.History,
+ })
+ if err != nil {
+ panic(err)
Review Comment:
do not use panic
##########
llm/book-flight/go-client/cmd/client.go:
##########
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "bufio"
+ "context"
+ "fmt"
+ "os"
+ "strings"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/client"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+)
+
+import (
+ chat "github.com/apache/dubbo-go-samples/llm/book-flight/proto"
+)
+
+type ChatContext struct {
+ ID string
+ History []*chat.ChatMessage
+}
+
+var (
+ contexts = make(map[string]*ChatContext)
+ currentCtxID string
+ contextOrder []string
+ maxID uint8 = 0
+)
+
+func handleCommand(cmd string) (resp string) {
+ cmd = strings.TrimSpace(cmd)
+ resp = ""
+ switch {
+ case cmd == "/?" || cmd == "/help":
+ resp += "Available commands:\n"
+ resp += "/? help - Show this help\n"
+ resp += "/list - List all contexts\n"
+ resp += "/cd <context> - Switch context\n"
+ resp += "/new - Create new context"
+ return resp
+ case cmd == "/list":
+ fmt.Println("Stored contexts (max 3):")
+ for _, ctxID := range contextOrder {
+ resp += fmt.Sprintf("- %s\n", ctxID)
+ }
+ return resp
+ case strings.HasPrefix(cmd, "/cd "):
+ target := strings.TrimPrefix(cmd, "/cd ")
+ if ctx, exists := contexts[target]; exists {
+ currentCtxID = ctx.ID
+ resp += fmt.Sprintf("Switched to context: %s\n", target)
+ } else {
+ resp += "Context not found"
+ }
+ return resp
+ case cmd == "/new":
+ newID := createContext()
+ currentCtxID = newID
+ resp += fmt.Sprintf("Created new context: %s\n", newID)
+ return resp
+ default:
+ resp += "Available commands:\n"
+ resp += "/? help - Show this help\n"
+ resp += "/list - List all contexts\n"
+ resp += "/cd <context> - Switch context\n"
+ resp += "/new - Create new context"
+ return resp
+ }
+}
+
+func createContext() string {
+ id := fmt.Sprintf("ctx%d", maxID)
+ maxID++
+ contexts[id] = &ChatContext{
+ ID: id,
+ History: []*chat.ChatMessage{},
+ }
+ contextOrder = append(contextOrder, id)
+
+ // up to 3 context
+ if len(contextOrder) > 3 {
+ delete(contexts, contextOrder[0])
+ contextOrder = contextOrder[1:]
+ }
+ return id
+}
+
+func main() {
+ currentCtxID = createContext()
+
+ cli, err := client.NewClient(
+ client.WithClientURL("tri://127.0.0.1:20000"),
+ )
+ if err != nil {
+ panic(err)
+ }
+
+ svc, err := chat.NewChatService(cli)
+ if err != nil {
+ fmt.Printf("Error creating service: %v\n", err)
+ return
+ }
+
+ fmt.Print("\nSend a message (/? for help)")
+ scanner := bufio.NewScanner(os.Stdin)
+ for {
+ fmt.Print("\n> ")
+ scanner.Scan()
+ input := scanner.Text()
+
+ // handle command
+ if strings.HasPrefix(input, "/") {
+ fmt.Println(handleCommand(input))
+ continue
+ }
+
+ func() {
+ currentCtx := contexts[currentCtxID]
+ currentCtx.History = append(currentCtx.History,
+ &chat.ChatMessage{
+ Role: "human",
+ Content: input,
+ Bin: nil,
+ })
+
+ stream, err := svc.Chat(context.Background(), &chat.ChatRequest{
+ Messages: currentCtx.History,
+ })
+ if err != nil {
+ panic(err)
+ }
+ defer stream.Close()
+
+ resp := ""
+
+ for stream.Recv() {
+ c := stream.Msg().Content
+ resp += c
Review Comment:
use strings.builder or other ways to reuse malloc memory
##########
llm/book-flight/go-client/cmd/client.go:
##########
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package main
+
+import (
+ "bufio"
+ "context"
+ "fmt"
+ "os"
+ "strings"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/client"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+)
+
+import (
+ chat "github.com/apache/dubbo-go-samples/llm/book-flight/proto"
+)
+
+type ChatContext struct {
+ ID string
+ History []*chat.ChatMessage
+}
+
+var (
+ contexts = make(map[string]*ChatContext)
+ currentCtxID string
+ contextOrder []string
+ maxID uint8 = 0
+)
+
+func handleCommand(cmd string) (resp string) {
+ cmd = strings.TrimSpace(cmd)
+ resp = ""
+ switch {
+ case cmd == "/?" || cmd == "/help":
+ resp += "Available commands:\n"
+ resp += "/? help - Show this help\n"
+ resp += "/list - List all contexts\n"
+ resp += "/cd <context> - Switch context\n"
+ resp += "/new - Create new context"
+ return resp
+ case cmd == "/list":
+ fmt.Println("Stored contexts (max 3):")
+ for _, ctxID := range contextOrder {
+ resp += fmt.Sprintf("- %s\n", ctxID)
+ }
+ return resp
+ case strings.HasPrefix(cmd, "/cd "):
+ target := strings.TrimPrefix(cmd, "/cd ")
+ if ctx, exists := contexts[target]; exists {
+ currentCtxID = ctx.ID
+ resp += fmt.Sprintf("Switched to context: %s\n", target)
+ } else {
+ resp += "Context not found"
+ }
+ return resp
+ case cmd == "/new":
+ newID := createContext()
+ currentCtxID = newID
+ resp += fmt.Sprintf("Created new context: %s\n", newID)
+ return resp
+ default:
+ resp += "Available commands:\n"
+ resp += "/? help - Show this help\n"
+ resp += "/list - List all contexts\n"
+ resp += "/cd <context> - Switch context\n"
+ resp += "/new - Create new context"
+ return resp
+ }
+}
+
+func createContext() string {
+ id := fmt.Sprintf("ctx%d", maxID)
+ maxID++
+ contexts[id] = &ChatContext{
+ ID: id,
+ History: []*chat.ChatMessage{},
+ }
+ contextOrder = append(contextOrder, id)
+
+ // up to 3 context
+ if len(contextOrder) > 3 {
+ delete(contexts, contextOrder[0])
+ contextOrder = contextOrder[1:]
+ }
+ return id
+}
+
+func main() {
+ currentCtxID = createContext()
+
+ cli, err := client.NewClient(
+ client.WithClientURL("tri://127.0.0.1:20000"),
+ )
+ if err != nil {
+ panic(err)
+ }
+
+ svc, err := chat.NewChatService(cli)
+ if err != nil {
+ fmt.Printf("Error creating service: %v\n", err)
+ return
+ }
+
+ fmt.Print("\nSend a message (/? for help)")
+ scanner := bufio.NewScanner(os.Stdin)
+ for {
+ fmt.Print("\n> ")
+ scanner.Scan()
+ input := scanner.Text()
+
+ // handle command
+ if strings.HasPrefix(input, "/") {
+ fmt.Println(handleCommand(input))
+ continue
+ }
+
+ func() {
+ currentCtx := contexts[currentCtxID]
+ currentCtx.History = append(currentCtx.History,
Review Comment:
history will keep growing, would it be better to limit the length?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] Add flight booking AI Agent demo #817 [dubbo-go-samples]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #818:
URL: https://github.com/apache/dubbo-go-samples/pull/818#discussion_r2083095420
##########
llm/book-flight/go-server/agents/task.go:
##########
@@ -0,0 +1,187 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package agents
+
+import (
+ "context"
+ "strings"
+)
+
+import (
+ "github.com/apache/dubbo-go-samples/llm/book-flight/go-server/tools"
+)
+
+type TaskState int
+
+const (
+ TaskUndefined TaskState = 0
+ TaskSubmitted TaskState = 1 << iota
+ TaskWorking
+ TaskInputRequired
+ TaskCompleted
+ TaskFailed
+ TaskCanceled
+ TaskUnrelated
+)
+
+// InitTaskState
+func InitTaskState(value string) TaskState {
+ var rst TaskState
+ switch strings.ToUpper(value) {
+ case "TASKUNDEFINED":
+ rst = TaskUndefined
+ case "TASKSUBMITTED":
+ rst = TaskSubmitted
+ case "TASKWORKING":
+ rst = TaskWorking
+ case "TASKINPUTREQUIRED":
+ rst = TaskInputRequired
+ case "TASKCOMPLETED":
+ rst = TaskCompleted
+ case "TASKFAILED":
+ rst = TaskFailed
+ case "TASKCANCELED":
+ rst = TaskCanceled
+ case "TASKUNRELATED":
+ rst = TaskUnrelated
+ default:
+ rst = TaskUndefined
+ }
+ return rst
+}
+
+// CreateToolkit
+func CreateTaskToolkit(description string, taskFlag TaskState, ts ...tools.Tool) tools.Tools {
+ toolsTask := append(ts, tools.CreateTool[TaskUnrelatedTool]("TaskUnrelated", "不相关问题占位符工具", ""))
Review Comment:
The 'TaskUnrelatedTool' is appended unconditionally and then is potentially appended again if the 'TaskUnrelated' flag is set later. This could lead to duplicate tool entries. Consider removing the unconditional append or reviewing the flag logic.
```suggestion
toolsTask := ts
```
##########
llm/book-flight/go-server/mcp/jsonrpc.go:
##########
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package mcp
+
+const (
+ jsonrpc = "2.0" // jsonrpc version
+)
+
+type RequestRPC struct {
+ // JsonRPC specifies the JSON-RPC version. It MUST be exactly "2.0".
+ JsonRPC string `json:"jsonrpc"` // Explicitly named "jsonrpc" in JSON
+ // Method is a string containing the name of the method to be invoked.
+ // Method names that begin with a lowercase letter are reserved for
+ // system-defined methods and MUST NOT be used for custom methods.
+ Method string `json:"method"`
+ // Params is a structured value that holds the parameter values to be used
+ // during the invocation of the method. This member MAY be omitted.
+ Params map[string]any `json:"params,omitempty"` // Omitempty to skip if nil
+ // Id is an identifier established by the client that MUST contain a String,
+ // Number, or Null value if included. If not included it is assumed to be a
+ // notification. The value SHOULD normally not be Null [1] and Numbers SHOULD
+ // NOT contain fractional parts [2].
+ // [1] Using Null as a value for the id member in a Request object is
+ // discouraged, as there are no benefits and it introduces ambiguities
+ // when differentiating between Requests, Notifications, and Response
+ // objects.
+ // [2] Fractional parts SHOULD NOT be used as there is no clear
+ // interoperable way to represent them across all systems.
+ Id string `json:"id,omitempty"` // Omitempty to skip if empty
+}
+
+// NewRequestRPC creates a new RequestRPC with the JsonRPC field set to "2.0".
+func NewRequestRPC(method string, params map[string]any, id string) *RequestRPC {
+ return &RequestRPC{
+ JsonRPC: jsonrpc,
+ Method: method,
+ Params: params,
+ Id: id,
+ }
+}
+
+type ErrorRPC struct {
+ // A Number that indicates the error type that occurred.
+ // This MUST be an integer.
+ Code int64 `json:"code"`
+ // A String providing a shot description of the error.
Review Comment:
It appears there is a typo in the comment ('shot' should be 'short'). Consider updating the comment to 'A String providing a short description of the error.'
```suggestion
// A String providing a short description of the error.
```
##########
llm/book-flight/go-client/frontend/templates/index.html:
##########
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+<html lang="en" dir="ltr">
+<head>
+ <meta charset="utf-8">
+ <title>Chatbot in JavaScript | CodingNepal</title>
+ <link rel="stylesheet" href="../static/style.css">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" />
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@48,400,1,0" />
+ <script src="../static/script.js" defer></script>
+ <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism.min.css">
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script>
+ <style>
+ .markdown-body {
+ line-height: 1.2;
+ font-family: sans-serif;
+ padding: 20px;
+ }
+ </style>
+</head>
+<body>
+
+<!-- 机票预订信息 -->
+<div class="booking-confirmation">
+ <div id="flight-info">
+ <h3>航班信息</h3>
+ <p>正在加载航班信息...</p>
+ </div>
+</div>
+<div class="chatbot">
+ <header>
+ <h2>Chatbot</h2>
+ </header>
+ <ul class="chatbox">
+ <li class="chat incoming">
+ <span class="material-symbols-outlined">smart_toy</span>
+ <p class="chat incoming content" id="content">Hi there 👋</p>
+ </li>
+ </ul>
+ <div class="chat-input">
+ <textarea placeholder="Enter a message..." spellcheck="false" required></textarea>
+ <span id="send-btn" class="material-symbols-rounded">send</span>
+ <div id="drop" class="drop-box"></div>
+ <span1 id="add-btn" class="material-symbols-rounded">add</span1>
Review Comment:
The HTML tag 'span1' is non-standard. It is recommended to change it to a standard tag such as 'span' for better browser compatibility.
```suggestion
<span id="add-btn" class="material-symbols-rounded">add</span>
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org