#How do I create dynamic fields for input to a Custom GPT
1 messages · Page 1 of 1 (latest)
Hi @winged estuary. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To create dynamic fields for input to a Custom GPT, you can follow a step-by-step instruction process. This process involves asking the user for their input first before the model takes any action. Here's an example of how you can structure your instructions:
- The user will provide you with specific information (this could be text, a location, a date, etc.).
- Use this information to perform a specific task or generate a response.
For instance, if you're creating a bot that provides weather forecasts, your instructions could look like this:
Context: A user needs information related to a weather forecast of a specific location.
Instructions:
- The user will provide a lat-long point or a general location or landmark (e.g. New York City, the White House). If the user does not provide one, ask for the relevant location.
- If the user provides a general location or landmark, convert that into a lat-long coordinate. If required, browse the web to look up the lat-long point.
- Run the "getPointData" API action and retrieve back the gridId, gridX, and gridY parameters.
- Apply those variables as the office, gridX, and gridY variables in the "getGridpointForecast" API action to retrieve back a forecast.
- Use that forecast to answer the user's question.
This approach allows the model to gather necessary information from the user before generating a response. It's a good practice to give the model time to "think" and work out its own solution before rushing to a conclusion. This can help the model reason its way toward correct answers more reliably.
You can find more details about this approach in the OpenAI's Prompt Engineering Guide (https://platform.openai.com/docs/guides/prompt-engineering).
Remember, the instructions you provide to the model should be clear and specific to get the best results.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@winged estuary Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Can you create a stand alone bot without having to enter the ChatGPT app?
Yea, that's the entire point of the api lol
@deft cloud chat completions basic example python
Let me check the knowledge base for you again. One moment! :books:
Sure, here's a basic example of how to use the Chat Completions API with Python, using the OpenAI Python library:
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Knock knock."},
{"role": "assistant", "content": "Who's there?"},
{"role": "user", "content": "Orange."},
],
temperature=0,
)
print(response.choices[0].message.content)
In this example, a conversation is started with a system message that tells the assistant how to behave, followed by alternating user and assistant messages. The model parameter specifies the model to use, and the messages parameter is a list of message objects. Each message object has a role (which can be 'system', 'user', or 'assistant') and content (the content of the message).
The temperature parameter controls the randomness of the model's output. A value of 0 makes the output deterministic, while higher values (up to 1) make the output more random.
The response from the API call is a ChatCompletion object, and the assistant's reply can be accessed with response.choices[0].message.content.
This information is based on the examples provided in the OpenAI Cookbook (https://cookbook.openai.com/examples/how_to_format_inputs_to_chatgpt_models#2-an-example-chat-completion-api-call) and the OpenAI API documentation (https://platform.openai.com/docs/api-reference/chat).
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@slow kestrel Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Replace the content string after user with inputs
@deft cloud make it a conversation with methods
Let me check the knowledge base for you again. One moment! :books:
Sure, if you want to make it a conversation with multiple turns, you can extend the list of messages in the conversation. Here's an example:
from openai import OpenAI
client = OpenAI()
# Start the conversation
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Knock knock."},
{"role": "assistant", "content": "Who's there?"},
{"role": "user", "content": "Orange."},
]
# Continue the conversation
messages.append({"role": "assistant", "content": "Orange who?"})
messages.append({"role": "user", "content": "Orange you glad I didn't say banana?"})
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=messages,
temperature=0,
)
print(response.choices[0].message.content)
In this example, we first define the initial conversation in the messages list. Then, we use the append method to add more messages to the conversation. Each time we add a message, we specify the role (either 'user' or 'assistant') and the content of the message.
The client.chat.completions.create method is then called with the updated messages list, and the assistant's reply to the final user message is printed out.