diff --git a/build_and_push b/build_and_push index dc98bc3e1..cf7e82e48 100755 --- a/build_and_push +++ b/build_and_push @@ -1,5 +1,5 @@ #! /bin/bash poetry remove langchain -docker build -t ibiscp/expert:v0.0.11 . && docker push ibiscp/expert:v0.0.11 +docker build -t ibiscp/expert:v0.0.12 . && docker push ibiscp/expert:v0.0.12 poetry add --editable ../langchain diff --git a/src/app.py b/src/app.py index d91a1c4ef..c68243b79 100644 --- a/src/app.py +++ b/src/app.py @@ -34,4 +34,4 @@ app = create_app() if __name__ == "__main__": import uvicorn - uvicorn.run(app, host="0.0.0.0", port=8000) + uvicorn.run(app, host="0.0.0.0", port=5003) diff --git a/src/endpoints.py b/src/endpoints.py index 0e79cde13..02e96f12a 100644 --- a/src/endpoints.py +++ b/src/endpoints.py @@ -12,14 +12,21 @@ import list # build router router = APIRouter() -AGENT_TYPE = "conversational-react-description" -# define endpoints -> /chain, /agent, /memory, /prompt -# return a dict + + +def get_type_list(): + all = get_all() + + all.pop("tools") + + for key, value in all.items(): + all[key] = [item["template"]["_type"] for item in value.values()] + + return all @router.get("/") def get_all(): - # tools = list.list_tools() return { "chains": {chain: signature.chain(chain) for chain in list.list_chains()}, "agents": {agent: signature.agent(agent) for agent in list.list_agents()}, @@ -49,30 +56,12 @@ def get_all(): } -@router.post("/load") -def get_load(data: dict[str, str]) -> str: - return "Hello Otávio!" +@router.post("/predict") +def get_load(data: dict[str, str]): + a = get_type_list() + # Build json -# @router.get("/chain") -# def get_chain(): -# llm = OpenAI(temperature=0) -# chain = DictableChain(llm=llm) -# return chain.to_dict() + # if type in a["prompts"]: - -# @router.get("/agent") -# def get_agent(): -# tools = [DictableTool(name="test", description="test", func=lambda x: x)] -# llm = OpenAI(temperature=0) -# return initialize_agent(llm=llm, tools=tools, memory=DictableMemory()).__dict__ - - -# @router.get("/memory") -# def get_memory(): -# return DictableMemory().to_dict() - - -# @router.get("/prompt") -# def get_prompt(): -# return {"template": "template", "input_variables": "input_variables"} + return a diff --git a/src/signature.py b/src/signature.py index 63959c6e5..0a46ba9d6 100644 --- a/src/signature.py +++ b/src/signature.py @@ -167,7 +167,7 @@ def tool(name: str): "list": False, "show": True, "placeholder": "", - "default": "", + "value": "", }, "llm": {"type": "BaseLLM", "required": True, "list": False, "show": True}, } @@ -183,11 +183,14 @@ def tool(name: str): _, extra_keys = _EXTRA_OPTIONAL_TOOLS[name] params = extra_keys + template = { + param: (type_dict[param] if param == "llm" else type_dict["str"]) + for param in params + } + template["_type"] = name + return { - "template": { - param: (type_dict[param] if param == "llm" else type_dict["str"]) - for param in params - }, + "template": template, **util.get_tool_params(util.get_tools_dict(name)), "base_classes": ["Tool"], } diff --git a/src/util.py b/src/util.py index baac2dad3..8a3f8c0ab 100644 --- a/src/util.py +++ b/src/util.py @@ -157,15 +157,25 @@ def format_dict(d): # Show if required value["show"] = bool( (value["required"] and key not in ["input_variables"]) - or key in ["allowed_tools", "verbose", "Memory", "memory", "prefix"] + or key + in ["allowed_tools", "verbose", "Memory", "memory", "prefix", "examples"] or "api_key" in key ) + # Add multline + if key in ["suffix", "prefix", "template", "examples"]: + value["multline"] = True + else: + value["multline"] = False + # Replace default value with actual value - if _type in ["str", "bool"]: - value["value"] = value.get("default", "") - if "default" in value: - value.pop("default") + # if _type in ["str", "bool"]: + # value["value"] = value.get("default", "") + # if "default" in value: + # value.pop("default") + if "default" in value: + value["value"] = value["default"] + value.pop("default") # Filter out keys that should not be shown return (