/ src / data / v1-chat.ts
v1-chat.ts
 1  /**
 2   * Generated by orval v7.9.0 🍺
 3   * Do not edit manually.
 4   * Cogni API
 5   * A minimal FastAPI that directly passes user queries to OpenAI, augmented with Cogni memory.
 6   * OpenAPI spec version: 0.1.0
 7   */
 8  import type {
 9    CompleteQueryRequest,
10    HTTPValidationError
11  } from './models';
12  
13  
14  
15  /**
16   * @summary Stream Chat
17   */
18  export type streamChatApiV1ChatPostResponse200 = {
19    data: unknown
20    status: 200
21  }
22  
23  export type streamChatApiV1ChatPostResponse422 = {
24    data: HTTPValidationError
25    status: 422
26  }
27      
28  export type streamChatApiV1ChatPostResponseComposite = streamChatApiV1ChatPostResponse200 | streamChatApiV1ChatPostResponse422;
29      
30  export type streamChatApiV1ChatPostResponse = streamChatApiV1ChatPostResponseComposite & {
31    headers: Headers;
32  }
33  
34  export const getStreamChatApiV1ChatPostUrl = () => {
35  
36  
37    
38  
39    return `/api/v1/chat`
40  }
41  
42  export const streamChatApiV1ChatPost = async (completeQueryRequest: CompleteQueryRequest, options?: RequestInit): Promise<streamChatApiV1ChatPostResponse> => {
43    
44    const res = await fetch(getStreamChatApiV1ChatPostUrl(),
45    {      
46      ...options,
47      method: 'POST',
48      headers: { 'Content-Type': 'application/json', ...options?.headers },
49      body: JSON.stringify(
50        completeQueryRequest,)
51    }
52  )
53  
54    const body = [204, 205, 304].includes(res.status) ? null : await res.text()
55    const data: streamChatApiV1ChatPostResponse['data'] = body ? JSON.parse(body) : {}
56  
57    return { data, status: res.status, headers: res.headers } as streamChatApiV1ChatPostResponse
58  }
59  
60