From 0394e68d508d3af4836280dc21702990a2c3784d Mon Sep 17 00:00:00 2001 From: moon Date: Mon, 31 Jul 2023 14:29:08 -0700 Subject: [PATCH] 0.3.5 - add temperature input --- easycompletion/model.py | 8 ++++++-- setup.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/easycompletion/model.py b/easycompletion/model.py index 409f074..7762317 100644 --- a/easycompletion/model.py +++ b/easycompletion/model.py @@ -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. @@ -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) @@ -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. @@ -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) @@ -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. @@ -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) diff --git a/setup.py b/setup.py index 311a37e..633c56f 100644 --- a/setup.py +++ b/setup.py @@ -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