Skip to content

zipkero/langgraph-go

Repository files navigation

langgraph-go

LangGraph/LangChain 스타일의 에이전트 런타임을 Go로 구현하는 라이브러리입니다. 그래프 실행, 에이전트 루프, 도구 호출, 메시지 모델, 구조화 출력, 체크포인트, 스트리밍, MCP, A2A, 벡터스토어와 외부 서비스 연동을 Go 패키지로 제공합니다.

현재 상태

이 저장소는 기능 구현과 검증 문서가 함께 진행되는 개발 중 프로젝트입니다. 루트 패키지는 애플리케이션이 아니라 다운스트림 Go 프로젝트에서 import해 사용하는 라이브러리 패키지들로 구성되어 있습니다.

현재 확인된 주요 패키지는 다음과 같습니다.

  • graph: 상태 그래프 빌더, 컴파일, 실행, 스트리밍, 체크포인트 연동
  • agent: ReAct 스타일 에이전트 루프, 도구 실행, 미들웨어, 응답 포맷
  • llm: OpenAI/Anthropic 챗 모델 어댑터, 임베딩, 스트리밍, 구조화 출력
  • tool: 도구 인터페이스, 스키마, 레지스트리, 실행기
  • message: 메시지 타입, tool call, 메시지 리듀서
  • checkpoint, store: 단기 체크포인트와 장기 메모리 저장소
  • document, vectorstore: 문서 로더, 텍스트 분할, 인메모리/Supabase/Chroma 벡터 검색
  • mcp, a2a: MCP 클라이언트/서버와 A2A 프로토콜 타입/서버/클라이언트
  • multiagent: supervisor, handoff, worker, network, planner 구성 요소

상세 기능 명세와 구현 순서는 ROADMAP.md를 기준으로 확인합니다.

설치

Go 모듈에서 다음처럼 가져옵니다.

go get github.com/zipkero/langgraph-go

이 저장소를 직접 개발할 때는 의존성을 내려받은 뒤 테스트를 실행합니다.

go mod download
go test ./...

빠른 시작

아래 예시는 API 키 없이 동작하는 작은 상태 그래프입니다.

package main

import (
	"context"
	"fmt"

	"github.com/zipkero/langgraph-go/config"
	"github.com/zipkero/langgraph-go/graph"
)

func main() {
	schema := graph.StateSchema{
		Reducers: map[string]graph.ReducerFunc{
			"items": func(cur, upd any) any {
				items, _ := cur.([]any)
				if upd == nil {
					return items
				}
				return append(items, upd)
			},
		},
	}

	builder := graph.NewStateGraph(schema)

	_ = builder.AddNode("first", func(ctx context.Context, st graph.State) (any, error) {
		return graph.StateUpdate{"items": "a", "label": "first"}, nil
	})
	_ = builder.AddNode("second", func(ctx context.Context, st graph.State) (any, error) {
		return graph.StateUpdate{"items": "b", "label": "second"}, nil
	})
	_ = builder.AddEdge("first", "second")
	_ = builder.SetEntryPoint("first")

	compiled, err := builder.Compile()
	if err != nil {
		panic(err)
	}

	result, err := compiled.Invoke(context.Background(), graph.State{}, config.RunConfig{})
	if err != nil {
		panic(err)
	}

	fmt.Println(result)
}

환경변수

라이브 LLM, 검색, DB, 스토리지 연동 테스트를 실행하려면 .env.sample을 참고해 필요한 값을 설정합니다. 키가 없는 통합 테스트는 대부분 t.Skip으로 건너뛰도록 구성되어 있습니다.

cp .env.sample .env

주요 환경변수는 다음과 같습니다.

  • OPENAI_API_KEY: OpenAI 챗/임베딩 라이브 테스트
  • ANTHROPIC_API_KEY: Anthropic 챗과 일부 멀티에이전트 e2e 테스트
  • DATABASE_URL: Supabase/Postgres 통합 테스트
  • TAVILY_API_KEY: 웹 검색 통합 테스트
  • GOOGLE_DRIVE_CREDENTIALS_PATH, GOOGLE_DRIVE_TOKEN_PATH: Google Drive 스토리지 통합 테스트

개발

전체 테스트:

go test ./...

특정 패키지 테스트:

go test ./graph
go test ./agent
go test ./vectorstore

Chroma 벡터스토어 e2e 테스트는 로컬 Chroma 서버가 필요합니다. 저장소의 docker-compose.yml로 서버를 띄울 수 있습니다.

docker compose up -d
go test ./vectorstore -run ChromaE2E

문서

  • ROADMAP.md: 전체 기능 명세, 패키지 경계, 구현 순서
  • features/: 기능별 spec, analysis, implement 문서
  • .env.sample: 연동 테스트와 실행 설정에 필요한 환경변수 예시

라이선스

이 저장소에서 라이선스 파일은 아직 확인되지 않았습니다.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors