Skip to content

Commit

Permalink
update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
luyaxi committed Aug 23, 2024
1 parent d86bfdf commit 9a7c2b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions codelinker/linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def replace_refs(schema, ret_schema):
async def request(
return_type: TypeAdapter,
objGen: OBJGenerator,
description: str = "",
prompt: Optional[str] = None,
request_name: str = "request",
completions_kwargs: dict = {},
Expand All @@ -52,7 +53,6 @@ async def request(

schema = return_type.json_schema()
schema = replace_refs(schema, schema)
description = return_type.__doc__ if return_type.__doc__ is not None else ""

resolve_none_object = False
if schema["type"] != "object":
Expand Down Expand Up @@ -179,6 +179,7 @@ async def exec(
return await request(
prompt=prompt,
return_type=TypeAdapter(return_type),
description=return_type.__doc__ if isinstance(return_type, BaseModel) else "",
objGen=self.objGen,
request_name=request_name,
completions_kwargs=completions_kwargs,
Expand Down Expand Up @@ -206,6 +207,9 @@ def decorator(func):
if return_type == inspect.Signature.empty:
raise ValueError(
f"Function {func.__name__} does not contain return type annotation!")

# get function description from return's schema
description = return_type.__doc__ if isinstance(return_type, BaseModel) else ""
return_type = TypeAdapter(return_type)
ret_schema = return_type.json_schema()

Expand All @@ -231,9 +235,8 @@ def replace_refs(schema):
return schema

ret_schema = replace_refs(ret_schema)
description += ret_schema.pop("description", "")

# get function description from return's schema
description = ret_schema.pop("description", "")
prompt = func.__doc__

label = SmartFuncLabel(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "codelinker"
version = "0.2.13"
version = "0.2.14"
description = "A tool to link the code with large language models."
authors = ["luyaxi <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 9a7c2b0

Please sign in to comment.