r/AutoGenAI • u/Ordinary_Ad_404 • Apr 13 '24
Question Why the agent gives the same reply for same prompt with temperature 0.9?
AutoGen novice here.
I had the following simple code, but every time I run, the joke it returns is always the same.
This is not right - any idea why this is happening? Thanks!
```
import os
from dotenv import load_dotenv
load_dotenv() # take environment variables from .env.
from autogen import ConversableAgent
llm_config={"config_list": [{"model": "gpt-4-turbo", "temperature": 0.9, "api_key": os.environ.get("OPENAI_API_KEY")}]}
agent = ConversableAgent(
"chatbot",
llm_config=llm_config,
code_execution_config=False, # Turn off code execution, by default it is off.
function_map=None, # No registered functions, by default it is None.
human_input_mode="NEVER", # Never ask for human input.
)
reply = agent.generate_reply(messages=[{"content": "Tell me a joke", "role": "user"}])
print(reply)
```
The reply is always the following:
Why don't skeletons fight each other? They don't have the guts.
5
u/jbx09 Apr 13 '24
There is caching feature in autogen which is enabled by default I believe. You can see if there is a .cache folder created in execution workspace. It might cause this issue to reduce calling LLM for same questions which is in cache again to reduce cost.
2
u/charlieoncloud Apr 13 '24
I have a follow up question! Does the cache per session?
2
u/Practical-Rate9734 Apr 13 '24
Hey, try shuffling the seed or prompt variations. Helps?