mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
* agents - phase 1 (#30) * chore: copy assistant files * feat: frontend and data-provider * feat: backend get endpoint test * fix(MessageEndpointIcon): switched to AgentName and AgentAvatar * fix: small fixes * fix: agent endpoint config * fix: show Agent Builder * chore: install agentus * chore: initial scaffolding for agents * fix: updated Assistant logic to Agent Logic for some Agent components * WIP first pass, demo of agent package * WIP: initial backend infra for agents * fix: agent list error * wip: agents routing * chore: Refactor useSSE hook to handle different data events * wip: correctly emit events * chore: Update @librechat/agentus npm dependency to version 1.0.9 * remove comment * first pass: streaming agent text * chore: Remove @librechat/agentus root-level workspace npm dependency * feat: Agent Schema and Model * fix: content handling fixes * fix: content message save * WIP: new content data * fix: run step issue with tool calls * chore: Update @librechat/agentus npm dependency to version 1.1.5 * feat: update controller and agent routes * wip: initial backend tool and tool error handling support * wip: tool chunks * chore: Update @librechat/agentus npm dependency to version 1.1.7 * chore: update tool_call typing, add test conditions and logs * fix: create agent * fix: create agent * first pass: render completed content parts * fix: remove logging, fix step handler typing * chore: Update @librechat/agentus npm dependency to version 1.1.9 * refactor: cleanup maps on unmount * chore: Update BaseClient.js to safely count tokens for string, number, and boolean values * fix: support subsequent messages with tool_calls * chore: export order * fix: select agent * fix: tool call types and handling * chore: switch to anthropic for testing * fix: AgentSelect * refactor: experimental: OpenAIClient to use array for intermediateReply * fix(useSSE): revert old condition for streaming legacy client tokens * fix: lint * revert `agent_id` to `id` * chore: update localization keys for agent-related components * feat: zod schema handling for actions * refactor(actions): if no params, no zodSchema * chore: Update @librechat/agentus npm dependency to version 1.2.1 * feat: first pass, actions * refactor: empty schema for actions without params * feat: Update createRun function to accept additional options * fix: message payload formatting; feat: add more client options * fix: ToolCall component rendering when action has no args but has output * refactor(ToolCall): allow non-stringy args * WIP: first pass, correctly formatted tool_calls between providers * refactor: Remove duplicate import of 'roles' module * refactor: Exclude 'vite.config.ts' from TypeScript compilation * refactor: fix agent related types > - no need to use endpoint/model fields for identifying agent metadata > - add `provider` distinction for agent-configured 'endpoint' - no need for agent-endpoint map - reduce complexity of tools as functions into tools as string[] - fix types related to above changes - reduce unnecessary variables for queries/mutations and corresponding react-query keys * refactor: Add tools and tool_kwargs fields to agent schema * refactor: Remove unused code and update dependencies * refactor: Update updateAgentHandler to use req.body directly * refactor: Update AgentSelect component to use localized hooks * refactor: Update agent schema to include tools and provider fields * refactor(AgentPanel): add scrollbar gutter, add provider field to form, fix agent schema required values * refactor: Update AgentSwitcher component to use selectedAgentId instead of selectedAgent * refactor: Update AgentPanel component to include alternateName import and defaultAgentFormValues * refactor(SelectDropDown): allow setting value as option while still supporting legacy usage (string values only) * refactor: SelectDropdown changes - Only necessary when the available values are objects with label/value fields and the selected value is expected to be a string. * refactor: TypeError issues and handle provider as option * feat: Add placeholder for provider selection in AgentPanel component * refactor: Update agent schema to include author and provider fields * fix: show expected 'create agent' placeholder when creating agent * chore: fix localization strings, hide capabilities form for now * chore: typing * refactor: import order and use compact agents schema for now * chore: typing * refactor: Update AgentForm type to use AgentCapabilities * fix agent form agent selection issues * feat: responsive agent selection * fix: Handle cancelled fetch in useSelectAgent hook * fix: reset agent form on accordion close/open * feat: Add agent_id to default conversation for agents endpoint * feat: agents endpoint request handling * refactor: reset conversation model on agent select * refactor: add `additional_instructions` to conversation schema, organize other fields * chore: casing * chore: types * refactor(loadAgentTools): explicitly pass agent_id, do not pass `model` to loadAgentTools for now, load action sets by agent_id * WIP: initial draft of real agent client initialization * WIP: first pass, anthropic agent requests * feat: remember last selected agent * feat: openai and azure connected * fix: prioritize agent model for runs unless an explicit override model is passed from client * feat: Agent Actions * fix: save agent id to convo * feat: model panel (#29) * feat: model panel * bring back comments * fix: method still null * fix: AgentPanel FormContext * feat: add more parameters * fix: style issues; refactor: Agent Controller * fix: cherry-pick * fix: Update AgentAvatar component to use AssistantIcon instead of BrainCircuit * feat: OGDialog for delete agent; feat(assistant): update Agent types, introduced `model_parameters` * feat: icon and general `model_parameters` update * feat: use react-hook-form better * fix: agent builder form reset issue when switching panels * refactor: modularize agent builder form --------- Co-authored-by: Danny Avila <danny@librechat.ai> * fix: AgentPanel and ModelPanel type issues and use `useFormContext` and `watch` instead of `methods` directly and `useWatch`. * fix: tool call issues due to invalid input (anthropic) of empty string * fix: handle empty text in Part component --------- Co-authored-by: Marco Beretta <81851188+berry-13@users.noreply.github.com> * refactor: remove form ModelPanel and fixed nested ternary expressions in AgentConfig * fix: Model Parameters not saved correctly * refactor: remove console log * feat: avatar upload and get for Agents (#36) Co-authored-by: Marco Beretta <81851188+berry-13@users.noreply.github.com> * chore: update to public package * fix: typing, optional chaining * fix: cursor not showing for content parts * chore: conditionally enable agents * ci: fix azure test * ci: fix frontend tests, fix eslint api * refactor: Remove unused errorContentPart variable * continue of the agent message PR (#40) * last fixes * fix: agentMap * pr merge test (#41) * fix: model icon not fetching correctly * remove console logs * feat: agent name * refactor: pass documentsMap as a prop to allow re-render of assistant form * refactor: pass documentsMap as a prop to allow re-render of assistant form * chore: Bump version to 0.7.419 * fix: TypeError: Cannot read properties of undefined (reading 'id') * refactor: update AgentSwitcher component to use ControlCombobox instead of Combobox --------- Co-authored-by: Marco Beretta <81851188+berry-13@users.noreply.github.com>
477 lines
13 KiB
TypeScript
477 lines
13 KiB
TypeScript
import { OpenAPIV3 } from 'openapi-types';
|
|
|
|
export type FlowchartSchema = {
|
|
mermaid: {
|
|
type: 'string';
|
|
description: 'Flowchart to be rendered, in Mermaid syntax';
|
|
};
|
|
title: {
|
|
type: 'string';
|
|
description: 'Title of the flowchart';
|
|
};
|
|
};
|
|
|
|
export const getWeatherOpenapiSpec: OpenAPIV3.Document = {
|
|
openapi: '3.1.0',
|
|
info: {
|
|
title: 'Get weather data',
|
|
description: 'Retrieves current weather data for a location.',
|
|
version: 'v1.0.0',
|
|
},
|
|
servers: [
|
|
{
|
|
url: 'https://weather.example.com',
|
|
},
|
|
],
|
|
paths: {
|
|
'/location': {
|
|
get: {
|
|
description: 'Get temperature for a specific location',
|
|
operationId: 'GetCurrentWeather',
|
|
parameters: [
|
|
{
|
|
name: 'location',
|
|
in: 'query',
|
|
description: 'The city and state to retrieve the weather for',
|
|
required: true,
|
|
schema: {
|
|
type: 'string',
|
|
},
|
|
},
|
|
],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
type: 'object',
|
|
properties: {
|
|
locations: {
|
|
type: 'array',
|
|
items: {
|
|
type: 'object',
|
|
properties: {
|
|
city: {
|
|
type: 'string',
|
|
example: 'San Francisco',
|
|
},
|
|
state: {
|
|
type: 'string',
|
|
example: 'CA',
|
|
},
|
|
countryCode: {
|
|
type: 'string',
|
|
description: 'ISO 3166-1 alpha-2 country code',
|
|
example: 'US',
|
|
},
|
|
time: {
|
|
type: 'string',
|
|
description:
|
|
'Optional time for which the weather is requested, in ISO 8601 format.',
|
|
example: '2023-12-04T14:00:00Z',
|
|
},
|
|
},
|
|
required: ['city', 'state', 'countryCode'],
|
|
description:
|
|
'Details of the location for which the weather data is requested.',
|
|
},
|
|
description: 'A list of locations to retrieve the weather for.',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
deprecated: false,
|
|
responses: {},
|
|
},
|
|
},
|
|
},
|
|
components: {
|
|
schemas: {},
|
|
},
|
|
};
|
|
|
|
export const whimsicalOpenapiSpec: OpenAPIV3.Document = {
|
|
openapi: '3.0.0',
|
|
info: {
|
|
version: '1.0.0',
|
|
title: 'Diagram to Image API',
|
|
description: 'A simple API to generate flowchart, mindmap, or sequence diagram images.',
|
|
},
|
|
servers: [{ url: 'https://whimsical.com/api' }],
|
|
paths: {
|
|
'/ai.chatgpt.render-flowchart': {
|
|
post: {
|
|
operationId: 'postRenderFlowchart',
|
|
// 'x-openai-isConsequential': false,
|
|
summary: 'Renders a flowchart',
|
|
description:
|
|
'Accepts a string describing a flowchart and returns a URL to a rendered image',
|
|
requestBody: {
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
$ref: '#/components/schemas/FlowchartRequest',
|
|
},
|
|
},
|
|
},
|
|
required: true,
|
|
},
|
|
responses: {
|
|
'200': {
|
|
description: 'URL to the rendered image',
|
|
content: {
|
|
'application/json': {
|
|
schema: {
|
|
$ref: '#/components/schemas/FlowchartResponse',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
components: {
|
|
schemas: {
|
|
FlowchartRequest: {
|
|
type: 'object',
|
|
properties: {
|
|
mermaid: {
|
|
type: 'string',
|
|
description: 'Flowchart to be rendered, in Mermaid syntax',
|
|
},
|
|
title: {
|
|
type: 'string',
|
|
description: 'Title of the flowchart',
|
|
},
|
|
},
|
|
required: ['mermaid'],
|
|
},
|
|
FlowchartResponse: {
|
|
type: 'object',
|
|
properties: {
|
|
imageURL: {
|
|
type: 'string',
|
|
description: 'URL of the rendered image',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
export const scholarAIOpenapiSpec = `
|
|
openapi: 3.0.1
|
|
info:
|
|
title: ScholarAI
|
|
description: Allows the user to search facts and findings from scientific articles
|
|
version: 'v1'
|
|
servers:
|
|
- url: https://scholar-ai.net
|
|
paths:
|
|
/api/abstracts:
|
|
get:
|
|
operationId: searchAbstracts
|
|
summary: Get relevant paper abstracts by keywords search
|
|
parameters:
|
|
- name: keywords
|
|
in: query
|
|
description: Keywords of inquiry which should appear in article. Must be in English.
|
|
required: true
|
|
schema:
|
|
type: string
|
|
- name: sort
|
|
in: query
|
|
description: The sort order for results. Valid values are cited_by_count or publication_date. Excluding this value does a relevance based search.
|
|
required: false
|
|
schema:
|
|
type: string
|
|
enum:
|
|
- cited_by_count
|
|
- publication_date
|
|
- name: query
|
|
in: query
|
|
description: The user query
|
|
required: true
|
|
schema:
|
|
type: string
|
|
- name: peer_reviewed_only
|
|
in: query
|
|
description: Whether to only return peer reviewed articles. Defaults to true, ChatGPT should cautiously suggest this value can be set to false
|
|
required: false
|
|
schema:
|
|
type: string
|
|
- name: start_year
|
|
in: query
|
|
description: The first year, inclusive, to include in the search range. Excluding this value will include all years.
|
|
required: false
|
|
schema:
|
|
type: string
|
|
- name: end_year
|
|
in: query
|
|
description: The last year, inclusive, to include in the search range. Excluding this value will include all years.
|
|
required: false
|
|
schema:
|
|
type: string
|
|
- name: offset
|
|
in: query
|
|
description: The offset of the first result to return. Defaults to 0.
|
|
required: false
|
|
schema:
|
|
type: string
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/searchAbstractsResponse'
|
|
/api/fulltext:
|
|
get:
|
|
operationId: getFullText
|
|
summary: Get full text of a paper by URL for PDF
|
|
parameters:
|
|
- name: pdf_url
|
|
in: query
|
|
description: URL for PDF
|
|
required: true
|
|
schema:
|
|
type: string
|
|
- name: chunk
|
|
in: query
|
|
description: chunk number to retrieve, defaults to 1
|
|
required: false
|
|
schema:
|
|
type: number
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/getFullTextResponse'
|
|
/api/save-citation:
|
|
get:
|
|
operationId: saveCitation
|
|
summary: Save citation to reference manager
|
|
parameters:
|
|
- name: doi
|
|
in: query
|
|
description: Digital Object Identifier (DOI) of article
|
|
required: true
|
|
schema:
|
|
type: string
|
|
- name: zotero_user_id
|
|
in: query
|
|
description: Zotero User ID
|
|
required: true
|
|
schema:
|
|
type: string
|
|
- name: zotero_api_key
|
|
in: query
|
|
description: Zotero API Key
|
|
required: true
|
|
schema:
|
|
type: string
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/saveCitationResponse'
|
|
components:
|
|
schemas:
|
|
searchAbstractsResponse:
|
|
type: object
|
|
properties:
|
|
next_offset:
|
|
type: number
|
|
description: The offset of the next page of results.
|
|
total_num_results:
|
|
type: number
|
|
description: The total number of results.
|
|
abstracts:
|
|
type: array
|
|
items:
|
|
type: object
|
|
properties:
|
|
title:
|
|
type: string
|
|
abstract:
|
|
type: string
|
|
description: Summary of the context, methods, results, and conclusions of the paper.
|
|
doi:
|
|
type: string
|
|
description: The DOI of the paper.
|
|
landing_page_url:
|
|
type: string
|
|
description: Link to the paper on its open-access host.
|
|
pdf_url:
|
|
type: string
|
|
description: Link to the paper PDF.
|
|
publicationDate:
|
|
type: string
|
|
description: The date the paper was published in YYYY-MM-DD format.
|
|
relevance:
|
|
type: number
|
|
description: The relevance of the paper to the search query. 1 is the most relevant.
|
|
creators:
|
|
type: array
|
|
items:
|
|
type: string
|
|
description: The name of the creator.
|
|
cited_by_count:
|
|
type: number
|
|
description: The number of citations of the article.
|
|
description: The list of relevant abstracts.
|
|
getFullTextResponse:
|
|
type: object
|
|
properties:
|
|
full_text:
|
|
type: string
|
|
description: The full text of the paper.
|
|
pdf_url:
|
|
type: string
|
|
description: The PDF URL of the paper.
|
|
chunk:
|
|
type: number
|
|
description: The chunk of the paper.
|
|
total_chunk_num:
|
|
type: number
|
|
description: The total chunks of the paper.
|
|
saveCitationResponse:
|
|
type: object
|
|
properties:
|
|
message:
|
|
type: string
|
|
description: Confirmation of successful save or error message.`;
|
|
|
|
export const swapidev = `
|
|
openapi: 3.0.3
|
|
info:
|
|
title: Star Wars API
|
|
description: This is a simple API that provides information about the Star Wars universe.
|
|
version: 1.0.0
|
|
servers:
|
|
- url: https://swapi.dev
|
|
|
|
paths:
|
|
/api/people:
|
|
get:
|
|
summary: List all people
|
|
operationId: getPeople
|
|
tags:
|
|
- People
|
|
responses:
|
|
'200':
|
|
description: A list of people
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
properties:
|
|
count:
|
|
type: integer
|
|
example: 82
|
|
next:
|
|
type: string
|
|
nullable: true
|
|
example: https://swapi.dev/api/people/?page=2
|
|
previous:
|
|
type: string
|
|
nullable: true
|
|
example: null
|
|
results:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/Person'
|
|
|
|
/api/people/{id}:
|
|
get:
|
|
summary: Get a person by ID
|
|
operationId: getPersonById
|
|
tags:
|
|
- People
|
|
parameters:
|
|
- name: id
|
|
in: path
|
|
required: true
|
|
description: The ID of the person to retrieve
|
|
schema:
|
|
type: string
|
|
responses:
|
|
'200':
|
|
description: A single person
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Person'
|
|
'404':
|
|
description: Person not found
|
|
|
|
components:
|
|
schemas:
|
|
Person:
|
|
type: object
|
|
properties:
|
|
name:
|
|
type: string
|
|
example: Luke Skywalker
|
|
height:
|
|
type: string
|
|
example: "172"
|
|
mass:
|
|
type: string
|
|
example: "77"
|
|
hair_color:
|
|
type: string
|
|
example: blond
|
|
skin_color:
|
|
type: string
|
|
example: fair
|
|
eye_color:
|
|
type: string
|
|
example: blue
|
|
birth_year:
|
|
type: string
|
|
example: "19BBY"
|
|
gender:
|
|
type: string
|
|
example: male
|
|
homeworld:
|
|
type: string
|
|
example: https://swapi.dev/api/planets/1/
|
|
films:
|
|
type: array
|
|
items:
|
|
type: string
|
|
example: https://swapi.dev/api/films/1/
|
|
species:
|
|
type: array
|
|
items:
|
|
type: string
|
|
example: https://swapi.dev/api/species/1/
|
|
vehicles:
|
|
type: array
|
|
items:
|
|
type: string
|
|
example: https://swapi.dev/api/vehicles/14/
|
|
starships:
|
|
type: array
|
|
items:
|
|
type: string
|
|
example: https://swapi.dev/api/starships/12/
|
|
created:
|
|
type: string
|
|
format: date-time
|
|
example: 2014-12-09T13:50:51.644000Z
|
|
edited:
|
|
type: string
|
|
format: date-time
|
|
example: 2014-12-20T21:17:56.891000Z
|
|
url:
|
|
type: string
|
|
example: https://swapi.dev/api/people/1/`;
|