update fix of pr review

This commit is contained in:
better629 2024-02-01 10:42:18 +08:00
parent 2d372a8863
commit c0a4d7c4c9
4 changed files with 7 additions and 17 deletions

View file

@ -2,15 +2,7 @@
# -*- coding: utf-8 -*-
# @Desc : use gpt4v to improve prompt and draw image with dall-e-3
"""
set the configuration in `config2.yaml` like below
```
llm:
base_url: "xxx"
api_key: "sk-xxx"
model: "gpt-4-vision-preview"
```
"""
"""set `model: "gpt-4-vision-preview"` in `config2.yaml` first"""
import asyncio

View file

@ -29,14 +29,11 @@ async def main():
if hasattr(llm, "completion"):
logger.info(llm.completion(hello_msg))
# check llm-vision capacity if it supports
# check if the configured llm supports llm-vision capacity. If not, it will throw a error
invoice_path = Path(__file__).parent.joinpath("..", "tests", "data", "invoices", "invoice-2.png")
img_base64 = encode_image(invoice_path)
try:
res = await llm.aask(msg="if this is a invoice, just return True else return False", images=[img_base64])
assert "true" in res.lower()
except Exception:
pass
res = await llm.aask(msg="if this is a invoice, just return True else return False", images=[img_base64])
assert "true" in res.lower()
if __name__ == "__main__":

View file

@ -254,6 +254,7 @@ async def test_action_node_with_image():
node = await invoice.fill(context="", llm=LLM(), images=[img_base64])
assert node.instruct_content.invoice
class ToolDef(BaseModel):
tool_name: str = Field(default="a", description="tool name", examples=[])
description: str = Field(default="b", description="tool description", examples=[])

View file

@ -18,7 +18,7 @@ class ForTestEnv(Environment):
value: int = 0
@mark_as_readable
def read_api_no_parms(self):
def read_api_no_param(self):
return self.value
@mark_as_readable
@ -46,5 +46,5 @@ async def test_ext_env():
with pytest.raises(ValueError):
await env.observe("not_exist_api")
assert await env.observe("read_api_no_parms") == 15
assert await env.observe("read_api_no_param") == 15
assert await env.observe(EnvAPIAbstract(api_name="read_api", kwargs={"a": 5, "b": 5})) == 10