Skip to content

Commit

Permalink
Jarvis use gpt-3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
waterflier committed Sep 20, 2023
1 parent a75857a commit d5073cc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions rootfs/agents/Jarvis/agent.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
instance_id = "Jarvis"
fullname = "Jarvis"
llm_model_name = "gpt-3.5-turbo-16k-0613"

[[prompt]]
role = "system"
Expand Down
9 changes: 9 additions & 0 deletions src/aios_kernel/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ async def _execute_func(self,inenr_func_call_node:dict,prompt:AgentPrompt,org_ms
async def _get_agent_prompt(self) -> AgentPrompt:
return self.prompt

def _format_msg_by_env_value(self,prompt:AgentPrompt):
if self.owner_env is None:
return

for msg in prompt.messages:
old_content = msg.get("content")
msg["content"] = old_content.format_map(self.owner_env)

async def _process_msg(self,msg:AgentMsg) -> AgentMsg:
from .compute_kernel import ComputeKernel
from .bus import AIBus
Expand All @@ -269,6 +277,7 @@ async def _process_msg(self,msg:AgentMsg) -> AgentMsg:
msg_prompt.messages = [{"role":"user","content":msg.body}]
prompt.append(msg_prompt)

self._format_msg_by_env_value(prompt)
inner_functions = self._get_inner_functions()

task_result:ComputeTaskResult = await ComputeKernel.get_instance().do_llm_completion(prompt,self.llm_model_name,self.max_token_size,inner_functions)
Expand Down
6 changes: 5 additions & 1 deletion src/aios_kernel/open_ai_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,12 @@ def get_capacity(self):

def is_support(self, task: ComputeTask) -> bool:
if task.task_type == ComputeTaskType.LLM_COMPLETION:
if not task.params["model_name"] or task.params["model_name"] == "gpt-4-0613":
if not task.params["model_name"]:
return True
model_name : str = task.params["model_name"]
if model_name.startswith("gpt-"):
return True

if task.task_type == ComputeTaskType.TEXT_EMBEDDING:
if task.params["model_name"] == "text-embedding-ada-002":
return True
Expand Down
2 changes: 1 addition & 1 deletion src/service/aios_shell/aios_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ async def main():

await asyncio.sleep(0.2)
while True:
user_input = await session.prompt_async(f"{shell.username}<->{shell.current_topic}@{shell.current_target}$",completer=completer,style=shell_style)
user_input = await session.prompt_async(f"{shell.username}<->{shell.current_topic}@{shell.current_target}$ ",completer=completer,style=shell_style)
if len(user_input) <= 1:
continue

Expand Down

0 comments on commit d5073cc

Please sign in to comment.