#api #api-request #api-wrapper #authorization #http-request #evil-corp #second-pilot

bin+lib evilcorp_secondpilot

EvilCorp SecondPilot API 的包装器

5 个版本 (稳定版)

2.3.0 2023年7月6日
2.2.0 2023年7月4日
2.1.0 2023年7月4日
2.0.0 2023年7月4日
0.1.0 2023年5月25日

#1919 in Web 编程


用于 axiograph

MIT 许可证

12KB
220 代码行

EvilCorp SecondPilot

EvilCorp SecondPilot API 的包装器,允许开发者在其自己的应用程序中利用其强大的自动完成和代码生成功能。此客户端使用了 futures-utilreqwestserde 等crate。

特性

  • 简化与 EvilCorp SecondPilot API 的交互。
  • 支持自定义 API 请求,包括模型、流、意图和其他参数。
  • 方便地处理 EvilCorp SecondPilot API 的授权。

用法

将此添加到您的 Cargo.toml

[dependencies]
evilcorp_secondpilot = "^2.0.0"

然后,导入库并使用 EvilcorpSecondPilotClient 结构体,如下所示

use evilcorp_secondpilot::{
    CompletionRequestBuilder,
    EvilcorpSecondPilotClient,
    Message,
};

let client =
    EvilcorpSecondPilotClient::new(
        "<your token>",
    );

let message = Message {
    content: "your message".to_string(),
    role: "user".to_string(),
};

let request = CompletionRequestBuilder::new()
    .with_model("<model>")
    .with_temperature(<temperature>)
    .with_top_p(<top_p>)
    .add_message(message)
    .build()
    .await;

let response = client.query(&request).await?;

println!("Response: {}", response);

结构

  • TokenResponse 是一个辅助结构体,用于包装 API 令牌端点的响应。
  • CompletionRequest 是一个辅助结构体,用于包装对补全端点的请求。
  • Message 是一个辅助结构体,用于包装要包含在 CompletionRequest 中的消息。
  • CompletionRequestBuilder 是一个结构体,用于帮助构建 CompletionRequest 对象。
  • CompletionResponseChoiceDelta 是辅助结构体,用于包装补全端点的响应。
  • EvilcorpSecondPilotClient 是与 EvilCorp SecondPilot API 通信的主要结构体。

许可证

本项目受 MIT 许可证的许可。


请注意,本项目与 EvilCorp 或其任何附属公司或子公司没有任何关联、授权、维护、赞助或认可。这是一个独立和非官方的 API 包装器。

依赖关系

~6–19MB
~282K SLoC