#Introduce Randomness in Function Calling

16 messages · Page 1 of 1 (latest)

patent ice
#

Someone please tell me there's a way to fix this otherwise I gotta rewrite my entire application stripping away function calling

fiery anvil
#

Increase the temperature of the call allowing more randomness in the response.

#

Give it a memory and in the system message let it know not to re use the history.

patent ice
fiery anvil
#

Hrm

patent ice
#
def prompt(
    self, schema: dict,
    question_type: str,
    difficulty: str,
    topic: str,
    instructions: Optional[str] = ""
) -> str:
    """Sends a prompt to the OpenAI GPT API and returns the response.

    :param question_type: The type of the question you want to ask.
    :param difficulty: The difficulty of the question.
    :param topic: The topic of the question.
    :param schema: The schema of the chosen question type.
    :param instructions: The instructions to send to the API.
    :return: The response from the API.
    """
    user_input = UserInput(question_type, difficulty, topic)
    messages = [
        Message(Roles.SYSTEM, self.behavior_instruction),
        Message(Roles.USER, f"""Get me a question for the inputs provided:
            {asdict(user_input)}\n{instructions}\nQuestion Number: {random.randint(0, 1000)}""")
    ]
    func_response = openai.ChatCompletion.create(
        model=self.model,
        messages=[asdict(msg) for msg in messages],
        functions=[{
            "name": "get_random_question",
            "description": "Get a random question for the given inputs.",
            "parameters": {
                "type": "object",
                "properties": {
                    "question": schema
                },
                "required": ["question"]
            }
        }],
        function_call={"name": "get_random_question"},
        temperature=2.0,
        top_p=0.25,
        presence_penalty=1.9
    )
    return json.loads(
        func_response.choices[0].message.function_call.arguments
    )
fiery anvil
#

Give it a different perspective. 10 random personalities or personalities and make that what is randomized.

patent ice
#

ok that seems like a good idea for starters but not sure if it will help in this context since we're asking quiz questions

fiery anvil
#

One little thing that can change it
"Get a random question for the given inputs."
"Generate a random question from the given inputs."

patent ice
#

Hmm aren't they both the same? Lemme give it a shot though, thanks

fiery anvil
#

It's a computerized language, little things add up

patent ice
#

No luck 😦

fiery anvil
#

nm nm

fiery anvil
#

This is python but

import openai

openai.api_key = +

# Ask the user for a topic
topic = input("Please enter a topic: ")

# Ask the user for the genre of questions
genre = input("What genre of questions would you like? (scientific, odd, artistic): ")

# Set the system prompt and user question based on user inputs
system_prompt = "You are a helpful assistant that generates random questions. Your goal is to ask {} questions about {}. Be creative and have fun!".format(genre, topic)
user_question = input("Please enter your question: ")

# Prepare the messages in the required format
messages = [
    {"role": "system", "content": system_prompt},
    {"role": "user", "content": user_question}
]

# Generate random questions using OpenAI API
completion = openai.ChatCompletion.create(
    model="gpt-3.5-turbo",
    messages=messages
)

# Get the generated response from the API
response = completion.choices[0].message['content']

# Print the generated question
print("Randomly generated question: ", response)```