micro--go-micro
081e375f29
* docs: add AI provider integration guide and Supported AI Providers section Add a step-by-step guide for AI infrastructure companies to implement ai.Model and contribute a provider to go-micro. Covers the full lifecycle: skeleton, tool call handling, tests, registration, and PR checklist. Add a "Supported AI Providers" section to the project README that lists current providers (Anthropic, OpenAI) in a table and links to the integration guide with a call-to-action for new providers and sponsors. Streamline the "Adding a New Provider" section in ai/README.md to point to the new guide instead of duplicating a full code listing. * fix: remove nonexistent Discord link from README * fix(website): set content container width to 800px on desktop Move the 800px max-width from .markdown-body up to .content so the entire content pane (not just the inner body) is sized correctly. The container now fills up to 800px beside the sidebar. * feat(ai): wire Atlas Cloud into server and auto-detection Import atlascloud provider in the micro server so it is available when running micro run / micro server. Add atlascloud to AutoDetectProvider so --ai_base_url with an atlascloud domain selects the right provider automatically. * feat(ai): add Google Gemini provider Add ai/gemini implementing ai.Model for Google's Gemini API. Uses the native generateContent endpoint with system_instruction, contents/parts, and functionDeclarations — not an OpenAI shim. Default model gemini-2.5-flash, auth via x-goog-api-key header. Wire into micro server imports and AutoDetectProvider (matches googleapis.com and google in base URL). Update README.md and ai/README.md with provider listing. * feat(ai): add Groq, Mistral, and Together AI providers Add three new OpenAI-compatible providers: - ai/groq: ultra-fast inference, default model llama-3.3-70b-versatile - ai/mistral: Mistral AI, default model mistral-large-latest - ai/together: Together AI, default model Llama-3.3-70B-Instruct-Turbo All three are wired into the micro server imports and AutoDetectProvider. README and ai/README updated with the full provider table. * feat(ai): add ai/tools helper and 'micro chat' interactive agent Extract the registry-discovery + RPC-execution loop from the web agent playground into a reusable ai/tools package: - tools.New(reg) creates a Set bound to a registry - Set.Discover() walks the registry and returns []ai.Tool with LLM-safe (underscored) names, remembering the mapping back to the original dotted form - Set.Handler(client) returns an ai.ToolHandler that resolves the safe name and issues the RPC Add cmd/micro/chat — an interactive 'micro chat' REPL that uses ai/tools to let users talk to their services through any registered AI provider. Supports --prompt for single-shot use, auto-detects the provider from --base_url, and falls back to the provider's conventional env var (ANTHROPIC_API_KEY, etc). Update README with the new command and the programmatic example. * feat(examples): add gRPC interop example Add examples/grpc-interop showing that any standard gRPC client can call a go-micro service — no go-micro SDK required on the client side. Includes: - proto/greeter.proto with generated Go, gRPC, and micro stubs - server/ using go-micro gRPC transport - client/ using stock google.golang.org/grpc (no go-micro imports) - README with Python example and explanation of how routing works Addresses the confusion from issue #2818 where users didn't know that go-micro gRPC services are callable by any gRPC client. --------- Co-authored-by: Claude <noreply@anthropic.com>
54 行
1.1 KiB
Go
54 行
1.1 KiB
Go
// server starts a go-micro gRPC service. Any standard gRPC client
|
|
// (Go, Python, Java, etc.) can call it — no go-micro SDK required on
|
|
// the client side.
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
|
|
micro "go-micro.dev/v5"
|
|
"go-micro.dev/v5/client"
|
|
grpcclient "go-micro.dev/v5/client/grpc"
|
|
"go-micro.dev/v5/server"
|
|
grpcserver "go-micro.dev/v5/server/grpc"
|
|
|
|
pb "example/proto"
|
|
)
|
|
|
|
type Greeter struct{}
|
|
|
|
func (g *Greeter) Hello(ctx context.Context, req *pb.HelloRequest, rsp *pb.HelloResponse) error {
|
|
log.Printf("Received request: name=%q", req.Name)
|
|
rsp.Message = "Hello " + req.Name
|
|
return nil
|
|
}
|
|
|
|
func main() {
|
|
addr := ":50051"
|
|
|
|
service := micro.New("greeter",
|
|
micro.Server(grpcserver.NewServer(
|
|
server.Name("greeter"),
|
|
server.Address(addr),
|
|
)),
|
|
micro.Client(grpcclient.NewClient(
|
|
client.ContentType("application/grpc+proto"),
|
|
)),
|
|
)
|
|
|
|
service.Init()
|
|
|
|
pb.RegisterGreeterHandler(service.Server(), new(Greeter))
|
|
|
|
fmt.Println("Go-Micro gRPC server listening on", addr)
|
|
fmt.Println()
|
|
fmt.Println("Call with a standard gRPC client:")
|
|
fmt.Println(" go run ../client/main.go")
|
|
|
|
if err := service.Run(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|