diff --git a/fern/apis/fai/definition/analytics.yml b/fern/apis/fai/definition/analytics.yml new file mode 100644 index 000000000..3c444f3dc --- /dev/null +++ b/fern/apis/fai/definition/analytics.yml @@ -0,0 +1,78 @@ +docs: FAI Analytics API + +imports: + commons: ./commons.yml + +service: + auth: false + base-path: /analytics + endpoints: + getHistogramAnalytics: + docs: Retrieve the usage histogram analytics for a given period + path: /histogram/{domain} + method: GET + path-parameters: + domain: string + request: + name: GetHistogramAnalyticsRequest + query-parameters: + start_date: + type: optional + docs: The start date of the period to retrieve analytics for + end_date: + type: optional + docs: The end date of the period to retrieve analytics for + groupBy: + type: GroupBy + docs: The field to group the analytics by + response: HistogramAnalytics + errors: + - commons.BadRequestError + - commons.InternalError + getInsights: + docs: Retrieve the insights for a given period + path: /insights/{domain} + method: GET + path-parameters: + domain: string + request: + name: GetInsightsRequest + query-parameters: + start_date: + type: optional + docs: The start date of the period to retrieve analytics for + end_date: + type: optional + docs: The end date of the period to retrieve analytics for + response: Insights + errors: + - commons.BadRequestError + - commons.InternalError + +types: + GroupBy: + enum: + - "DAY" + - "WEEK" + - "MONTH" + + HistogramAnalytics: + properties: + bars: list + + HistogramAnalyticsBar: + properties: + label: string + queryCount: integer + conversationCount: integer + + Insights: + properties: + insights: list + + Insight: + properties: + insightText: string + numberOfQueries: integer + examples: list + \ No newline at end of file diff --git a/fern/apis/fai/definition/api.yml b/fern/apis/fai/definition/api.yml new file mode 100644 index 000000000..e5b7ac2c7 --- /dev/null +++ b/fern/apis/fai/definition/api.yml @@ -0,0 +1,8 @@ +name: fai +auth: bearer +default-environment: Prod +environments: + Prod: https://fai.buildwithfern.com +error-discrimination: + strategy: property + property-name: error \ No newline at end of file diff --git a/fern/apis/fai/definition/chat.yml b/fern/apis/fai/definition/chat.yml new file mode 100644 index 000000000..e1da9df23 --- /dev/null +++ b/fern/apis/fai/definition/chat.yml @@ -0,0 +1,35 @@ +docs: FAI Chat API + +imports: + commons: ./commons.yml + +service: + auth: false + base-path: /chat + endpoints: + chatCompletion: + docs: Create a docs chat completion for a given domain + path: /{domain} + method: POST + path-parameters: + domain: string + request: + name: ChatCompletionRequest + body: + properties: + model: optional + system_prompt: optional + messages: list + response: ChatCompletionResponse + errors: + - commons.BadRequestError + - commons.InternalError + +types: + ChatCompletionResponse: + type: list + + ChatTurn: + properties: + role: string + content: string diff --git a/fern/apis/fai/definition/commons.yml b/fern/apis/fai/definition/commons.yml new file mode 100644 index 000000000..62d895dc2 --- /dev/null +++ b/fern/apis/fai/definition/commons.yml @@ -0,0 +1,9 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/fern-api/fern/main/fern.schema.json +errors: + BadRequestError: + status-code: 400 + type: string + + InternalError: + status-code: 401 + type: string diff --git a/fern/apis/fai/definition/conversations.yml b/fern/apis/fai/definition/conversations.yml new file mode 100644 index 000000000..40924adf2 --- /dev/null +++ b/fern/apis/fai/definition/conversations.yml @@ -0,0 +1,42 @@ +docs: FAI Conversations API + +imports: + commons: ./commons.yml + +service: + auth: false + base-path: /conversations + endpoints: + getConversation: + docs: Retrieve a complete conversation by conversation id + path: /{domain}/{conversation_id} + method: GET + path-parameters: + domain: string + conversation_id: string + response: Conversation + errors: + - commons.BadRequestError + - commons.InternalError + +types: + Conversation: + properties: + conversation_id: string + created_at: datetime + turns: list + + Conversations: + type: list + + ConversationSource: + default: CHAT + enum: + - CHAT + - MCP + + ConversationTurn: + properties: + role: string + text: string + created_at: datetime \ No newline at end of file diff --git a/fern/apis/fai/definition/index.yml b/fern/apis/fai/definition/index.yml new file mode 100644 index 000000000..1ae52a097 --- /dev/null +++ b/fern/apis/fai/definition/index.yml @@ -0,0 +1,89 @@ +docs: FAI Index API + +imports: + commons: ./commons.yml + +service: + auth: false + base-path: /index + endpoints: + indexDocument: + docs: Index a document for a given domain + path: /{domain} + method: POST + path-parameters: + domain: string + request: + name: IndexRequest + body: + properties: + index_name: + type: optional + default: custom + docs: The name of the index to which the document will be added + document_id: + type: string + docs: A unique identifier for the document + context: + type: list + docs: The context of the document, as a list of strings, that will be indexed. + content: + type: string + docs: The content of the document that will be returned in the tool response + errors: + - commons.BadRequestError + - commons.InternalError + + getDocument: + docs: Get a document for a given domain + path: /{domain} + method: GET + path-parameters: + domain: string + request: + name: GetRequest + query-parameters: + document_id: + type: string + docs: The unique identifier of the document to get + errors: + - commons.BadRequestError + - commons.InternalError + + updateDocument: + docs: Update a document for a given domain + path: /{domain}/update + method: POST + path-parameters: + domain: string + request: + name: UpdateRequest + query-parameters: + document_id: + type: string + docs: The unique identifier of the document to update + is_active: + type: boolean + docs: Whether the document is active + context: + type: list + docs: The context of the document, as a list of strings, that will be indexed. + content: + type: string + docs: The content of the document that will be returned in the tool response. If not provided, the document will be removed from the index. + response: ContextResponse + errors: + - commons.BadRequestError + - commons.InternalError + +types: + ContextResponse: + properties: + document_id: string + domain: string + context_id: string + context: list + content: string + is_active: boolean + created_at: datetime + updated_at: datetime \ No newline at end of file diff --git a/fern/apis/fai/definition/queries.yml b/fern/apis/fai/definition/queries.yml new file mode 100644 index 000000000..d84bec630 --- /dev/null +++ b/fern/apis/fai/definition/queries.yml @@ -0,0 +1,74 @@ +docs: FAI Queries API + +imports: + commons: ./commons.yml + conversations: ./conversations.yml + +service: + auth: false + base-path: / + endpoints: + createQuery: + docs: Log a new query to the FAI DB + path: /queries + method: POST + request: + name: CreateQueryRequest + body: + properties: + query_id: string + conversation_id: string + domain: string + text: string + role: string + source: string + created_at: datetime + time_to_first_token: + type: optional + docs: Time in seconds until first token was received. Only specified for Assistant responses. + errors: + - commons.BadRequestError + - commons.InternalError + + getRecentQueries: + docs: Retrieve all paginated recent queries + path: /queries/{domain} + method: GET + path-parameters: + domain: + type: string + docs: The domain to retrieve queries for + request: + name: GetRecentQueriesRequest + query-parameters: + page: optional + limit: optional + cutoff_time: optional + include_assistant: optional + start_date: + type: optional + docs: The start date of the period to retrieve analytics for + end_date: + type: optional + docs: The end date of the period to retrieve analytics for + response: QueryPage + errors: + - commons.BadRequestError + - commons.InternalError + +types: + Query: + properties: + query_id: string + conversation_id: string + domain: string + text: string + role: string + source: string + created_at: datetime + time_to_first_token: optional + + QueryPage: + properties: + queries: list + total: integer \ No newline at end of file diff --git a/fern/apis/fai/generators.yml b/fern/apis/fai/generators.yml new file mode 100644 index 000000000..74c15fd57 --- /dev/null +++ b/fern/apis/fai/generators.yml @@ -0,0 +1,13 @@ +default-group: local + +groups: + local: + generators: + - name: fernapi/fern-typescript-node-sdk + version: 2.0.0 + output: + location: npm + url: npm.buildwithfern.com + package-name: "@fern-api/fai-sdk" + github: + repository: fern-api/fai-sdk