anthropic

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Deprecated: 不再维护,逐步迁移到 github.com/MeowSalty/pinai/handlers/multi 包。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListModels

func ListModels(c *fiber.Ctx) error

ListModels 处理获取可用模型列表的请求 @Summary 列出模型 @Description 获取所有可用的 AI 模型列表 @Tags Anthropic @Accept json @Produce json @Success 200 {object} ModelList @Failure 500 {object} fiber.Map @Router /anthropic/v1/models [get]

func SetupAnthropicRoutes

func SetupAnthropicRoutes(router fiber.Router, portalService portal.Service, userAgent string)

SetupAnthropicRoutes 注册 Anthropic 兼容路由。

Types

type AnthropicHandler

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

AnthropicHandler 结构体定义了 Anthropic 兼容 API 的处理器

该结构体封装了处理 Anthropic 兼容 API 请求所需的服务和日志记录器

func New

func New(portal portal.Service, userAgent string) *AnthropicHandler

New 创建并初始化一个新的 Anthropic API 处理器实例

该函数使用依赖注入的方式创建 AnthropicHandler 实例

参数:

  • portal: AI 网关服务实例,用于处理 AI 相关请求
  • userAgent: User-Agent 配置,空则透传客户端 UA,"default" 使用 fasthttp 默认值,其他字符串则复写

返回值:

  • *AnthropicHandler: 初始化后的 Anthropic 处理器实例

func (*AnthropicHandler) Messages

func (h *AnthropicHandler) Messages(c *fiber.Ctx) error

Messages 处理消息完成请求 @Summary 消息完成 @Description 创建消息完成响应 @Tags Anthropic @Accept json @Produce json @Param request body anthropicTypes.MessageRequest true "消息请求" @Success 200 {object} anthropicTypes.MessageResponse @Failure 400 {object} fiber.Map @Failure 401 {object} fiber.Map @Failure 500 {object} fiber.Map @Router /anthropic/v1/messages [post]

type Model

type Model struct {
	ID      string `json:"id"`       // 模型 ID
	Object  string `json:"object"`   // 对象类型,通常是 "model"
	Created int64  `json:"created"`  // 创建时间戳
	OwnedBy string `json:"owned_by"` // 模型所有者
}

Model 结构体定义了 Anthropic 兼容的模型信息

type ModelList

type ModelList struct {
	Object string  `json:"object"` // 对象类型,通常是 "list"
	Data   []Model `json:"data"`   // 模型列表
}

ModelList 结构体定义了模型列表响应格式

Jump to

Keyboard shortcuts

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