mirror of
https://github.com/mii443/openai-api-rs.git
synced 2025-12-04 11:38:22 +00:00
Fix readme
This commit is contained in:
@@ -26,7 +26,7 @@ let client = Client::new(env::var("OPENAI_API_KEY").unwrap().to_string());
|
|||||||
### Create request
|
### Create request
|
||||||
```rust
|
```rust
|
||||||
let req = ChatCompletionRequest::new(
|
let req = ChatCompletionRequest::new(
|
||||||
GPT4.to_string(),
|
GPT4_O.to_string(),
|
||||||
vec![chat_completion::ChatCompletionMessage {
|
vec![chat_completion::ChatCompletionMessage {
|
||||||
role: chat_completion::MessageRole::user,
|
role: chat_completion::MessageRole::user,
|
||||||
content: chat_completion::Content::Text(String::from("What is bitcoin?")),
|
content: chat_completion::Content::Text(String::from("What is bitcoin?")),
|
||||||
@@ -50,14 +50,14 @@ $ export OPENAI_API_BASE=https://api.openai.com/v1
|
|||||||
```rust
|
```rust
|
||||||
use openai_api_rs::v1::api::Client;
|
use openai_api_rs::v1::api::Client;
|
||||||
use openai_api_rs::v1::chat_completion::{self, ChatCompletionRequest};
|
use openai_api_rs::v1::chat_completion::{self, ChatCompletionRequest};
|
||||||
use openai_api_rs::v1::common::GPT4;
|
use openai_api_rs::v1::common::GPT4_O;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().to_string());
|
let client = Client::new(env::var("OPENAI_API_KEY").unwrap().to_string());
|
||||||
|
|
||||||
let req = ChatCompletionRequest::new(
|
let req = ChatCompletionRequest::new(
|
||||||
GPT4.to_string(),
|
GPT4_O.to_string(),
|
||||||
vec![chat_completion::ChatCompletionMessage {
|
vec![chat_completion::ChatCompletionMessage {
|
||||||
role: chat_completion::MessageRole::user,
|
role: chat_completion::MessageRole::user,
|
||||||
content: chat_completion::Content::Text(String::from("What is bitcoin?")),
|
content: chat_completion::Content::Text(String::from("What is bitcoin?")),
|
||||||
|
|||||||
Reference in New Issue
Block a user