poe_api

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: MIT Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Golang Poe API

https://github.com/ading2210/poe-api 的golang版本

Notice

Fork from https://github.com/lwydyby/poe-api, 在此基础上进行了一些修改,并修复了一些bug

Instructions

install

go get github.com/Calcium-Ion/poe-api

use


import (
    "fmt"
    "log"
    "time"
    
    "github.com/Calcium-Ion/poe-api"
)


func ExampleSendMessage() {
    c, err := poe_api.NewClient("", nil)
    if err != nil {
    log.Printf("failed to create client: %v", err)
    }
	
    res, err := c.SendMessage("ChatGPT", "一句话描述golang的channel", true, 30*time.Second)
    if err != nil {
        log.Printf("failed to send message: %v", err)
    }
    fmt.Println(poe_api.GetFinalResponse(res))
	
	res, err = c.SendMessage("ChatGPT", "channel是并发安全的吗", false, 30*time.Second)
    if err != nil {
        log.Printf("failed to send message: %v", err)
    }
	// 流式返回 每次返回新增的数据
	for m := range poe_api.GetTextStream(res) {
		fmt.Println(m)
	}
}

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

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, error)

func (*Client) CreateBot

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

func (*Client) DeleteMessage

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

func (*Client) EditBot

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

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

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

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

func (*InvalidToken) Error

func (e *InvalidToken) Error() string

type Message

type Message struct {
	ChatID        float64       `json:"chatId"`
	Bot           string        `json:"bot"`
	Query         string        `json:"query"`
	Source        Source        `json:"source"`
	WithChatBreak bool          `json:"withChatBreak"`
	ClientNonce   string        `json:"clientNonce"`
	Sdid          string        `json:"sdid"`
	Attachments   []interface{} `json:"attachments"`
}

type Payload

type Payload struct {
	QueryName  string                 `json:"queryName"`
	Variables  interface{}            `json:"variables"`
	Extensions map[string]interface{} `json:"extensions"`
}

type Point

type Point interface {
	string | bool
}

type Source

type Source struct {
	SourceType        string                 `json:"sourceType"`
	ChatInputMetadata map[string]interface{} `json:"chatInputMetadata"`
}

type Subscription

type Subscription struct {
	SubscriptionName string      `json:"subscriptionName"`
	Query            interface{} `json:"query"`
	QueryHash        string      `json:"queryHash"`
}

type SubscriptionsMutation

type SubscriptionsMutation struct {
	Subscriptions []Subscription `json:"subscriptions"`
}

Jump to

Keyboard shortcuts

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