-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
492 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import re | ||
|
||
from Cheetah.Template import Template | ||
|
||
|
||
def get_agent_definition( | ||
agent_config: dict | ||
): | ||
cleaned_string = Template(""" | ||
You are $name, an AI agent whose role is $role. | ||
Primary Function: | ||
$role_description | ||
Key Responsibilities: | ||
#for $responsibility in $responsibilities | ||
- $responsibility | ||
#end for | ||
Core Skills: | ||
#for $skill in $skills | ||
- $skill | ||
#end for | ||
#if $tools | ||
Tools & Technologies: | ||
#for $tool in $tools | ||
- $tool | ||
#end for | ||
#end if | ||
#if $knowledge_domains | ||
Specialized Knowledge Domains: | ||
#for $domain in $knowledge_domains | ||
- $domain | ||
#end for | ||
#end if | ||
#if $operational_parameters | ||
Operational Parameters: | ||
$operational_parameters | ||
#end if | ||
#if $interaction_style | ||
Interaction Style: | ||
$interaction_style | ||
#end if | ||
#if $performance_objectives | ||
Performance Objectives: | ||
#for $objective in $performance_objectives | ||
- $objective | ||
#end for | ||
#end if | ||
#if $version | ||
Version Information: | ||
$version | ||
#end if | ||
As an AI agent, you should strive to provide accurate, helpful, | ||
and contextually appropriate responses based on the above specifications. | ||
Always maintain the defined interaction style and adhere to the operational parameters. | ||
If you encounter a task outside your defined capabilities or knowledge domains, please | ||
inform the user and offer alternative solutions if possible. | ||
""", agent_config) | ||
# cleaned_string = re.sub(r'\s+', ' ', f"{template}") | ||
# cleaned_string = cleaned_string.strip() | ||
return cleaned_string | ||
|
||
|
||
def get_prompt(agent_config: dict): | ||
template = Template(""" | ||
$agent_definition | ||
You need to follow your responsibility. to complete the task. | ||
-------------- | ||
User Inputs: | ||
#for $key, $value in $user_inputs.items() | ||
$key: $value | ||
#end for | ||
#if $history | ||
------------ | ||
Other Agents Responses: | ||
#for $key, $value in $history.items() | ||
$key: $value | ||
#end for | ||
#end if | ||
""", agent_config) | ||
cleaned_string = re.sub(r'\s+', ' ', f"{template}") | ||
cleaned_string = cleaned_string.strip() | ||
return cleaned_string | ||
|
||
|
||
if __name__ == '__main__': | ||
from ceylon.llm.types import AgentDefinition | ||
|
||
conf = AgentDefinition( | ||
name="Researcher", | ||
role="researcher", | ||
responsibility="Search the internet", | ||
skills=["search"], | ||
tools=[] | ||
).model_dump() | ||
print(conf) | ||
|
||
print(get_agent_definition(conf)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from typing import List, Optional | ||
|
||
from langchain_core.tools import BaseTool | ||
from pydantic import BaseModel | ||
|
||
|
||
class Step(BaseModel): | ||
owner: str | ||
dependencies: List[str] | ||
|
||
|
||
class Job(BaseModel): | ||
title: str | ||
input: dict | ||
work_order: List[Step] | ||
visualize: bool = False | ||
|
||
|
||
class AgentDefinition(BaseModel): | ||
name: str | ||
role: str | ||
role_description: str | ||
responsibilities: List[str] | ||
skills: List[str] | ||
tools: List[str] = [] | ||
knowledge_domains: Optional[List[str]] = [] | ||
interaction_style: Optional[str] = None | ||
operational_parameters: Optional[str] = None | ||
performance_objectives: Optional[List[str]] = [] | ||
version: Optional[str] = None | ||
|
||
|
||
class LLMAgentResponse(BaseModel): | ||
time: float | ||
agent_id: str | ||
agent_name: str | ||
response: str | ||
|
||
|
||
class LLMAgentRequest(BaseModel): | ||
name: str | ||
user_inputs: dict | ||
history: List[LLMAgentResponse] |
Oops, something went wrong.