Skip to content
This repository was archived by the owner on Jul 9, 2024. It is now read-only.
This repository was archived by the owner on Jul 9, 2024. It is now read-only.

how to use functions feature within continuous conversation #70

@For-December

Description

@For-December

Thank you for developing this powerful lib!
It always works well, but when I try to use functions feature, I' m in trouble.
I want to fulfill a continuous conversation with functions feature, for instance:

  • ask chatGPT what' s the time
  • chatGPT call my function to get current time
  • then chatGPT reply to me with the time that my function returns

Just like the example: https://openai.com/blog/function-calling-and-other-api-updates
image

Here is my test code:

  // build conversation and send to openAI
  conversation.add_function(get_current_time()).unwrap();
  let res = conversation
      .send_message_functions(ask)  // ask is "what' s the time now?"
      .await
      .unwrap()
      .message_choices;

about get_current_time:

/// get current time
///
/// * time - the time that user asks
#[gpt_function]
async fn get_current_time(time: String) -> Value {
    println!("AI uses param: {time}");
    return Ok(json!({
        "time":"10:30"
    }));
}

my function ( get_current_time ) was called successfully, but I could' t get a expected reply about current time.

message_functions' length is 1, content is empty str
called message().content also return empty str

history like this:
image

maybe need this?( I guess...)
image
and when I called send_message_functions again, error occur:
image

I tried again and again, but couldn't be able to solve it, hope to get help

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions