Code Monkey home page Code Monkey logo

claude-api's Introduction

这是一个go调用claude api的库

example1

package main

import (
	"context"
	"fmt"
	"github.com/Anyc66666666/claude-api"
	"log"
	"time"
)

func main() {
	chat := claude.New("xoxp-***f", "U05A5***", "C05EW***", time.Second*2, time.Second*45)
	ctx := context.Background()
	res, err := chat.Reply(ctx, "什么是claude")
	if err != nil {
		log.Println(err)
	}

	for {

		select {

		case data := <-res:
			if data.Error != nil {
				log.Println(data.Error)
				return
			}
			fmt.Println(data.Text)
			return

		}

	}
}

其他的例子可以详情看这里

授权以及获取user-token

网页(登录)后, 进入api配置页面(点我跳转)。

〉》点击 【Create an app】

​ 〉》主页看见Your Apps并弹出窗口【Create an app】 〉》 点击【From scratch】

​ 〉》填写app名称以及选择工作空间(例:name: Bot, workspace: chat) 〉》 点击【Create App】

​ 〉》点击左侧边栏上的【OAuth & Permissions】 〉》 下拉至【Scopes】卡片,在 【User Token Scopes】 项下添加权限,如下:

​ channels:history, channels:read, channels:write, groups:history, groups:read, groups:write,

​ chat:write, im:history, im:write, mpim:history, mpim:write

​ 〉》回到顶部【OAuth Tokens for Your Workspace】栏,点击【Install to Workspace】,然后确认授权即可

至此,获得拥有一定权限的user-token

截屏2023-04-18 09.10.56

截屏2023-04-18 09.14.41

获取 claude appid

截屏2023-04-18 08.49.20

注意事项

由于是Slack转接Claude,Slack是有限流机制读我。 目前使用的是web协议对接,文档说明似乎是1秒一个请求,后面可以尝试使用sock对接可拥有更多的请求流量。

Credits Thank you to:

claude-api's People

Contributors

anyc66666666 avatar bincooo avatar

Stargazers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.