poe_api

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2023 License: MIT Imports: 26 Imported by: 1

README

Golang Poe API

The golang version of https://github.com/ading2210/poe-api, used for the golang project to call poe api

The latest commit that is currently compatible is https://github.com/ading2210/poe-api/tree/7470d07b989af596293f24d0bcfc6315161505e0

Notice

As a single person, it can be challenging to keep up with the frequent API definition changes made by Poe in the ading2210/poe-api project. Therefore, welcome those with the necessary skills to contribute by submitting modifications directly via MR, rather than forking the code. This will help streamline the process and ensure that updates are efficiently implemented.

Instructions

install

go get github.com/lwydyby/poe-api

use


import (
"fmt"
"time"

"github.com/lwydyby/poe-api"
)


func ExampleSendMessage() {
	c := poe_api.NewClient("", nil)
	res, err := c.SendMessage("ChatGPT", "一句话描述golang的channel", true, 30*time.Second)
	if err != nil {
		panic(err)
	}
	// 等待全部返回后 直接返回全文
	fmt.Println(poe_api.GetFinalResponse(res))
	res, err = c.SendMessage("ChatGPT", "channel是并发安全的吗", false, 30*time.Second)
	if err != nil {
		panic(err)
	}
	// 流式返回 每次返回新增的数据
	for m := range poe_api.GetTextStream(res) {
		fmt.Println(m)
	}
	// output: 
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFinalResponse

func GetFinalResponse(ch <-chan map[string]interface{}) string

func GetPoint added in v1.0.2

func GetPoint[T Point](s T) *T

func GetTextStream

func GetTextStream(ch <-chan map[string]interface{}) <-chan string

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(token string, proxy *url.URL) *Client

func (*Client) CreateBot added in v1.0.2

func (c *Client) CreateBot(req CreateBot) map[string]interface{}

func (*Client) DeleteMessage

func (c *Client) DeleteMessage(messageIDs []int) error

func (*Client) EditBot added in v1.0.2

func (c *Client) EditBot(botID string, req CreateBot) map[string]interface{}

func (*Client) GetBots

func (c *Client) GetBots() map[string]string

func (*Client) GetMessageHistory

func (c *Client) GetMessageHistory(chatbot string, count int, cursor interface{}) ([]map[string]interface{}, error)

func (*Client) PurgeConversation

func (c *Client) PurgeConversation(chatbot string, count int) error

func (*Client) SendChatBreak

func (c *Client) SendChatBreak(chatbot string) (map[string]interface{}, error)

func (*Client) SendMessage

func (c *Client) SendMessage(chatbot, message string, withChatBreak bool, timeout time.Duration) (<-chan map[string]interface{}, error)

type CreateBot added in v1.0.2

type CreateBot struct {
	Handle            string
	Prompt            string
	DisplayName       string
	BaseModel         string
	Description       string
	IntroMessage      string
	ApiKey            *string
	ApiBot            bool
	ApiUrl            *string
	PromptPublic      *bool
	PfpUrl            *string
	Linkification     bool
	MarkdownRendering *bool
	SuggestedReplies  bool
	Private           bool
	Temperature       string
}

type InvalidToken added in v1.0.2

type InvalidToken struct {
	// contains filtered or unexported fields
}

func (*InvalidToken) Error added in v1.0.2

func (e *InvalidToken) Error() string

type Point added in v1.0.2

type Point interface {
	string | bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL