Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions fern/apis/fai/definition/analytics.yml
Original file line number Diff line number Diff line change
@@ -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<datetime>
docs: The start date of the period to retrieve analytics for
end_date:
type: optional<datetime>
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<datetime>
docs: The start date of the period to retrieve analytics for
end_date:
type: optional<datetime>
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>

HistogramAnalyticsBar:
properties:
label: string
queryCount: integer
conversationCount: integer

Insights:
properties:
insights: list<Insight>

Insight:
properties:
insightText: string
numberOfQueries: integer
examples: list<string>

8 changes: 8 additions & 0 deletions fern/apis/fai/definition/api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: fai
auth: bearer
default-environment: Prod
environments:
Prod: https://fai.buildwithfern.com
error-discrimination:
strategy: property
property-name: error
35 changes: 35 additions & 0 deletions fern/apis/fai/definition/chat.yml
Original file line number Diff line number Diff line change
@@ -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<string>
system_prompt: optional<string>
messages: list<ChatTurn>
response: ChatCompletionResponse
errors:
- commons.BadRequestError
- commons.InternalError

types:
ChatCompletionResponse:
type: list<ChatTurn>

ChatTurn:
properties:
role: string
content: string
9 changes: 9 additions & 0 deletions fern/apis/fai/definition/commons.yml
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions fern/apis/fai/definition/conversations.yml
Original file line number Diff line number Diff line change
@@ -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<ConversationTurn>

Conversations:
type: list<Conversation>

ConversationSource:
default: CHAT
enum:
- CHAT
- MCP

ConversationTurn:
properties:
role: string
text: string
created_at: datetime
89 changes: 89 additions & 0 deletions fern/apis/fai/definition/index.yml
Original file line number Diff line number Diff line change
@@ -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<string>
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<string>
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<string>
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<string>
content: string
is_active: boolean
created_at: datetime
updated_at: datetime
74 changes: 74 additions & 0 deletions fern/apis/fai/definition/queries.yml
Original file line number Diff line number Diff line change
@@ -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<double>
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<integer>
limit: optional<integer>
cutoff_time: optional<datetime>
include_assistant: optional<boolean>
start_date:
type: optional<datetime>
docs: The start date of the period to retrieve analytics for
end_date:
type: optional<datetime>
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<double>

QueryPage:
properties:
queries: list<Query>
total: integer
13 changes: 13 additions & 0 deletions fern/apis/fai/generators.yml
Original file line number Diff line number Diff line change
@@ -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