Skip to content

codex を golang で取り扱うラッパーライブラリ

License

Notifications You must be signed in to change notification settings

thamaji/codex-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codex-go

概要

codex-go は OpenAI が提供する CLI 型のコーディングエージェント codex を Go から簡単に利用するためのラッパーライブラリです。

本ライブラリは codex 0.2.0 ~ 0.46.0 での動作を確認しています。

インストール

go get github.com/thamaji/codex-go

使用例

簡単な使用例です。環境変数 OPENAI_APIKEY に API キーを入れて実行します。

package main

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

    "github.com/thamaji/codex-go"
)

func main() {
    apiKey := os.Getenv("OPENAI_APIKEY")

    client := codex.New(codex.WithLogger(os.Stderr, "info"))

    ctx := context.Background()
    if err := client.Login(ctx, apiKey); err != nil {
        log.Fatal(err)
    }

    // シンプルな呼び出し例
    text, err := client.Invoke(
        ctx,
        "hello",
        codex.WithCwd("."),
        codex.WithSandbox("read-only"),
        codex.WithApprovalPolicy("never"),
    )
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(text)
}

About

codex を golang で取り扱うラッパーライブラリ

Resources

License

Stars

Watchers

Forks

Packages

No packages published