Can I share one of my threads on the forum to get assistance with the AI behaving poorly?

The AI is not following instructions and doing a poor job of coding for me. How can I share the thread for others to see and tell me if I am doing something wrong?

You cannot share any thread ID identifier with others that do not have API access. The forum members to help are not staff.

Besides knowing and understanding your assistants’ instructions, and seeing the whole path a conversation took, the hardest part is in understanding what another person’s goals are and their own understanding of a code base, of which only a small portion may be shown to an AI.

This makes “look at what the AI did wrong” very hard to understand in most cases of code, requiring beyond AI-level proficiency in being able to do the task correctly.

The ideal way to obtain a conversation is to use the same API 'list messages" that would get the response of an AI after a run is completed, with a larger number of chronologically-sorted messages. Then a format where they could be presented for understanding.

I had o1-preview whip up an ugly app that only took some manual coding to make it work right, using your environment’s OPENAI_API_KEY and a thread_id, to get messages, let you check boxes, and save the selected messages to a file.

You can use it with a thread id that you will have to have logged (or I assume obtain from the user interface of the playground) and an API key in your OS environment matching the selected project when the thread was run.

Then you can ponder what’s worth sharing that anyone could understand, beyond just one input and an AI output.

Nobody here can fix bad AI models, only tell you that GPT-4, not on assistants, is the starting point for coding if you have an account still with access.

Python - get a thread's messages, save
import tkinter as tk
from tkinter import ttk, filedialog, messagebox
import threading
import requests
import os

class App(tk.Tk):
    def __init__(self):
        super().__init__()
        self.title("Assistants: Get Thread Messages")
        self.geometry("800x600")

        self.api_key = os.getenv("OPENAI_API_KEY")
        if not self.api_key:
            messagebox.showerror("API Key Missing", "Please set the OPENAI_API_KEY environment variable.")
            self.destroy()
            return

        # Thread ID Entry
        thread_id_label = ttk.Label(self, text="Thread ID:")
        thread_id_label.pack(pady=5)
        self.thread_id_entry = ttk.Entry(self, width=50)
        self.thread_id_entry.pack(pady=5)

        # Get Button
        get_button = ttk.Button(self, text="Get", command=self.get_messages)
        get_button.pack(pady=5)

        # Frame for messages with scrollbar
        self.canvas = tk.Canvas(self)
        self.scrollbar = ttk.Scrollbar(self, orient="vertical", command=self.canvas.yview)
        self.scrollable_frame = ttk.Frame(self.canvas)

        self.scrollable_frame.bind(
            "<Configure>",
            lambda e: self.canvas.configure(
                scrollregion=self.canvas.bbox("all")
            )
        )

        self.canvas.create_window((0, 0), window=self.scrollable_frame, anchor="nw")
        self.canvas.configure(yscrollcommand=self.scrollbar.set)

        self.canvas.pack(side="left", fill="both", expand=True)
        self.scrollbar.pack(side="right", fill="y")

        # Save Button
        save_button = ttk.Button(self, text="Save Selected Messages", command=self.save_messages)
        save_button.pack(pady=5)

        # Store message variables
        self.message_vars = []

    def get_messages(self):
        # Clear previous messages
        for widget in self.scrollable_frame.winfo_children():
            widget.destroy()
        self.message_vars = []

        thread_id = self.thread_id_entry.get().strip()
        if not thread_id:
            messagebox.showerror("Error", "Please enter a thread ID.")
            return

        # Fetch messages in a separate thread
        threading.Thread(target=self.fetch_messages, args=(thread_id,), daemon=True).start()

    def fetch_messages(self, thread_id):
        url = f"https://api.openai.com/v1/threads/{thread_id}/messages"
        headers = {"Authorization": f"Bearer {self.api_key}",
                   "OpenAI-Beta": "assistants=v2"}
        params = {
            "limit": 100,
            "order": "asc"
        }

        response = requests.get(url, headers=headers, params=params)
        if response.status_code == 200:
            data = response.json()
            messages = data.get("data", [])
            self.display_messages(messages)
        else:
            self.after(0, messagebox.showerror, "Error", f"Failed to fetch messages:\n{response.status_code} {response.text}")

    def display_messages(self, messages):
        # Schedule the GUI update in the main thread
        self.after(0, self._display_messages, messages)

    def _display_messages(self, messages):
        for message in messages:
            role = message.get('role', '')
            content_items = message.get('content', [])
            content_value = ''
            if content_items:
                for item in content_items:
                    if item.get('type') == 'text':
                        content_value += item.get('text', {}).get('value', '') + '\n'

            # Create variables and widgets for each message
            selected_var = tk.BooleanVar()
            self.message_vars.append(selected_var)

            # Header frame for checkbox and role
            header_frame = ttk.Frame(self.scrollable_frame)
            header_frame.pack(fill='x', pady=2)
            checkbox = ttk.Checkbutton(header_frame, variable=selected_var)
            checkbox.pack(side='left')
            role_label = ttk.Label(header_frame, text=f"Role: {role}")
            role_label.pack(side='left', padx=5)

            # Content Text Box
            content_text = tk.Text(self.scrollable_frame, height=4, wrap='word')
            content_text.insert('1.0', content_value.strip())
            content_text.configure(state='disabled')
            content_text.pack(fill='x', pady=2)

            # Separator
            separator = ttk.Separator(self.scrollable_frame, orient='horizontal')
            separator.pack(fill='x', pady=5)

    def save_messages(self):
        # Collect selected messages
        selected_messages = []
        # Each message has 4 widgets: header_frame, content_text, separator
        for i, var in enumerate(self.message_vars):
            if var.get():
                # header_frame is the first widget
                header_widget = self.scrollable_frame.winfo_children()[i*3]
                role = header_widget.winfo_children()[1].cget("text").replace("Role: ", "")

                # content_text is the second widget
                content_widget = self.scrollable_frame.winfo_children()[i*3 + 1]
                content = content_widget.get('1.0', 'end').strip()

                selected_messages.append((role, content))

        if not selected_messages:
            messagebox.showinfo("No Messages Selected", "Please select messages to save.")
            return

        # Open file dialog to save
        file_path = filedialog.asksaveasfilename(defaultextension=".txt",
                                                 filetypes=[("Text files", "*.txt"),
                                                            ("All files", "*.*")])
        if file_path:
            try:
                with open(file_path, 'w', encoding='utf-8') as f:
                    for role, msg in selected_messages:
                        f.write(role + '\n' + msg + '\n\n')
                messagebox.showinfo("Success", f"Messages saved to {file_path}")
            except Exception as e:
                messagebox.showerror("Error", f"Could not save file:\n{e}")

if __name__ == "__main__":
    app = App()
    app.mainloop()