11// Generated by `wit-bindgen` 0.41.0. DO NOT EDIT!
22// Options used:
33// * runtime_path: "wit_bindgen_rt"
4+ /// Represents a single message in a chat conversation
5+ /// Used for both user input and assistant responses
46#[ derive( Clone ) ]
57pub struct ChatMessage {
8+ /// The role of the message sender: "user", "assistant", or "system"
69 pub role : _rt:: String ,
10+ /// The content/body of the message
711 pub content : _rt:: String ,
812}
913impl :: core:: fmt:: Debug for ChatMessage {
@@ -14,12 +18,21 @@ impl ::core::fmt::Debug for ChatMessage {
1418 . finish ( )
1519 }
1620}
21+ /// Configuration for a chat completion request to OpenAI
22+ /// Contains the conversation history and generation parameters
1723#[ derive( Clone ) ]
1824pub struct ChatCompletion {
25+ /// Unique identifier for this completion request
1926 pub id : _rt:: String ,
27+ /// The OpenAI model to use (e.g., "gpt-3.5-turbo", "gpt-4")
2028 pub model : _rt:: String ,
29+ /// List of messages in the conversation history
2130 pub messages : _rt:: Vec < ChatMessage > ,
31+ /// Controls randomness in the response (0.0 = deterministic, 2.0 = very random)
32+ /// Optional parameter - if not provided, uses model default
2233 pub temperature : Option < f64 > ,
34+ /// Maximum number of tokens to generate in the response
35+ /// Optional parameter - if not provided, uses model default
2336 pub max_tokens : Option < u32 > ,
2437}
2538impl :: core:: fmt:: Debug for ChatCompletion {
@@ -33,11 +46,17 @@ impl ::core::fmt::Debug for ChatCompletion {
3346 . finish ( )
3447 }
3548}
49+ /// Response from OpenAI's chat completion API
50+ /// Contains the generated text and metadata about the completion
3651#[ derive( Clone ) ]
3752pub struct ChatResponse {
53+ /// Unique identifier for this completion response
3854 pub id : _rt:: String ,
55+ /// The model that was used to generate the response
3956 pub model : _rt:: String ,
57+ /// The generated text content from the assistant
4058 pub content : _rt:: String ,
59+ /// Reason why the generation stopped: "stop", "length", "content_filter", etc.
4160 pub finish_reason : _rt:: String ,
4261}
4362impl :: core:: fmt:: Debug for ChatResponse {
@@ -50,9 +69,13 @@ impl ::core::fmt::Debug for ChatResponse {
5069 . finish ( )
5170 }
5271}
72+ /// Configuration for an embedding request to OpenAI
73+ /// Used to convert text into numerical vector representations
5374#[ derive( Clone ) ]
5475pub struct Embedding {
76+ /// The OpenAI embedding model to use (e.g., "text-embedding-ada-002")
5577 pub model : _rt:: String ,
78+ /// The text input to convert into an embedding vector
5679 pub input : _rt:: String ,
5780}
5881impl :: core:: fmt:: Debug for Embedding {
@@ -63,9 +86,14 @@ impl ::core::fmt::Debug for Embedding {
6386 . finish ( )
6487 }
6588}
89+ /// Response from OpenAI's embedding API
90+ /// Contains the numerical vector representation of the input text
6691#[ derive( Clone ) ]
6792pub struct EmbeddingResponse {
93+ /// The model that was used to generate the embedding
6894 pub model : _rt:: String ,
95+ /// The numerical vector representation of the input text
96+ /// Each number represents a dimension in the embedding space
6997 pub embedding : _rt:: Vec < f64 > ,
7098}
7199impl :: core:: fmt:: Debug for EmbeddingResponse {
@@ -302,7 +330,23 @@ pub unsafe fn __post_return_create_embedding<T: Guest>(arg0: *mut u8) {
302330 _rt:: cabi_dealloc ( base4, len4 * 8 , 8 ) ;
303331}
304332pub trait Guest {
333+ /// Creates a chat completion using OpenAI's API
334+ /// Sends a conversation to OpenAI and returns the assistant's response
335+ ///
336+ /// Parameters:
337+ /// - api-key: Your OpenAI API key for authentication
338+ /// - completion: The chat completion configuration and conversation
339+ ///
340+ /// Returns: The generated response from the assistant
305341 fn create_chat_completion ( api_key : _rt:: String , completion : ChatCompletion ) -> ChatResponse ;
342+ /// Creates an embedding vector using OpenAI's API
343+ /// Converts text into a numerical representation for semantic analysis
344+ ///
345+ /// Parameters:
346+ /// - api-key: Your OpenAI API key for authentication
347+ /// - embedding: The embedding configuration and input text
348+ ///
349+ /// Returns: The numerical vector representation of the input text
306350 fn create_embedding ( api_key : _rt:: String , embedding : Embedding ) -> EmbeddingResponse ;
307351}
308352#[ doc( hidden) ]
0 commit comments