Expert Instructor Coder on the GPT Store
GPT Description
GPT Prompt Starters
- Explain Test Cases
- What is the Azure OpenAI GPT-4o with Instructor Package
- prompt_template_code_rewrite
- Use Python tool and explain `instructor_testor.py` Here is the script ``` import os import unittest from unittest.mock import patch, MagicMock from openai import AzureOpenAI import instructor from pydantic import BaseModel, Field from dotenv import load_dotenv # Load environment variables load_dotenv() # Define the models as per the original script class CodeSnippet(BaseModel): language: str code: str explanation: str class CodingAssistant(BaseModel): task: str solution: CodeSnippet additional_notes: str = Field(default="") # Define the function to be tested as per the original script def get_coding_solution(task: str) -> CodingAssistant: # Fetching environment variables endpoint = os.getenv("AZURE_OPENAI_ENDPOINT") key = os.getenv("AZURE_OPENAI_API_KEY") version = os.getenv("AZURE_OPENAI_API_VERSION") deployment = os.getenv("CHAT_COMPLETIONS_DEPLOYMENT_NAME") # Initialize AzureOpenAI client client = AzureOpenAI( azure_endpoint=endpoint, api_key=key, api_version=version ) # Patch the client with instructor instructor_client = instructor.patch(client) response = instructor_client.chat.completions.create( model=deployment, response_model=CodingAssistant, messages=[ {"role": "system", "content": "You are an expert coding assistant."}, {"role": "user", "content": f"Provide a solution for the following coding task: {task}"} ] ) return response # Test case class class TestCodingAssistant(unittest.TestCase): @patch('instructor.patch') @patch('openai.AzureOpenAI') def test_valid_coding_solution(self, MockAzureOpenAI, MockInstructorPatch): # Mock environment variables os.environ['AZURE_OPENAI_API_KEY'] = 'fake-api-key' os.environ['AZURE_OPENAI_ENDPOINT'] = 'https://fake-endpoint' os.environ['AZURE_OPENAI_API_VERSION'] = '2024-02-01' os.environ['CHAT_COMPLETIONS_DEPLOYMENT_NAME'] = 'fake-deployment-name' # Set up mocks mock_client = MagicMock() MockAzureOpenAI.return_value = mock_client mock_instructor_client = MagicMock() MockInstructorPatch.return_value = mock_instructor_client # Mock response from the chat completions.create method mock_response = CodingAssistant( task="Write a Python function to find the nth Fibonacci number using recursion.", solution=CodeSnippet( language="Python", code="def fibonacci(n):\n if n <= 0:\n return 0\n elif n == 1:\n return 1\n else:\n return fibonacci(n-1) + fibonacci(n-2)", explanation="This function uses recursion to compute the nth Fibonacci number." ), additional_notes="Ensure to handle large values of n carefully due to recursion limits." ) mock_instructor_client.chat.completions.create.return_value = mock_response # Call the function to be tested result = get_coding_solution("Write a Python function to find the nth Fibonacci number using recursion.") # Assertions self.assertEqual(result.task, mock_response.task) self.assertEqual(result.solution.language, mock_response.solution.language) self.assertEqual(result.solution.code, mock_response.solution.code) self.assertEqual(result.solution.explanation, mock_response.solution.explanation) self.assertEqual(result.additional_notes, mock_response.additional_notes) @patch('instructor.patch') @patch('openai.AzureOpenAI') def test_invalid_task_input(self, MockAzureOpenAI, MockInstructorPatch): # Mock environment variables os.environ['AZURE_OPENAI_API_KEY'] = 'fake-api-key' os.environ['AZURE_OPENAI_ENDPOINT'] = 'https://fake-endpoint' os.environ['AZURE_OPENAI_API_VERSION'] = '2024-02-01' os.environ['CHAT_COMPLETIONS_DEPLOYMENT_NAME'] = 'fake-deployment-name' # Set up mocks mock_client = MagicMock() MockAzureOpenAI.return_value = mock_client mock_instructor_client = MagicMock() MockInstructorPatch.return_value = mock_instructor_client # Mock response for invalid input mock_instructor_client.chat.completions.create.side_effect = ValueError("Invalid task input") # Call the function to be tested with self.assertRaises(ValueError): get_coding_solution("") @patch('instructor.patch') @patch('openai.AzureOpenAI') def test_different_coding_task(self, MockAzureOpenAI, MockInstructorPatch): # Mock environment variables os.environ['AZURE_OPENAI_API_KEY'] = 'fake-api-key' os.environ['AZURE_OPENAI_ENDPOINT'] = 'https://fake-endpoint' os.environ['AZURE_OPENAI_API_VERSION'] = '2024-02-01' os.environ['CHAT_COMPLETIONS_DEPLOYMENT_NAME'] = 'fake-deployment-name' # Set up mocks mock_client = MagicMock() MockAzureOpenAI.return_value = mock_client mock_instructor_client = MagicMock() MockInstructorPatch.return_value = mock_instructor_client # Mock response from the chat completions.create method mock_response = CodingAssistant( task="Write a Python function to sort a list of integers using bubble sort.", solution=CodeSnippet( language="Python", code="def bubble_sort(arr):\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] = arr[j+1], arr[j]", explanation="This function sorts a list of integers using the bubble sort algorithm." ), additional_notes="This implementation is straightforward but not the most efficient for large lists." ) mock_instructor_client.chat.completions.create.return_value = mock_response # Call the function to be tested result = get_coding_solution("Write a Python function to sort a list of integers using bubble sort.") # Assertions self.assertEqual(result.task, mock_response.task) self.assertEqual(result.solution.language, mock_response.solution.language) self.assertEqual(result.solution.code, mock_response.solution.code) self.assertEqual(result.solution.explanation, mock_response.solution.explanation) self.assertEqual(result.additional_notes, mock_response.additional_notes) @patch('instructor.patch') @patch('openai.AzureOpenAI') def test_api_error_handling(self, MockAzureOpenAI, MockInstructorPatch): # Mock environment variables os.environ['AZURE_OPENAI_API_KEY'] = 'fake-api-key' os.environ['AZURE_OPENAI_ENDPOINT'] = 'https://fake-endpoint' os.environ['AZURE_OPENAI_API_VERSION'] = '2024-02-01' os.environ['CHAT_COMPLETIONS_DEPLOYMENT_NAME'] = 'fake-deployment-name' # Set up mocks mock_client = MagicMock() MockAzureOpenAI.return_value = mock_client mock_instructor_client = MagicMock() MockInstructorPatch.return_value = mock_instructor_client # Mock API error response mock_instructor_client.chat.completions.create.side_effect = Exception("API Error") # Call the function to be tested with self.assertRaises(Exception): get_coding_solution("Write a Python function to find the nth Fibonacci number using recursion.") # Run the test if __name__ == '__main__': unittest.main()```
Expert Instructor Coder GPT FAQs
More custom GPTs by askbigplay.com on the GPT Store
`Browser`Tool
Enhance online research, scraping and summarizing
1K+
Interior Design Expert
Specializing in condos in South Florida
200+
RAG Prompt Optimizer
Specializes in categorizing, optimizing, and indexing prompts, templates, and instructions for Retrieval-Augmented Generation (RAG) systems. Enhances content for improved AI retrieval and generation capabilities.
200+
Productivity Toolkit
Advanced assistant for productivity and tool expertise.
100+
RAG-Boost
Optimizing inference and empowering users to interact with their documents through ChatGPT, enriched with memory from the "text-embedding-ada-002" OpenAI embeddings stored in the Azure AI search index
100+
Respond like a Term Paper
structured and thorough workflow to meet objective
100+
Perplexity Whisperer
Optimizing Perplexity.ai queries for enhanced information retrieval and summarization
100+
Rover Repair Assistant
Personal Guide for Land Rover & Range Rover Care
80+
Vector Logo Generation Expert
Generating unique and professional vector logos using DALL-E
80+
CodeMaster AI
Elite Python coder with 20 years in generative AI, expert in TDD and code optimization.
70+

DAX & Power Query Coding Assistant
Expert in Power BI DAX and Power Query
70+
AI Songwriter and Music Maker
Prompt expert for creating songs based on specified user inputs and preferences.
60+
System Instruction Master Navigator
instructions are expertly crafted, consistent, and structured, specifically tailored for GPT-4 Turbo Model and OpenAI Assistants OpenAI API
50+

RAG for myfiles
Optimizing `myfiles_browser`for Retrieval-Augmented Generation
50+
Master Orchestrator v3
Adept at harnessing expert tools to fulfill diverse needs with precision and insight.
40+
RAG AI Instruction Maker
To equip developers with a structured guide for creating AI systems that are user-centric, adaptive, and effective, ensuring a seamless and personalized interaction experience that aligns with user needs and enhances their ability to achieve objectives efficiently.
40+

Call Flow Expert
Specializing in designing and optimizing call flows for conversational AI systems
40+
Perplexity API Integration Expert
Code integration options with the Perplexity API
40+
Sky
Expert Python programmer specializing in pandas DataFrames
30+
DD's Portfolio Manager
An AI assistant for portfolio management, using PortfolioOpt_CoR and other tools. Friendly, supportive, and consistent interaction. Logical and practical guidance. Rhetorical questions for tree of thoughts.
30+

AI Highlighter Expert Assistant
Roam Highlighter o optimize content highlighting, formatting, and importing into note-taking applications like Roam Research
30+
Boston Adventure Trip Planner
Boston Trip Planner providing tailored and comprehensive travel planning assistance for visitors exploring the city
30+
Open Interpreterv2
Advanced Code Execution Assistant
30+
Geek Squad Tech Lead (GSTL)
providing exceptional technology help and guidance one ticket at a time
20+
App Development Workflow with Toolkit
Specialized AI AutoAgent with a Suite of Tools, including App Building Guidance
20+
Alpha Wolf AI AutoAgent
Integrated Persona for Enhanced Collaboration
20+
Chat History Parser Workflow
Transforms raw conversation data into a structured JSONL format
20+
Dataset Maker
Specialist generating synthetic conversation data
20+
Ultimate Roaster
crafts sharp, clever jokes with puns, alliterations, and relevant humor. It balances light and dark by poking fun while highlighting strengths. Creative and bold, it avoids hurtful remarks, tailoring roasts to personalities. Constructive, it mixes compliments for a playful tone
20+
DD's Portfolio Manager (Claude)
An AI assistant for portfolio management, using PortfolioOpt_CoR and other tools. Friendly, supportive, and consistent interaction. Logical and practical guidance. Rhetorical questions for tree of thoughts.
20+
Azure Subscription Expert
Specialized in managing Azure subscriptions and optimizing Azure AI services
20+
CustomGPT Indexer
Expert system for structuring and indexing ChatGPT models.
20+
Dr. Alex Turing v3
The Ultimate Agent - multi-faceted expertise of a seasoned technology strategist, embodies a persona that seamlessly integrates the comprehensive skill set of the Microsoft's Generative AI Framework "AutoGen Studio" toolkit
10+
AutoGen Guide
AI assistant for project planning and execution with a focus on Autogen Framework and Microsoft Fabric integration.
10+

Tornado Recovery Guide (TRG)
Expert Assistant for Tornado Recovery in Family Fun Centers
10+
Convo Insight Synthesizer
Summarizer of entire ChatGPT conversations.
10+
SWE AGENT HELPER
Expert on creating SWE-agent turns LMs (e.g. GPT-4) into software engineering agents
10+
Conversation Starter Maker
I make expertly written, structured and aligned conversation starters to enhance inference
10+
Building a Knowledgebase from Conversation
Transforming unstructured text provided by the user during a conversation into a structured knowledgebase, formatted as JSON
10+

LM Studio AI Model Configurator
Expert in creating, modifying, and explaining configuration files for LM Studio AI
10+

Paul's Copilot
a wise guide, specializing in helping me achieve my goal according to my [preferences].
10+
Model Picker
Expert specializing in identifying, recommending, and configuring AI models from Hugging Face and LM Studio
10+
Clogged Toilet Expert
Professional plumber with extensive experience in dealing with clogged toilets
10+
M Click Expert
assist in gathering detailed and varied information
10+

Advanced Power Query Assistant
Specializing in Power Query, DAX, and related topics within the Microsoft Fabric ecosystem
10+
Advanced Browser AI Assistant
Sophisticated web crawling, content synthesis, and research capabilities
10+

Integration Expert
Expert on creating Azure OpenAI integration code for a given input
10+
Structured Reasoning AI
Tackle complex problems through systematic analysis and multi-step reasoning
10+
Expert Search
dedicated AI-driven research companion, I excel in delivering comprehensive insights and bespoke solutions across AI, Python development, and the broader domain of Prompt Engineering
10+
GenomeQuest
Your guide for genetic exploration & online research
10+
Family Hub
To facilitate effective communication and coordination among family members in a blended family setting
9+
Grandma with an iPhone
Patient and clear technical support to grandmas
9+
Ultimate AI-Detector
Equipped to effectively analyze, score, and identify AI-generated text
9+
Agent Orchestrator
Master as building skill-tool-pools, assigning and summoning them to agents to complete tasks using AutoGen
9+
Fabric Weaver
Fabric Weaver is your expert AI companion for building and maintaining web-based Fabric pattern libraries. With deep knowledge in Flask, Python, and pattern management, Fabric Weaver guides you through every step of your project, from setup to advanced features.
8+
Paul's Copilot
To ensure you have all the tools and insights at your fingertips to excel and innovate in your role.
7+
Wayne Brown's Digital Twin
Digital Twin of Wayne Brown
7+
Advanced Browser Agent
Efficiently navigate and search the web using specialized tools to fulfill user request
7+

Venture Fund Analyzer
Evaluate each company within the ARK Venture Fund for potential investment
7+
RAG Expert
Optimize Cosmos DB conversations for Retrieval-Augmented Generation (RAG)
6+
Dr. Alan Maxwell
Seamlessly integrates diverse AI components to address multifaceted challenges
5+
Email Summary Expert Assistant
Summarize email chains, highlighting key exchanges, topics, and action items
5+

Cipher Sentinel AI
Compliance Security Confidentiality Availability Integrity Expert
4+
Informed Compassion GPT
providing accurate and contextually relevant information (Informed) while engaging in natural, empathetic interactions (Compassion)
4+
Bubble Maker
Develop a custom ChatGPT action to enable seamless querying of Power BI datasets, ensuring that users can effortlessly generate and interpret data visualizations
3+
Ultimate AI-Detector (Claude)
Equipped to effectively analyze, score, and identify AI-generated text
3+
Iterative Query Handling Workflow
Iterative Query Handling Workflow
3+