pub struct Doubao {
    prompts: Vec<Value>,
    id: usize,
    status: LifeStatus,
    role: Identity,
    res: String,
    username: String,
    tokens: (u64, u64),
}

Fields§

§prompts: Vec<Value>§id: usize§status: LifeStatus§role: Identity§res: String§username: String§tokens: (u64, u64)

Implementations§

source§

impl Doubao

source

pub fn new() -> Self

source

fn push(&mut self, msg: String)

source

async fn async_get_res(&mut self) -> Result<(), Box<dyn Error>>

向大模型 api 请求并获得回应。

source

fn get_res(&mut self)

发送之前的所有信息提供给大模型并获得回复,不懂异步,直接阻塞。

Trait Implementations§

source§

impl Responder for Doubao

source§

fn send(&mut self, _msg: &str)

发送原始信息。ai 玩家不需要原始信息。
source§

fn rec(&mut self) -> String

接收一条原始信息。ai 玩家不需要接收原始信息。
source§

fn send_number(&mut self, _x: usize)

默认实现发送数字,开头以 n 标记。
source§

fn rec_number(&mut self) -> usize

接收一个数字。
source§

fn send_begin(&mut self)

表示和一个应答者通话的开始。
source§

fn send_end(&mut self)

表示一次等待的结束作为结束。
source§

fn send_msg(&mut self, msg: &str)

用于发送直接显示在客户端上的消息,函数会在开头以 m 标记。
source§

fn rec_text(&mut self) -> String

接收文本。文本会被以 t 开头标记。
source§

fn send_json(&mut self, _jstr: &str)

传入原始 json 字符串,会被标记为 j 发送。
source§

fn vote(&mut self, msg: &str, list: Vec<(usize, String)>) -> (String, usize)

投票。返回 (详情字符串, 选票指向的 id)。
注意投票需要开始信号,因为平票多次投票中,玩家只多次响应单次投票,而把详细信息当作普通信息显示。
source§

fn role(&self) -> Identity

source§

fn set_role(&mut self, r: Identity)

source§

fn status(&self) -> LifeStatus

source§

fn set_status(&mut self, s: LifeStatus)

source§

fn set_name(&mut self)

source§

fn name(&self) -> String

source§

fn set_id(&mut self, id: usize)

source§

fn get_id(&self) -> usize

source§

fn coutinue_game(&mut self)

在玩家端游戏结束判定时发送继续游戏。其实只是发送一个结束信号。
source§

fn cost(&self) -> (u64, u64)

source§

fn game_over(&mut self, msg: String)

在玩家端结束游戏判定时发送游戏结束信息。其实只是发送一条获胜信息。

Auto Trait Implementations§

§

impl Freeze for Doubao

§

impl RefUnwindSafe for Doubao

§

impl Send for Doubao

§

impl Sync for Doubao

§

impl Unpin for Doubao

§

impl UnwindSafe for Doubao

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more