Skip to content

Commit

Permalink
v0.0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-XT committed May 7, 2024
1 parent 19de785 commit 2842168
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions convertanything/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ def convertanything(
llm="gpt-3.5-turbo-16k",
**kwargs,
):
if server.endswith("/"):
server = server[:-1]
if server.endswith("/v1"):
server = server[:-3]
input_string = str(input_string)
openai.base_url = f"{server}/v1/"
openai.api_key = api_key if api_key else server
Expand All @@ -44,7 +40,7 @@ def convertanything(
JSON Structured Output:
"""
response = ""
messages = [{"role": "system", "content": prompt}]
messages = [{"role": "user", "content": prompt}]
if "prompt_name" in kwargs:
messages[0]["prompt_name"] = kwargs["prompt_name"]
if "prompt_category" not in kwargs:
Expand All @@ -68,10 +64,18 @@ def convertanything(
try:
response = json.loads(response)
return model(**response)
except:
except Exception as e:
print(e)
print(response)
print("Failed to convert the response to the model, trying again.")
return convertanything(input_string=input_string, model=model)
return convertanything(
input_string=input_string,
model=model,
server=server,
api_key=api_key,
llm=llm,
**kwargs,
)


def remap_fields(converted_data: dict, data: List[dict]) -> List[dict]:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="convertanything",
version="0.0.12",
version="0.0.13",
description="convertanything is a Python package that allows you to convert any text into a structured format according to the schema provided.",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 2842168

Please sign in to comment.