Token导航 LogoToken导航TokenDH.com
Adk Go Openai logo
地图位置未说明官方级别未说明来源级核验

Adk Go Openai

MCP Server

为ADK-Go框架提供的OpenAI模型实现,用于处理天气查询等任务。

工具数

0

提示词数

0

GitHub Stars

26

资源数

0
OpenAI位置天气GoGo语言

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

byebyebruce

提供方

byebyebruce

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

ADK-Go的OpenAI模型

此包为 ADK Go 框架。

用法

go get github.com/byebyebruce/adk-go-openai

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	openai "github.com/byebyebruce/adk-go-openai"
	go_openai "github.com/sashabaranov/go-openai"
	"google.golang.org/adk/agent"
	"google.golang.org/adk/agent/llmagent"
	"google.golang.org/adk/cmd/launcher"
	"google.golang.org/adk/cmd/launcher/full"
	"google.golang.org/adk/tool"
	"google.golang.org/adk/tool/functiontool"
)

type Input struct {
	City string `json:"city" jsonschema:"city name"`
}

type Output struct {
	WeatherSummary string `json:"weather_summary" jsonschema:"weather summary in the given city"`
}

func GetWeather(ctx tool.Context, input Input) (Output, error) {
	log.Println("Getting weather for city: ", input.City)
	return Output{
		WeatherSummary: fmt.Sprintf("Today in %q is sunny\n", input.City),
	}, nil
}

func main() {
	ctx := context.Background()

	modelName := "gpt-5.1"
	openaiCfg := go_openai.DefaultConfig(os.Getenv("OPENAI_API_KEY"))
	if baseURL := os.Getenv("OPENAI_BASE_URL"); baseURL != "" {
		openaiCfg.BaseURL = baseURL
	}

	weatherTool, err := functiontool.New(functiontool.Config{
		Name:        "weather",
		Description: "Returns weather in a city",
	}, GetWeather)
	if err != nil {
		log.Fatalf("Failed to create tool: %v", err)
	}

	model := openai.NewOpenAIModel(modelName, openaiCfg)
	a, err := llmagent.New(llmagent.Config{
		Name:        "weather_agent",
		Model:       model,
		Description: "Agent to answer questions about weather in a city.",
		Instruction: "Your SOLE purpose is to answer questions about the current weather in a specific city. You MUST refuse to answer any questions unrelated to weather.",
		Tools: []tool.Tool{
			weatherTool,
		},
	})
	if err != nil {
		log.Fatalf("Failed to create agent: %v", err)
	}

	config := &launcher.Config{
		AgentLoader: agent.NewSingleLoader(a),
	}

	l := full.NewLauncher()
	if err = l.Execute(ctx, config, os.Args[1:]); err != nil {
		log.Fatalf("Run failed: %v\n\n%s", err, l.CommandLineSyntax())
	}
}

献给Ollama

export OPENAI_BASE_URL='http://localhost:11434/v1/'

示例

deepwiki-cli 快速入门

目录标签

目录标签

OpenAI位置天气GoGo语言本地部署ADK-Go天气查询

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP