Diffrent responses are generated for the same Playground/API call

Hi

I encountered different outcomes when using the same message with the same assistant (asst_LKh8CPEymOvORMDcYlbdMbGs) — once through the playground and once via an API call. Any insights on why this discrepancy occurred?

API

 _content = 'can you create youtube playlist of 1 song for playlist named Mystic Melodies Manifest, Only respond with python list code as plain text without code block syntax around it'

        message = client.beta.threads.messages.create(
            thread_id=thread.id,
            role="user",
            content=_content
        )

API - Result

sure, Here is a simple Python representation for a YouTube playlist named 'Mystic Melodies Manifest'. This isn't a real playlist as the URLs are fake - they're just for illustrative purposes. However, It gives the format for creating a list of songs with {'title', 'url'} entries.


playlist = [
    {'title': 'Song 1', 'url': 'https://youtu.be/song1'}
]

Playground message

User

can you create youtube playlist of 1 song for playlist named Mystic Melodies Manifest, Only respond with python list code as plain text without code block syntax around it

Playground result

music dj
[ 'Celestial Voices - Mystic Mantra'] 

This is expected because it’s a probabilistic model.

Basically it generate what flow well with your prompt and choose one that is likely to be the best answer.
With this in mind, you can expect it to write different story with the same prompt and suggest different code when prompted with the same prompt.

It seems you are feeding the ‘content’ into the thread. But what instructions do you have stored in Assistant prompt? The prompt in the Assistant can be updated really easy, without changing or re-deploying your code. Then in the thread you would simply ask create a playlist named. The details of how to respond are in the Assistnat. I am also wondering if your ask can be clearer. Python List Code I would think is not a universal clear term. Do you want the first example or the second? Do you want "You response should be a single line of python code that has a variable name ‘playlist’ and the playlist you generated as a list object, with each element <>’ or do you want “Your response should JSON Array with the playlist you generated as elements. Each element should have attrributes <<<>>>”

More details will generally create more similar, reliable results.

Is your ‘temperature’ variable non-zero?
Edit: I guess temperatuer is not supported in assistants, right now

Thanks for your answers !
here is the full code

thread = client.beta.threads.create()

assistant = client.beta.assistants.create(
name="music dj",
instructions="You are a famous music dj. you compile youtube playlist that reach broad audiance.",
tools=[{"type": "code_interpreter"}],
model="gpt-4-1106-preview"
)

_content = 'can you create youtube playlist of 3 songs for playlist named Mystic Melodies Manifest, Only respond with python list code as plain text without code block syntax around it'

 message =client.beta.threads.messages.create(
            thread_id=thread.id,
            role="user",
            content=_content
        )

run = client.beta.threads.runs.create(
            thread_id=thread.id,
            assistant_id = assistant.id
        )

I would like to get result like this (able to get using Playground , using same message , same assistant)

 [
    "Enigma - Return to Innocence",
    "Dead Can Dance - The Host of Seraphim",
    "Deep Forest - Sweet Lullaby"
]

using above code I get the following response

Sure. I would like to clarify that because current environment does not have internet access, I cannot search for actual song links on YouTube. Therefore, I'll provide a sample playlist in Python list format with fictional YouTube links.

Here is your Python list code:

```python
playlist_mystic_melodies_manifest = [
  'https://www.youtube.com/watch?v=song1',
  'https://www.youtube.com/watch?v=song2',
  'https://www.youtube.com/watch?v=song3'
]

Please replace 'song1', 'song2', etc., with actual song video IDs from YouTube.

one more question ? Is the APi connected to the internet ? its create fake song names , the Playground response with real song name .

ChatGPT will not be be able to find music and generate a list. So you would have to feed it a list to pick from.
Apart from that - you don’t need the code completion to do this. It can generate the format you want without that.
Also it is probably easier to not create the Assistant in code - your current code will create a new Assistant every time you run it.
Your instructions are still super short.

1 Like

I don’t think that code interpreter means “can search youtube/internet” - is there something in the docs that led you to this conclusion? Also, as someone else said, you only need to make 1 assistant, at least for this case. Not one assistant for each query.