Skip to content

Commit

Permalink
0.3.5 - add temperature input
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Jul 31, 2023
1 parent 93c9831 commit 0394e68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions easycompletion/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def chat_completion(
chunk_length=DEFAULT_CHUNK_LENGTH,
api_key=None,
debug=DEBUG,
temperature=0.0
):
"""
Function for sending chat messages and returning a chat response.
Expand Down Expand Up @@ -257,7 +258,7 @@ def chat_completion(
response = None
for i in range(model_failure_retries):
try:
response = openai.ChatCompletion.create(model=model, messages=messages)
response = openai.ChatCompletion.create(model=model, messages=messages, temperature=temperature)
break
except Exception as e:
log(f"OpenAI Error: {e}", type="error", log=debug)
Expand Down Expand Up @@ -298,6 +299,7 @@ def text_completion(
chunk_length=DEFAULT_CHUNK_LENGTH,
api_key=None,
debug=DEBUG,
temperature=0.0
):
"""
Function for sending text and returning a text completion response.
Expand Down Expand Up @@ -354,7 +356,7 @@ def text_completion(
response = None
for i in range(model_failure_retries):
try:
response = openai.ChatCompletion.create(model=model, messages=messages)
response = openai.ChatCompletion.create(model=model, messages=messages, temperature=temperature)
break
except Exception as e:
log(f"OpenAI Error: {e}", type="error", log=debug)
Expand Down Expand Up @@ -400,6 +402,7 @@ def function_completion(
model=None,
api_key=None,
debug=DEBUG,
temperature=0.0
):
"""
Send text and a list of functions to the model and return optional text and a function call.
Expand Down Expand Up @@ -540,6 +543,7 @@ def function_completion(
messages=all_messages,
functions=functions,
function_call=function_call,
temperature=temperature
)
if not response.get("choices") or response["choices"][0] is None:
log("No choices in response", type="error", log=debug)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="easycompletion",
version='0.3.4',
version='0.3.5',
description="Easy text completion and function calling. Also includes useful utilities for counting tokens, composing prompts and trimming them to fit within the token limit.",
long_description=long_description, # added this line
long_description_content_type="text/markdown", # and this line
Expand Down

0 comments on commit 0394e68

Please sign in to comment.