add compute node for llama
This commit is contained in:
File diff suppressed because one or more lines are too long
+288
@@ -0,0 +1,288 @@
|
|||||||
|
|
||||||
|
# 2023-09-15 03:41:50.683879
|
||||||
|
+hello
|
||||||
|
|
||||||
|
# 2023-09-15 03:42:12.120490
|
||||||
|
+help
|
||||||
|
|
||||||
|
# 2023-09-15 06:37:37.070634
|
||||||
|
+hel
|
||||||
|
|
||||||
|
# 2023-09-15 06:37:43.470674
|
||||||
|
+he
|
||||||
|
|
||||||
|
# 2023-09-15 06:37:46.694774
|
||||||
|
+help()
|
||||||
|
|
||||||
|
# 2023-09-15 06:37:58.255558
|
||||||
|
+open($target,$topic)
|
||||||
|
|
||||||
|
# 2023-09-15 06:38:39.946346
|
||||||
|
+open(math_school, hello)
|
||||||
|
|
||||||
|
# 2023-09-15 06:38:52.255612
|
||||||
|
+5+3
|
||||||
|
|
||||||
|
# 2023-09-15 06:40:08.434216
|
||||||
|
+open(小学老师,math_school)
|
||||||
|
|
||||||
|
# 2023-09-15 06:40:12.511473
|
||||||
|
+5+3
|
||||||
|
|
||||||
|
# 2023-09-15 06:41:07.635875
|
||||||
|
+send(小学老师, 5+3, math_school)
|
||||||
|
|
||||||
|
# 2023-09-15 06:41:28.111632
|
||||||
|
+send("小学老师", "5+3", "math_school")
|
||||||
|
|
||||||
|
# 2023-09-15 06:46:03.361318
|
||||||
|
+5+3
|
||||||
|
|
||||||
|
# 2023-09-15 06:58:04.568600
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 06:58:10.940263
|
||||||
|
+5+3
|
||||||
|
|
||||||
|
# 2023-09-15 08:14:18.370059
|
||||||
|
+op
|
||||||
|
|
||||||
|
# 2023-09-15 08:14:57.303640
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 08:16:13.045359
|
||||||
|
+5+3
|
||||||
|
|
||||||
|
# 2023-09-15 08:24:53.045039
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 08:24:56.551048
|
||||||
|
+5+3
|
||||||
|
|
||||||
|
# 2023-09-15 08:27:14.113933
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 08:27:31.679873
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 08:28:39.132082
|
||||||
|
+$open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 08:29:11.896668
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 08:36:34.342241
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 08:36:39.386247
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 09:57:19.516838
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 09:57:33.371520
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 10:00:53.355748
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:01:02.862918
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 10:05:53.128794
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:05:58.133501
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 10:07:42.454258
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:07:47.737608
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 10:10:09.716805
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:10:16.097322
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 10:12:08.449379
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:12:13.079025
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 10:13:48.545683
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:13:54.927181
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 10:19:17.745657
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:19:23.711550
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 10:21:26.701757
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:21:32.767604
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 10:26:04.480292
|
||||||
|
+open(math_school,小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:26:10.045387
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 10:31:28.045250
|
||||||
|
+open(match_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:31:36.167547
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-15 10:32:29.338152
|
||||||
|
+open(match_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:32:35.693949
|
||||||
|
+3+5=8
|
||||||
|
|
||||||
|
# 2023-09-15 10:33:03.433018
|
||||||
|
+open(match_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:33:14.326229
|
||||||
|
+4+5=9
|
||||||
|
|
||||||
|
# 2023-09-15 10:34:21.259810
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-15 10:34:34.422484
|
||||||
|
+1+1=2
|
||||||
|
|
||||||
|
# 2023-09-16 10:13:23.564438
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-16 10:13:29.941319
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-16 10:14:23.145831
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-16 10:14:26.382580
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 11:43:17.436353
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 11:43:22.332117
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 11:49:27.933651
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 11:49:35.619278
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 11:51:28.813245
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 11:51:34.474472
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 11:58:28.221803
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 11:59:16.715335
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 12:04:10.819566
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 12:04:15.404546
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 12:04:39.159679
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 12:04:50.036365
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 12:05:20.015642
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 12:05:26.268601
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 12:07:52.687876
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 12:08:10.093561
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 12:10:49.055737
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 12:10:55.622177
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 12:17:37.593976
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 12:17:41.496433
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 12:43:55.489719
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 12:43:59.837491
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 12:46:07.069625
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 12:46:13.028847
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 12:48:40.762746
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 12:48:45.062939
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 12:52:08.003428
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 12:52:15.104145
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 12:58:11.789619
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 12:58:17.994040
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 13:03:18.654092
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 13:03:23.698141
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 13:05:39.719027
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 13:05:44.820351
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 13:08:18.344888
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 13:08:25.670674
|
||||||
|
+5+3=8
|
||||||
|
|
||||||
|
# 2023-09-17 13:10:28.539763
|
||||||
|
+open(math_school, 小学老师)
|
||||||
|
|
||||||
|
# 2023-09-17 13:10:33.353629
|
||||||
|
+5+3=8
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
instance_id = "math_teacher"
|
instance_id = "math_teacher"
|
||||||
fullname = "the one"
|
fullname = "the one"
|
||||||
|
llm_model_name = "llama"
|
||||||
[[prompt]]
|
[[prompt]]
|
||||||
role = "system"
|
role = "system"
|
||||||
content = "你是精通数学的老师"
|
content = "你是精通数学的老师"
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -9,3 +9,4 @@ from .role import AIRole,AIRoleGroup
|
|||||||
from .workflow import Workflow
|
from .workflow import Workflow
|
||||||
from .bus import AIBus
|
from .bus import AIBus
|
||||||
from .workflow_env import WorkflowEnvironment,CalenderEnvironment,CalenderEvent
|
from .workflow_env import WorkflowEnvironment,CalenderEnvironment,CalenderEvent
|
||||||
|
from .local_llama_compute_node import LocalLlama_ComputeNode
|
||||||
@@ -115,7 +115,7 @@ class Environment:
|
|||||||
def get_value(self,key:str) -> Optional[str]:
|
def get_value(self,key:str) -> Optional[str]:
|
||||||
handler = self.get_handlers.get(key)
|
handler = self.get_handlers.get(key)
|
||||||
if handler is not None:
|
if handler is not None:
|
||||||
return handler(key)
|
return handler()
|
||||||
|
|
||||||
s = self.values.get(key)
|
s = self.values.get(key)
|
||||||
if isinstance(s,str):
|
if isinstance(s,str):
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
from typing import Optional
|
from typing import Optional, List
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from .compute_task import ComputeTask, ComputeTaskState, ComputeTaskType
|
from .compute_task import ComputeTask, ComputeTaskState, ComputeTaskType
|
||||||
@@ -26,14 +26,18 @@ class LocalLlama_ComputeNode(Queue_ComputeNode):
|
|||||||
class GenerateResponse(BaseModel):
|
class GenerateResponse(BaseModel):
|
||||||
error: Optional[int]
|
error: Optional[int]
|
||||||
msg: Optional[str]
|
msg: Optional[str]
|
||||||
results: Optional[str]
|
results: Optional[List[str]]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
prompt_msgs = []
|
||||||
|
for prompt in task.params["prompts"]:
|
||||||
|
prompt_msgs.append(prompt["content"])
|
||||||
|
|
||||||
body = {
|
body = {
|
||||||
"prompts": task.params["prompts"]
|
"prompts": prompt_msgs
|
||||||
}
|
}
|
||||||
|
|
||||||
response = requests.post("http://aigc:7880/generate", data = body, verify=False)
|
response = requests.post("http://aigc:7880/generate", json = body, verify=False, headers={"Content-Type": "application/json"})
|
||||||
response.close()
|
response.close()
|
||||||
|
|
||||||
logger.info(f"LocalLlama_ComputeNode task responsed, request: {body}, status-code: {response.status_code}, headers: {response.headers}, content: {response.content}")
|
logger.info(f"LocalLlama_ComputeNode task responsed, request: {body}, status-code: {response.status_code}, headers: {response.headers}, content: {response.content}")
|
||||||
@@ -47,19 +51,20 @@ class LocalLlama_ComputeNode(Queue_ComputeNode):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
resp = GenerateResponse.parse_raw(response.content.decode("utf-8"))
|
resp = response.json()
|
||||||
if resp.error:
|
if "error" in resp:
|
||||||
return {
|
return {
|
||||||
"state": ComputeTaskState.ERROR,
|
"state": ComputeTaskState.ERROR,
|
||||||
"error": {
|
"error": {
|
||||||
"code": resp.error,
|
"code": resp["error"],
|
||||||
"message": "local llama failed:" + resp.msg
|
"message": "local llama failed:" + resp["msg"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
return {
|
return {
|
||||||
"content": str(resp.results),
|
"state": ComputeTaskState.DONE,
|
||||||
"message": {}
|
"content": str(resp["results"]),
|
||||||
|
"message": str(resp["results"])
|
||||||
}
|
}
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
import traceback
|
import traceback
|
||||||
|
|||||||
@@ -54,11 +54,14 @@ class OpenAI_ComputeNode(ComputeNode):
|
|||||||
prompts = task.params["prompts"]
|
prompts = task.params["prompts"]
|
||||||
|
|
||||||
logger.info(f"call openai {mode_name} prompts: {prompts}")
|
logger.info(f"call openai {mode_name} prompts: {prompts}")
|
||||||
|
try:
|
||||||
resp = openai.ChatCompletion.create(model=mode_name,
|
resp = openai.ChatCompletion.create(model=mode_name,
|
||||||
messages=prompts,
|
messages=prompts,
|
||||||
functions=task.params["inner_functions"],
|
functions=task.params["inner_functions"],
|
||||||
max_tokens=task.params["max_token_size"],
|
max_tokens=task.params["max_token_size"],
|
||||||
temperature=0.7) # TODO: add temperature to task params?
|
temperature=0.7) # TODO: add temperature to task params?
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"openai.ChatCompletion.create failed! {e}")
|
||||||
|
|
||||||
logger.info(f"openai response: {resp}")
|
logger.info(f"openai response: {resp}")
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class CalenderEnvironment(Environment):
|
|||||||
def stop(self):
|
def stop(self):
|
||||||
self.is_run = False
|
self.is_run = False
|
||||||
|
|
||||||
async def get_now(self) -> str:
|
def get_now(self) -> str:
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
formatted_time = now.strftime('%Y-%m-%d %H:%M:%S')
|
formatted_time = now.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
return formatted_time
|
return formatted_time
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ shell_style = Style.from_dict({
|
|||||||
|
|
||||||
directory = os.path.dirname(__file__)
|
directory = os.path.dirname(__file__)
|
||||||
sys.path.append(directory + '/../../')
|
sys.path.append(directory + '/../../')
|
||||||
from aios_kernel import Workflow,AIAgent,AgentMsg,AgentMsgState,ComputeKernel,OpenAI_ComputeNode,AIBus,AIChatSession
|
from aios_kernel import Workflow,AIAgent,AgentMsg,AgentMsgState,ComputeKernel,OpenAI_ComputeNode,AIBus,AIChatSession,LocalLlama_ComputeNode
|
||||||
|
|
||||||
sys.path.append(directory + '/../../component/')
|
sys.path.append(directory + '/../../component/')
|
||||||
from agent_manager import AgentManager
|
from agent_manager import AgentManager
|
||||||
@@ -69,9 +69,15 @@ class AIOS_Shell:
|
|||||||
|
|
||||||
AgentManager().initial(os.path.abspath(directory + "/../../../rootfs/"))
|
AgentManager().initial(os.path.abspath(directory + "/../../../rootfs/"))
|
||||||
WorkflowManager().initial(os.path.abspath(directory + "/../../../rootfs/workflows/"))
|
WorkflowManager().initial(os.path.abspath(directory + "/../../../rootfs/workflows/"))
|
||||||
|
|
||||||
open_ai_node = OpenAI_ComputeNode()
|
open_ai_node = OpenAI_ComputeNode()
|
||||||
open_ai_node.start()
|
open_ai_node.start()
|
||||||
ComputeKernel().add_compute_node(open_ai_node)
|
ComputeKernel().add_compute_node(open_ai_node)
|
||||||
|
|
||||||
|
llama_ai_node = LocalLlama_ComputeNode()
|
||||||
|
llama_ai_node.start()
|
||||||
|
ComputeKernel().add_compute_node(llama_ai_node)
|
||||||
|
|
||||||
AIBus().get_default_bus().register_unhandle_message_handler(self._handle_no_target_msg)
|
AIBus().get_default_bus().register_unhandle_message_handler(self._handle_no_target_msg)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user