Skip to content

Commit

Permalink
Adding OpenAI temperature as an adjustable .env value
Browse files Browse the repository at this point in the history
  • Loading branch information
MalikMAlna committed Apr 13, 2023
1 parent e144b9d commit 53e9aaf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions babyagi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 53e9aaf

Please sign in to comment.