From 53e9aaf7d766b851ce31f90d7172f76a0fc6f0cf Mon Sep 17 00:00:00 2001 From: MalikMAlna Date: Wed, 12 Apr 2023 23:05:29 -0400 Subject: [PATCH] Adding OpenAI temperature as an adjustable .env value --- .env.example | 1 + babyagi.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 6e2fe868..fb2b8db5 100644 --- a/.env.example +++ b/.env.example @@ -7,6 +7,7 @@ # API CONFIG OPENAI_API_KEY= OPENAI_API_MODEL=gpt-3.5-turbo # alternatively, gpt-4, text-davinci-003, etc +OPENAI_TEMPERATURE=0.0 PINECONE_API_KEY= PINECONE_ENVIRONMENT=us-east1-gcp diff --git a/babyagi.py b/babyagi.py index 960cb2e3..7b4f7c49 100755 --- a/babyagi.py +++ b/babyagi.py @@ -45,6 +45,9 @@ OBJECTIVE = os.getenv("OBJECTIVE", "") INITIAL_TASK = os.getenv("INITIAL_TASK", os.getenv("FIRST_TASK", "")) +# Model configuration +OPENAI_TEMPERATURE = float(os.getenv("OPENAI_TEMPERATURE", 0.0)) + # Extensions support begin @@ -134,7 +137,7 @@ def get_ada_embedding(text): def openai_call( prompt: str, model: str = OPENAI_API_MODEL, - temperature: float = 0.0, + temperature: float = OPENAI_TEMPERATURE, max_tokens: int = 100, ): while True: @@ -233,7 +236,7 @@ def execution_agent(objective: str, task: str) -> str: You are an AI who performs one task based on the following objective: {objective}\n. Take into account these previously completed tasks: {context}\n. Your task: {task}\nResponse:""" - return openai_call(prompt, temperature=0.0, max_tokens=2000) + return openai_call(prompt, max_tokens=2000) def context_agent(query: str, top_results_num: int):