1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! # client
//!
//! This module defines the `GHModels` client for interacting with the GitHub Models API.
//!
//! The client handles authentication using a GitHub personal access token (PAT) and provides
//! a method for sending chat completion requests to hosted models such as `openai/gpt-4o`.
//!
//! It is designed to be similar in usage to OpenAI's Python client, but tailored for Rust.
//!
//! ## Example
//!
//! ```rust
//! use gh_models::{GHModels, types::ChatMessage};
//! use std::env;
//!
//! #[tokio::main]
//! async fn main() {
//! let token = env::var("GITHUB_TOKEN").expect("Missing GITHUB_TOKEN");
//! let client = GHModels::new(token);
//!
//! let messages = vec![
//! ChatMessage { role: "system".into(), content: "You are a helpful assistant.".into() },
//! ChatMessage { role: "user".into(), content: "What is the capital of France?".into() },
//! ];
//!
//! let response = client.chat_completion("openai/gpt-4o", messages, 1.0, 4096, 1.0).await.unwrap();
//! println!("{}", response.choices[0].message.content);
//! }
//! ```
use Client;
use json;
use crate;
/// A client for interacting with GitHub-hosted AI models.
///
/// This struct handles authentication and sending chat completion requests
/// to the GitHub Models API.