Skip to content

Commit

Permalink
support none prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
luyaxi committed Aug 22, 2024
1 parent d1d8919 commit 85b55c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions codelinker/linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
import inspect
import asyncio

from typing import Callable, Any, TypeVar
from typing import Callable, Any, TypeVar, Optional
from functools import wraps
from concurrent.futures import ThreadPoolExecutor
from pydantic import TypeAdapter,BaseModel
from copy import deepcopy


from .config import CodeLinkerConfig
from .request import OBJGenerator
from .models import SmartFuncLabel, StructureSchema, StructuredRet
Expand Down Expand Up @@ -38,9 +39,9 @@ def replace_refs(schema, ret_schema):


async def request(
prompt: str,
return_type: TypeAdapter,
objGen: OBJGenerator,
prompt: Optional[str] = None,
request_name: str = "request",
completions_kwargs: dict = {},
images: list = None,
Expand All @@ -52,7 +53,8 @@ async def request(
schema = return_type.json_schema()
schema = replace_refs(schema, schema)
messages = deepcopy(messages)
messages.append({"role": "user", "content": prompt})
if prompt is not None:
messages.append({"role": "user", "content": prompt})

if images is not None and len(images) > 0:
messages[-1]["content"] = [
Expand Down Expand Up @@ -158,8 +160,8 @@ def close(self):

async def exec(
self,
prompt: str,
return_type: T,
prompt: Optional[str] = None,
request_name: str = "request",
completions_kwargs: dict = {},
images: list = None,
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.5"
version = "0.2.6"
description = ""
authors = ["luyaxi <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 85b55c0

Please sign in to comment.