From 3134b0d67994d8c9bf049b2015bfb00a36963bf4 Mon Sep 17 00:00:00 2001 From: Malte Pietsch Date: Fri, 16 Sep 2022 14:11:33 +0200 Subject: [PATCH] fix: type of `temperature` param and adjust defaults for `OpenAIAnswerGenerator` (#3073) * fix: type of temperature param and adjust defaults * update schema * update api docs --- docs/_src/api/api/generator.md | 4 ++-- haystack/json-schemas/haystack-pipeline-main.schema.json | 6 +++--- haystack/nodes/answer_generator/openai.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/_src/api/api/generator.md b/docs/_src/api/api/generator.md index 6d2353d18..bda1b192b 100644 --- a/docs/_src/api/api/generator.md +++ b/docs/_src/api/api/generator.md @@ -370,9 +370,9 @@ on the [OpenAI API website](https://openai.com/api/). ```python def __init__(api_key: str, model: str = "text-curie-001", - max_tokens: int = 7, + max_tokens: int = 13, top_k: int = 5, - temperature: int = 0, + temperature: float = 0.2, presence_penalty: float = -2.0, frequency_penalty: float = -2.0, examples_context: Optional[str] = None, diff --git a/haystack/json-schemas/haystack-pipeline-main.schema.json b/haystack/json-schemas/haystack-pipeline-main.schema.json index 54c077915..b274b3f17 100644 --- a/haystack/json-schemas/haystack-pipeline-main.schema.json +++ b/haystack/json-schemas/haystack-pipeline-main.schema.json @@ -3908,7 +3908,7 @@ }, "max_tokens": { "title": "Max Tokens", - "default": 7, + "default": 13, "type": "integer" }, "top_k": { @@ -3918,8 +3918,8 @@ }, "temperature": { "title": "Temperature", - "default": 0, - "type": "integer" + "default": 0.2, + "type": "number" }, "presence_penalty": { "title": "Presence Penalty", diff --git a/haystack/nodes/answer_generator/openai.py b/haystack/nodes/answer_generator/openai.py index 192154f73..42d091507 100644 --- a/haystack/nodes/answer_generator/openai.py +++ b/haystack/nodes/answer_generator/openai.py @@ -28,9 +28,9 @@ class OpenAIAnswerGenerator(BaseGenerator): self, api_key: str, model: str = "text-curie-001", - max_tokens: int = 7, + max_tokens: int = 13, top_k: int = 5, - temperature: int = 0, + temperature: float = 0.2, presence_penalty: float = -2.0, frequency_penalty: float = -2.0, examples_context: Optional[str] = None,