@@ -23,15 +23,19 @@ Instantiate and use the client with the following:
2323import { FernFaiClient } from " @fern-api/fai-sdk" ;
2424
2525const client = new FernFaiClient ({ token: " YOUR_TOKEN" });
26- await client .queries .createQuery ({
27- query_id: " query_id" ,
28- conversation_id: " conversation_id" ,
29- domain: " domain" ,
30- text: " text" ,
31- role: " role" ,
32- source: " source" ,
33- created_at: " 2024-01-15T09:30:00Z" ,
34- time_to_first_token: undefined ,
26+ await client .chat .chatCompletion (" domain" , {
27+ model: undefined ,
28+ system_prompt: undefined ,
29+ messages: [
30+ {
31+ role: " role" ,
32+ text: " text" ,
33+ },
34+ {
35+ role: " role" ,
36+ text: " text" ,
37+ },
38+ ],
3539});
3640```
3741
@@ -57,7 +61,7 @@ will be thrown.
5761import { FernFaiError } from " @fern-api/fai-sdk" ;
5862
5963try {
60- await client .queries . createQuery (... );
64+ await client .chat . chatCompletion (... );
6165} catch (err ) {
6266 if (err instanceof FernFaiError ) {
6367 console .log (err .statusCode );
7579If you would like to send additional headers as part of the request, use the ` headers ` request option.
7680
7781``` typescript
78- const response = await client .queries . createQuery (... , {
82+ const response = await client .chat . chatCompletion (... , {
7983 headers: {
8084 ' X-Custom-Header' : ' custom value'
8185 }
@@ -97,7 +101,7 @@ A request is deemed retryable when any of the following HTTP status codes is ret
97101Use the ` maxRetries ` request option to configure this behavior.
98102
99103``` typescript
100- const response = await client .queries . createQuery (... , {
104+ const response = await client .chat . chatCompletion (... , {
101105 maxRetries: 0 // override maxRetries at the request level
102106});
103107```
@@ -107,7 +111,7 @@ const response = await client.queries.createQuery(..., {
107111The SDK defaults to a 60 second timeout. Use the ` timeoutInSeconds ` option to configure this behavior.
108112
109113``` typescript
110- const response = await client .queries . createQuery (... , {
114+ const response = await client .chat . chatCompletion (... , {
111115 timeoutInSeconds: 30 // override timeout to 30s
112116});
113117```
@@ -118,7 +122,7 @@ The SDK allows users to abort requests at any point by passing in an abort signa
118122
119123``` typescript
120124const controller = new AbortController ();
121- const response = await client .queries . createQuery (... , {
125+ const response = await client .chat . chatCompletion (... , {
122126 abortSignal: controller .signal
123127});
124128controller .abort (); // aborts the request
@@ -130,7 +134,7 @@ The SDK provides access to raw response data, including headers, through the `.w
130134The ` .withRawResponse() ` method returns a promise that results to an object with a ` data ` and a ` rawResponse ` property.
131135
132136``` typescript
133- const { data, rawResponse } = await client .queries . createQuery (... ).withRawResponse ();
137+ const { data, rawResponse } = await client .chat . chatCompletion (... ).withRawResponse ();
134138
135139console .log (data );
136140console .log (rawResponse .headers [' X-My-Header' ]);
0 commit comments