Skip to content

Commit

Permalink
Merge pull request #384 from l3vels/fix/fastApiDocs
Browse files Browse the repository at this point in the history
Fix/fast api docs
  • Loading branch information
Chkhikvadze authored Dec 18, 2023
2 parents c38f52f + bcd5916 commit de00e53
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 31 deletions.
2 changes: 1 addition & 1 deletion apps/server/controllers/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_tools() -> List[ToolOutput]:
# return convert_tools_to_tool_list(db_tools)


@router.post("/run", response_model=ToolRunOutput)
@router.post("/run", response_model=ToolRunOutput, include_in_schema=False)
def run_tool(
input: ToolRunInput, auth: UserAccount = Depends(authenticate_by_token_or_api_key)
) -> ToolRunOutput:
Expand Down
4 changes: 2 additions & 2 deletions apps/server/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ def jwt_exception_handler(request: Request, exc: AuthJWTException):
app.include_router(config_router, prefix="/config", include_in_schema=False)
app.include_router(datasource_router, prefix="/datasource", include_in_schema=False)
app.include_router(run_router, prefix="/run", include_in_schema=False)
app.include_router(tool_router, prefix="/tool", include_in_schema=False)
app.include_router(tool_router, prefix="/tool", include_in_schema=True)
app.include_router(llm_router, prefix="/llm", include_in_schema=False)
app.include_router(chat_router, prefix="/chat", include_in_schema=True)
app.include_router(file_router, prefix="/file", include_in_schema=False)
app.include_router(model_router, prefix="/model", include_in_schema=False)
app.include_router(model_router, prefix="/model", include_in_schema=True)
app.include_router(schedule_router, prefix="/schedule", include_in_schema=False)
app.include_router(api_key_router, prefix="/api-key", include_in_schema=False)
app.include_router(integrations_router, prefix="/integrations", include_in_schema=False)
Expand Down
141 changes: 113 additions & 28 deletions apps/server/typings/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,122 @@ class InputModeType(List[str], Enum):


class AgentInput(BaseModel):
name: str
description: Optional[str]
agent_type: Optional[AgentType]
workspace_id: Optional[UUID4]
role: Optional[str]
is_memory: Optional[bool]
avatar: Optional[str]
is_template: bool
name: str = Field(..., example="Agent Smith")
description: Optional[str] = Field(None, example="Description of the agent")
agent_type: Optional[AgentType] = Field(
None,
example=AgentType.voice,
description="You have to choose between Text-based and Voice-based agents.",
)
workspace_id: Optional[UUID4] = Field(
None, example="123e4567-e89b-12d3-a456-426614174000"
)
role: Optional[str] = Field(
None, example="Speaker", description="A role can be anything of your choosing."
)
is_memory: Optional[bool] = Field(None, example=True)
avatar: Optional[str] = Field(
None,
example="https://raw.githubusercontent.com/l3vels/L3AGI/77d65c9ad74d4da140ef7a30590f063768333bd9/apps/ui/src/assets/tools/openweather.svg",
)
is_template: bool = Field(None, example=True)


class ConfigInput(BaseModel):
goals: List[str]
constraints: List[str]
tools: List[str]
datasources: List[str]
model: Optional[str]
temperature: float = Field(..., gt=0, lt=1.0)
instructions: List[str]
suggestions: Optional[List[str]]
greeting: Optional[str]
text: Optional[str]
integrations: Optional[List[dict]]
source_flow: Optional[DataSourceFlow]
synthesizer: Optional[str]
default_voice: Optional[str]
voice_id: Optional[str]
transcriber: Optional[str]
response_mode: Optional[List[str]]
input_mode: Optional[InputModeType]
runners: Optional[List[Dict]]
sentiment_analyzer: Optional[Dict]
goals: List[str] = Field(
...,
example=[
"Provide a concise summary or highlight about the sourced articles.",
"Efficiently locate relevant scientific articles from arxiv.org based on user queries.",
],
description="A list of goals that the agent aims to achieve. These goals can include providing summaries, locating relevant articles, or any other specific objectives.",
)
constraints: List[str] = Field(
...,
example=[
"Does not replace professional advice or expert consultations in respective fields.",
"Does not provide opinions or expert analysis. Presents only factual information based on sourced content.",
],
description="A list of constraints or limitations that the agent adheres to. These constraints can include not replacing professional advice, not providing opinions or expert analysis, and presenting only factual information based on sourced content.",
)
tools: List[str] = Field(
...,
example=[
"59209d41-83cf-48c5-806a-ec87a55cdcc4",
"ac34d174-6ca4-49cf-aef2-6e2cdf2e0028",
],
description="You should pass an array of Toolkit IDs.",
)
datasources: List[str] = Field(
...,
example=["0b9d648f-0fcb-4ced-8e08-502c5b8e0c06"],
description="You should pass an array of Data Source IDs which you have created.",
)
model: Optional[str] = Field(
None,
example="8833a90e-86e4-4118-9e28-517de1a4def8",
description="Expects Model ID",
)
temperature: float = Field(
...,
gt=0,
le=1.0,
example=0.5,
description="The temperature parameter for the agent. It should be a float value between 0 and 1, representing the level of randomness in the agent's responses. A higher value like 1.0 will result in more random responses, while a lower value like 0.5 will make the responses more focused and deterministic.",
)
instructions: List[str] = Field(
...,
example=[
"The more specific your inquiry, the more accurate Maven's assistance will be.",
"Efficiently locate relevant scientific articles from arxiv.org based on user queries.",
],
description="A list of instructions or guidance for interacting with the agent. These instructions can include tips on how to get more accurate assistance or specific guidelines for using certain features.",
)
suggestions: Optional[List[str]] = Field(
None,
example=[
"What's the weather like today?",
"Tell me a joke.",
"How can I contact customer support?",
],
description="An array of suggested dialogs or questions that users can choose from to interact with the system.",
)
greeting: Optional[str] = Field(
None,
example="Hello! I'm the ArXiv & Wikipedia Expert, your dedicated assistant for both academic research and general knowledge. How may I assist you today?",
description="A greeting message displayed by the assistant to welcome users and provide an introduction to its capabilities.",
)
text: Optional[str] = Field(None, example="text")
integrations: Optional[List[dict]] = Field(
None, example=[{"integration1": "value1"}, {"integration2": "value2"}]
)
source_flow: Optional[DataSourceFlow] = Field(
None,
example=DataSourceFlow.PRE_RETRIEVAL,
description="The flow of data source execution. Use `pre_execution` for pre-retrieval execution.",
)
synthesizer: Optional[str] = Field(
None,
example="b44769b1-1a20-44d3-b0f1-8b4c96e6a02a",
description="only on `voice-based` agents! <br/> Expects Voice Tool ID",
)
default_voice: Optional[str] = Field(None, example="default_voice")
voice_id: Optional[str] = Field(None, example="voice_id")
transcriber: Optional[str] = Field(
None,
example="transcriber",
description="only on `voice-based` agents! <br/> Expects Voice Tool ID",
)
response_mode: Optional[InputModeType] = Field(
None, example=InputModeType.text.value
)
input_mode: Optional[InputModeType] = Field(None, example=InputModeType.text.value)
runners: Optional[List[Dict]] = Field(
None, example=[{"runner1": "value1"}, {"runner2": "value2"}]
)
sentiment_analyzer: Optional[Dict] = Field(
None, example={"analyzer1": "value1", "analyzer2": "value2"}
)


class AgentConfigInput(BaseModel):
Expand Down

0 comments on commit de00e53

Please sign in to comment.