Add the gpt4 vision feature in AIOS

This commit is contained in:
alexsunxl
2023-11-17 12:01:16 +08:00
parent 3bc864467e
commit 1dbb218140
8 changed files with 158 additions and 5 deletions
+26 -4
View File
@@ -1,11 +1,9 @@
import asyncio
import os
import sys
directory = os.path.dirname(__file__)
sys.path.append(directory + '/../src')
from aios_kernel import CalenderEnvironment,WorkflowEnvironment
from aios_kernel import CalenderEnvironment,WorkflowEnvironment,ComputeKernel,OpenAI_ComputeNode,AIStorage
async def test_buildin_envs():
@@ -22,6 +20,29 @@ async def test_buildin_envs():
await asyncio.sleep(10)
async def test_image_to_text():
# init the compute kernel and add the compute node
open_ai_node = OpenAI_ComputeNode.get_instance()
if await open_ai_node.initial() is not True:
print("openai node initial failed!")
return False
ComputeKernel.get_instance().add_compute_node(open_ai_node)
w_env = WorkflowEnvironment("workflow",os.path.abspath(directory + "/../rootfs/workflow_env.db"))
assert w_env.functions['image_2_text'] is not None
await ComputeKernel.get_instance().start()
fn = w_env.get_ai_function('image_2_text')
image_path = os.path.abspath(directory + "/test.png")
arguments = {
'image_path': image_path
}
# execute the ai function
result = await fn.execute(**arguments)
assert result is not ""
print(result)
await asyncio.sleep(10)
if __name__ == "__main__":
#test_rstr = "abc is {abc}"
@@ -29,4 +50,5 @@ if __name__ == "__main__":
#new_str = test_rstr.format_map(values)
#print(new_str)
asyncio.run(test_buildin_envs())
# asyncio.run(test_buildin_envs())
asyncio.run(test_image_to_text())
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 690 KiB