Update code & pass test
This commit is contained in:
@@ -2,6 +2,7 @@ instance_id = "David"
|
|||||||
fullname = "David"
|
fullname = "David"
|
||||||
max_token_size = 16000
|
max_token_size = 16000
|
||||||
llm_model_name = "gpt-3.5-turbo-16k-0613"
|
llm_model_name = "gpt-3.5-turbo-16k-0613"
|
||||||
|
owner_env = "calender"
|
||||||
|
|
||||||
[[prompt]]
|
[[prompt]]
|
||||||
role = "system"
|
role = "system"
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ class AIAgent:
|
|||||||
self.unread_msg = Queue() # msg from other agent
|
self.unread_msg = Queue() # msg from other agent
|
||||||
self.owner_env : Environment = None
|
self.owner_env : Environment = None
|
||||||
self.owenr_bus = None
|
self.owenr_bus = None
|
||||||
self.enable_function_list = []
|
self.enable_function_list = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create_from_templete(cls,templete:AIAgentTemplete, fullname:str):
|
def create_from_templete(cls,templete:AIAgentTemplete, fullname:str):
|
||||||
@@ -392,7 +392,7 @@ class AIAgent:
|
|||||||
prompt.append(msg_prompt)
|
prompt.append(msg_prompt)
|
||||||
|
|
||||||
|
|
||||||
logger.debug(f"Agent {self.agent_id} do llm token static system:{system_prompt_len},function:{function_token_len},history:{history_token_len},input:{input_len},totoal prompt:{system_prompt_len + function_token_len + history_token_len} ")
|
logger.debug(f"Agent {self.agent_id} do llm token static system:{system_prompt_len},function:{function_token_len},history:{history_token_len},input:{input_len}, totoal prompt:{system_prompt_len + function_token_len + history_token_len} ")
|
||||||
task_result:ComputeTaskResult = await ComputeKernel.get_instance().do_llm_completion(prompt,self.llm_model_name,self.max_token_size,inner_functions)
|
task_result:ComputeTaskResult = await ComputeKernel.get_instance().do_llm_completion(prompt,self.llm_model_name,self.max_token_size,inner_functions)
|
||||||
final_result = task_result.result_str
|
final_result = task_result.result_str
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import base64
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
import requests
|
import requests
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from .compute_task import ComputeTask, ComputeTaskResult, ComputeTaskState, ComputeTaskType
|
from .compute_task import ComputeTask, ComputeTaskResult, ComputeTaskState, ComputeTaskType
|
||||||
from .compute_node import ComputeNode
|
from .compute_node import ComputeNode
|
||||||
@@ -27,12 +28,18 @@ class Local_Stability_ComputeNode(ComputeNode):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def declare_user_config(cls):
|
def declare_user_config(cls):
|
||||||
user_config = AIStorage.get_instance().get_user_config()
|
user_config = AIStorage.get_instance().get_user_config()
|
||||||
user_config.add_user_config(
|
if os.getenv("LOCAL_STABILITY_URL") is None:
|
||||||
"local_stability_url", "local stability url", False, None)
|
user_config.add_user_config(
|
||||||
user_config.add_user_config(
|
"local_stability_url", "local stability url", False, None)
|
||||||
"text2img_output_dir", "output dir", True, "./")
|
if os.getenv("TEXT2IMG_OUTPUT_DIR") is None:
|
||||||
user_config.add_user_config(
|
home_dir = Path.home()
|
||||||
"text2img_default_model", "text2img default model", True, "v1-5-pruned-emaonly")
|
output_dir = Path.joinpath(home_dir, "text2img_output")
|
||||||
|
Path.mkdir(output_dir, exist_ok=True)
|
||||||
|
user_config.add_user_config(
|
||||||
|
"text2img_output_dir", "text2image output dir", True, output_dir)
|
||||||
|
if os.getenv("TEXT2IMG_DEFAULT_MODEL") is None:
|
||||||
|
user_config.add_user_config(
|
||||||
|
"text2img_default_model", "text2img default model", True, "v1-5-pruned-emaonly")
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|||||||
@@ -106,14 +106,14 @@ class OpenAI_ComputeNode(ComputeNode):
|
|||||||
logger.info(f"call openai {mode_name} prompts: {prompts}")
|
logger.info(f"call openai {mode_name} prompts: {prompts}")
|
||||||
resp = openai.ChatCompletion.create(model=mode_name,
|
resp = openai.ChatCompletion.create(model=mode_name,
|
||||||
messages=prompts,
|
messages=prompts,
|
||||||
max_tokens=result_token,
|
#max_tokens=result_token,
|
||||||
temperature=0.7)
|
temperature=0.7)
|
||||||
else:
|
else:
|
||||||
logger.info(f"call openai {mode_name} prompts: {prompts} functions: {json.dumps(llm_inner_functions)}")
|
logger.info(f"call openai {mode_name} prompts: {prompts} functions: {json.dumps(llm_inner_functions)}")
|
||||||
resp = openai.ChatCompletion.create(model=mode_name,
|
resp = openai.ChatCompletion.create(model=mode_name,
|
||||||
messages=prompts,
|
messages=prompts,
|
||||||
functions=llm_inner_functions,
|
functions=llm_inner_functions,
|
||||||
max_tokens=result_token,
|
#max_tokens=result_token,
|
||||||
temperature=0.7) # TODO: add temperature to task params?
|
temperature=0.7) # TODO: add temperature to task params?
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,8 @@ class AIOS_Shell:
|
|||||||
google_text_to_speech = GoogleTextToSpeechNode.get_instance()
|
google_text_to_speech = GoogleTextToSpeechNode.get_instance()
|
||||||
google_text_to_speech.declare_user_config()
|
google_text_to_speech.declare_user_config()
|
||||||
|
|
||||||
|
Local_Stability_ComputeNode.declare_user_config()
|
||||||
|
|
||||||
|
|
||||||
async def _handle_no_target_msg(self,bus:AIBus,msg:AgentMsg) -> bool:
|
async def _handle_no_target_msg(self,bus:AIBus,msg:AgentMsg) -> bool:
|
||||||
target_id = msg.target.split(".")[0]
|
target_id = msg.target.split(".")[0]
|
||||||
@@ -86,10 +88,6 @@ class AIOS_Shell:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
async def initial(self) -> bool:
|
async def initial(self) -> bool:
|
||||||
os.environ["LOCAL_STABILITY_URL"] = "http://192.168.100.79:7866"
|
|
||||||
os.environ["TEXT2IMG_DEFAULT_MODEL"] = "v1-5-pruned-emaonly"
|
|
||||||
os.environ["TEXT2IMG_OUTPUT_DIR"] = "./"
|
|
||||||
|
|
||||||
cal_env = CalenderEnvironment("calender")
|
cal_env = CalenderEnvironment("calender")
|
||||||
await cal_env.start()
|
await cal_env.start()
|
||||||
Environment.set_env_by_id("calender",cal_env)
|
Environment.set_env_by_id("calender",cal_env)
|
||||||
|
|||||||
Reference in New Issue
Block a user