( requestBody: string, responseBody: string | undefined, )
| 966 | |
| 967 | // Converts a single HTTP exchange (request + response) into a normalized conversation |
| 968 | async function transformHttpExchange( |
| 969 | requestBody: string, |
| 970 | responseBody: string | undefined, |
| 971 | ): Promise<{ conversation: NormalizedConversation; model?: string }> { |
| 972 | const { request, response } = await parseHttpExchange( |
| 973 | requestBody, |
| 974 | responseBody, |
| 975 | ); |
| 976 | const messages = request.messages.map(transformOpenAIRequestMessage); |
| 977 | |
| 978 | if (response?.choices?.length) { |
| 979 | messages.push(...transformOpenAIResponseChoice(response.choices)); |
| 980 | } |
| 981 | |
| 982 | return { conversation: { messages }, model: request.model }; |
| 983 | } |
| 984 | |
| 985 | // Transforms a single OpenAI-style outbound request message into normalized form |
| 986 | // We use this to look up whether we already have a cached response for it |
no test coverage detected
searching dependent graphs…